Monday, August 2, 2010

simple move-evaluation

I have added the a simple function that evaluates each possible move and selects the move with the best result. This is done by assigning a value to each piece (white pawn = 1, black pawn = -1, white knight = 3, black knight =-3...) and then building the sum of everything that is left on the board.
Right now the evaluation depth is set to one half move for debugging purpose, meaning that the evaluation function only takes into account the pieces it sees on the board and doesn't care about what happens after the next moves. This provides for a rather crude and greedy game-play, though it's definitely an improvement over selecting the next move at random.
Once I'm happy with it and some bugs are ironed out I will increase the evaluation depth by calling the evaluation function recursively. It will be interesting to see how everything performs at this level.
Strategic and positional knowledge  is an entirely different matter - I'll save that for some later time :)
Here is a debug output:




Possible moves: 17
E8-D7: Score -1
E8-D8: Score -1
E8-F8: Score -1
E8-F7: Score -1
E7-E6: Score -1
E5-E4: Score -1
E5-E3: Score -6
E5-E6: Score -1
E5-D5: Score -1
E5-C5: Score -1
E5-B5: Score -1
E5-A5: Score -1
E5-F5: Score -1
E5-G5: Score -1
E5-H5: Score -1
D3-E2: Score -2
D3-D2: Score -1
10 ########################
09 ########################
08 ####........Kb......####
07 ####........Pb......####
06 ####................####
05 ####........Rb......####
04 ####................####
03 ####......PbRw......####
02 ####........Pw......####
01 ####........Kw......####
00 ########################
01 ########################
   # # A B C D E F G H # #
Best move: E5-E3: Score -6


No comments:

Post a Comment