I feel like I want to share my experience with CG games, so far, and ask you for opinion.
It seems to me that when I’m using some greedy algorithm I’m getting better results rather than when trying to implement “big search algorithm”.
For example in “The Accountant” contest I tried nothing fancy, just plane, well structured, “if else” blocks and I did quite well, compared to my other accomplishments. In Code4Life again I tried simple evaluation of the game state and making conclusions based on that.
But when I try rather complex algorithm like big game search algorithm I cannot accomplish almost anything. Almost all of the attempts end up in slow algorithm or very big branching factor. For example in Mars Lander I tried to study Genetic Algorithms and really want to solve the task with GA I went through many tutorials and my algorithm won’t converge no matter what I try.
Even I wrote animation simulation to see what I’m missing:
(more brighter path has low evaluation)
But still nothing, may be I’m not using the right mutation. But I cannot conquer the randomness. Not to mention it’s slow.
In legends Of Code and Magic I started with simple strategy to play all possible creatures from hand and attack first all opponent creatures then hit the opponent. This strategy was working like charm in the first leagues and then I decided to make tree which first makes all possible hand combinations simulates them then simulates all items for all targets and finally all possible attacks. The branching factor was gigantic. Tried to decrease it, but I was completely tangled with tweaks like when to play charges, which Items to use, when to simulate attacks, each thing depends on the other, so I hadn’t great success there also.
Other thing I thought was to encode my state as narrow as possible, to use every bit of several ints or longs, with big amount of masking and bitwise operations. And I thought this could grant me the possibility to have bigger branching factor, to store more graph nodes with states and to get in the time limit. Nothing like this, not to mention it is hell to debug.
Recently I was solving SkyNet episode 2. At first I thought “this task is great for Dijkstra’s algorithm” after 300 pains and many days I managed to solve it using Dijsktra and after browsing the best solutions I saw that the right algorithm was BFS and I had no clue about that.
Is it me or someone else have similar obstacles. May be I’m not so talented to see which algorithms to use or I’m making implementation mistakes.