|
Post by schlum on Apr 30, 2014 14:48:14 GMT 1
Hi !
I’m coding an IA to play the game, but can’t catch up with your merging rules ; what about greediness and priority ?
If I set not greedy, right priority as for 2048 original version, with max 3 tiles merging, it don’t work * 2 2 1 1 1 going right, expected 0 0 0 5 2, got 0 0 0 2 5 (4 tiles merged) * 1 1 2 1 1 going right, expected 0 0 2 2 2, got 0 0 0 1 5
On the contrary, if I set it the most greedy possible with 4 or 5 tiles merging possible, I can’t get it too : * 1 0 1 2 1 going right, expected 0 0 0 0 5, got 0 0 2 2 1 * 0 1 2 5 2 going left, expected 10 0 0 0 0, got 1 2 5 2 0 (so those 4 can’t be merged ?)
What are the rules for 4 tiles (and 5?) merging and priority between 2 tiles merging / 3 tiles merging ?
Sincerely
|
|
|
Post by schlum on Apr 30, 2014 15:32:23 GMT 1
Btw, even with this imprecision, a very poor heuristic (only based on free tiles) and a 3 level based expectiminimax alg, the IA got the 100 € and 134597 pts
|
|
|
Post by Admin on Apr 30, 2014 17:58:35 GMT 1
4 or 5 tiles can't be directly merged, as the game would be too easy that way. (If there is a two-step merge like 2+1+1+1 -> 2+1+2 -> 5, it is performed. But it can't go 1+1+1+2 -> 1+2+2 -> 5, only in two separate steps and 1+2+5+2 can't be merged at all.)
Priority is that starting from the right, we iterate through the tiles. If a tile that can be merged with another one or two to the left is found, we merge them and continue with the merged tile. (1+1+1+2 doesn't merge in one step because we start with the 2, can't merge it so we move on to the 1. We merge it with the 1 to its left, yielding 1+2+2. We are now at the first 2, and can't merge because the 2 tile to the right isn't taken into account.)
By the way, the score your AI achieved is the highest score in the game so far!
|
|
|
Post by schlum on Apr 30, 2014 19:10:15 GMT 1
The second try with a 4-6 deep tree gave a 402496 with the 200 € and a 100 € I’m confident that by having a better heuristic, it can achieve a double 500 € (but it does not play at all like the original 2048, it takes care about free space a way more than sticking big ones in corners or edges… with this heuristic at last !) I’ll try to figure out the merging thing, thanks for the explanations
|
|
|
Post by schlum on Apr 30, 2014 22:57:42 GMT 1
I could manage to code the same merge behavior lol (with a lot of code and conditions ; I’m glad the merging results are preprocessed on all possible sequences for optimization ^^) The current run just achieved the first 200 € tile If you want to try the IA, I put the code here : cschlum2.free.fr/2048euro.cIt works with FireFox and the extension Remote Control ( addons.mozilla.org/fr/firefox/addon/remote-control/ ) You can change the expectiminimax tree exploration deepness with the macros MAX_NB_CALLS and MIN_MAXLEV The heuristic is currently only on the number of free tiles ; it works quite well, and it seems hard to find a more specific heuristic with all these merging conditions ^^
|
|
|
Post by schlum on Apr 30, 2014 23:02:05 GMT 1
Oh I’m not sure the TCP / socket functions to talk with Firefox / Remote Control can be compiled on Windows :/ All other pieces of code should be OK (standard C & libs)
|
|