How to evaluate the connection of four game situations in java

I am trying to write a simple AI for a "Get four" game. The basic principles of the game are done, so I can throw coins of different colors and they stack on top of each other and fill the 2D array, etc. Etc. so far it looks like this:

public int insert(int x, int color)  //0 = empty, 1=player1 2=player2"

      

X is the horizontal coordinate, since the y coordinate is determined by the number of stones in the array already, I think the idea is obvious.

Now the problem is that I have to evaluate specific game situations, so find out how many new pairs, triplets and possible 4 per line I can get in a specific situation, so that then give each situation a certain value. With these values, I can tweak the "game tree" so that I can later decide which one will be better than the next one (hereinafter the Alpha-Beta-Pruning implementation). My current problem is that I cannot think of an efficient way to implement the rating of the current game situation in a java method.
Any ideas would be greatly appreciated!

0


source to share


3 answers


I'm assuming this is homework and you want to say that you want to write an evaluation function and don't know what tricks to use?

The game is called "Connect 4" in English, so you can "connect 4 evaluation functions".



You can find enough heuristics to discuss people.

Please do not copy the actual source code, this is an important exercise :)

+4


source


The search space for Connect 4 can't be big. For a simple implementation, although one of them will take some time (maybe tens of minutes), it does a minimax search until someone wins, or the game ends. Assign +1 or -1 for a win for one player or another and 0 for a draw.



+1


source


nonsense. the search space is huge. you need to use a predefined table if you want to do this.

0


source







All Articles