i made a script that searches for the best possible move to do in a bejeweled game.
the code is a bit messy, but it should work.
explenation of how it works.
first it wil start with indexing the field
so it wil know where all the jewels are placed, and what kind of jewel each is.
then it will search for all the moves that are possible, for each move it wil start the proces again it searches again for all the moves, he wil do this till he know al the possible combinations.
it wil remember wich combination gave him the most opertuneties
like:
first it wil ave 3 moves.
the first one gave him one other move and after that none.
second one gave him 3 possible moves, after all thes moves there was only one left.
the third move, only gives one move, but that move gives him 2 other moves, one of these wil end the game the other gave him another move, after this move he don't know how many moves he wil have, becaus he don't know what the jewels are that will fall.
il put it in a tabel
- move1
- move1
- no more moves
- move2
- move1
- no more moves
- move2
- no more moves
- move3
- no more moves
- move3
- move1
- move1
- no more moves
- move2
- move1
- don't know what wil fall, but this one gives him the most opertunities
so now it wil do move 3, this one gives him the most possible moves.
when he did the move, this wil all start over.
it does one move, searches again and find the best move for the field with the new fallen jewels.
hope my english wasn't to bad:P

