2

I'm trying to code AI for a game somewhat similar to Tic-Tac-Toe. You can see its rules here.

The min-max algorithm and analysis function I'm using can be found here

The way I've tried so far:

  1. I've built some patterns which will be good for the current player. (in Python)

e.g. my_pattern = " ".join(str(x) for x in [piece, None, piece, piece, None])

  1. I'm matching such patterns with all the 6 possible orientations on the hexagonal gameboard for every piece (not for blank spaces). To be precise, matching my_pattern with 6 different arrays (each array represents one of 6 different orientations).

Now, What should this analysis function actually calculate?

  1. The score of entire state of board?
  2. The score of the last move made on board?

If someone can accurately describe the purpose of Analysis function, that would be great.

rpiman
  • 21
  • 2

1 Answers1

0

The analysis function represents the current state of board. It may/ may not include the last move, any of the previous moves or the order of moves to reach a board position. It should also consider whose turn it is to play.

What I mean is the same board can be good/bad for white/black depending on whose turn it is. (Called the situation of zugzwang in chess).

Also, the same board can be reached in a variety of move sequences, hence, it depends on the type of game whether you want to include that in the analysis or not. (High level chess engines surely include order of moves, though not for calculating current board, but for further analysis on a possibility of reaching that position). In this game however, I don't think there is any need of including last or any of the previous moves (order) for your analysis function.

EDIT:

An example of analysis function:

value = 10000*W(4) - 10000*W(3) + 200*W(2.1) + 200*W(1.2) + 100*W(2) + 100*W(1.1) + 2*W(1e) + 10*W(1m) + 30*W(1c) - (10000*B(4) - 10000*B(3) + 200*B(2.1) + 200*B(1.2) + 100*B(2) + 100*B(1.1) + 2*B(1e) + 10*B(1m) + 30*B(1c))

where:

W = white
B = black pieces
4 = made line of 4 pieces
3 = made line of 3 pieces
2 = made line of 2 pieces having possibility of getting extended to 4 from atleast one side
. = blank (ie, 1.2 = W.WW on the board)
1.1 = Piece|Blank|Piece and possibility of extending to 4 from atleast one side
e|m|c = edge|middle|center of board, and possibility of extending to 4 from either sides

The positive result of this analysis function would mean white is better, 0 indicates balanced board and negative value means black has advantageous position. You can change the weights owing to the result of tests you will execute. However, finding all possible combinations is exhaustive task, but the game is such :)

vish4071
  • 5,135
  • 4
  • 35
  • 65
  • So, what should the analysis function return to the Min-Max algorithm? On basis of what should I calculate the score? – rpiman Nov 28 '16 at 12:29