I've been tasked with implementing either the min-max function or alpha-beta pruning to code AI for the game Gumoku (connect 5, vertical, horizontal, or diagonal).
In both algorithms an evaluation function is called to analyze the board of play. Is there any "easy" way to do this? My initial plan is to store the board as a 2D array and then compare values stored in the array to determine each players position on the board. The board looks something like this:
0 0 0 0 0
1 0 0 1 1
0 0 0 0 0
2 0 1 2 2
0 0 0 0 0
where 0's are open spaces, 1's are player one's pieces and 2's are player two's pieces. In order to evaluate how advantageous the board is I would need to check how many in a row each player has and assign a value to how good it is (i.e. 2 in a row is worth 5, 3 in a row is worth 8 ... 5 in a row is worth 30 and is a win).
The way I started doing is is a vector of points for the position of each player's piece on the board, then comparing adjacent indexes in the board array to see if a player had two or more pieces in a row. However, this seems very inefficient and requires several sets of nested if-statements. Is there a faster, better way to handle this?
Thanks for any input or ideas :)