January 24, 2017

Hello everyone. Hope you had a nice weekend.

If you have been following along you know we did a fun project ‘Designing a Chess Game in Alpha Software’. It was fun for me at least and I hope all of you liked it or at least found some value in it. The finished chess game worked OK but not great. Any mid-level player could easily beat the game and the reason for this is our game only looked ahead two moves and the second move was limited to handling and or avoiding check. I have been giving this some thought and decided to see if I can expand the second move analysis and look at the third potential move if possible.

To do this we need to examine the process as it currently exist. In our game White is controlled by the human player and Black in controlled by the computer. When the game starts the computer looks at all available moves for white and verifies that what ever piece the user selects it insures the move by the user is legal stopping all moves which are not. Blacks move originally looked at our saved games in our open book finding the move made by the human player and then selected the most often used move as a counter. If no moves were found in the open book the computer then looked to see if they were in check and if so responded accordingly. If not, looked to see if a piece was under attack or could black’s move capture a white  piece and if so, picked the move with the highest value. If neither of those applied the computer would move to strengthen defense where possible.

Lets examine why this sequence is weak.

Black checked by white

Current condition knows that Black is in check and if the threatening square can be captured it makes that move. This happens regardless of what whites response could be. So if the attack piece is a pawn  and black uses a Queen to take the pawn then White takes the Queen; that is a bad move. Black looses in both material and position. Our new code will look at what is better; moving the King or blocking check or if capture is the only option, then look at all capture scenario’s choosing the one which has the highest value.

Black moves to a square which puts White in Check

Currently our program does not know if a move will result in check. It only knows what pieces of white can be captured based on current board layout so our new code will look at all moves available for the current pieces on the board and all moves available based on each square a piece can move to This will include a guess as to White’s response for each possible move.

Black looks to the Open Book for saved moves based on whites sequence of moves and blacks response up to this move.

This process was slow and did not always find the correct response. Our new procedure now takes a snapshot of the board layout and stores the code for that image in the Open Book. This means Black only needs to see the same image as the current board image and then picks the best move of the available moves matching that image. I already tested this and it works much faster and more often picks the best move. (still not perfect)

 

This is turning into a very busy day so I have to stop for now but will continue tomorrow. Tomorrow we will be using collections as a means of tracking future moves for each available piece  starting with the King. I hope you will have time to follow along.

That’s all for today. If you are a business and need help with an Alpha Software program, contact us. Are rates are reasonable and our work is guaranteed.

Phone:713 417-6831

EMail: NLawson@cdc-takecharge.com