Xenthalon Posted December 21, 2006 Share Posted December 21, 2006 So I have been using AutoIt since a few years now, but never started any bigger projects than some small automations. Recently I stumbled upon a nice Tetris variant and decided to write a AutoIt script for it that basically plays the game for me. After a couple of hours of work I got a good base, reading out the current field with Pixeldetection, detecting the next stone thats gonna come up, some game menu navigation and all that. Even a very basic AI which was able to play the game, but honestly was at the intellectual level of an infant. This AI went rather smooth, it only set the stones a little slower when it was in the higher rows of tetris, but it wasn't that bad. So I searched the internet for a better AI and found excellent C++ code and rewrote it to work in AutoIt. It works and gives no errors, but that is basically it. What that AI does is the following: It takes a copy of the current known field and the stone it has to set at this very moment. Then it sets the stone at all possible positions in all angles, and rates the resulting field and eventually sets the real stone in the real field at the best position. However this takes a huge amount of time, by the time the AI is done calculating the best spot the stone is already 3/4 down the field. This is not as intended and now I am searching for ways to improve that. Now to my questions: 1. Is it possible to use something similiar to pointers in AutoIt? At the moment I just copy the field in a second array again and again which surely takes some performance. 2. Can my user defined functions return more than one parameter? My current way is rather sloppy and it involves using StringSplit after calling the function which I am not very fond of. 3. This may sound really noobish now, but I am running in troubles with arrays now and then which I can't really understand. Now is $array[column][row] or [row][column]? Or in the mathematical context, is it x y or y x? It all works nicely but I got moments of doubt... I hope you can help me. Thanks in advance. Link to comment Share on other sites More sharing options...
Zedna Posted January 6, 2007 Share Posted January 6, 2007 Now to my questions: 1. Is it possible to use something similiar to pointers in AutoIt? At the moment I just copy the field in a second array again and again which surely takes some performance. 2. Can my user defined functions return more than one parameter? My current way is rather sloppy and it involves using StringSplit after calling the function which I am not very fond of. 3. This may sound really noobish now, but I am running in troubles with arrays now and then which I can't really understand. Now is $array[column][row] or [row][column]? Or in the mathematical context, is it x y or y x? It all works nicely but I got moments of doubt... I hope you can help me. Thanks in advance. 1) for pointers is DllSctruct... functions but for your copu of array it's not usable 2) in your UDF use params with ByRef 3) $array[column][row] or [row][column] it x y or y x? - depends on how you fill/use values into/from your array - both may be correct but I think in most cases is first one implicit. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 6, 2007 Share Posted January 6, 2007 Arrays are not arranged in an x, y, z, etc pattern. They are rank 0, rank 1, rank 2, etc. If I could see the C++ code you have, I may be able to help. Link to comment Share on other sites More sharing options...
BALA Posted January 6, 2007 Share Posted January 6, 2007 (edited) Also, those codes were probably written in a C-type language for the reason that C has a knack for making programs written in it run fast. Edited January 6, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now