Andy's LEGO® Mindstorms® Page
About this site
  
What's New?
  
Standard Disclaimer
Quite C
  
Francesco Ferrara
  
Getting Started
  
Installing Quite C
  
Compiling a project
  
Sample Code
Chess
  
The Robot Chess Project
  
Programming Chess
  
First Attempt
  
Version 0
  
Version 1
  
The Program
  
The State of Play
  
The User Interface
  
The Move Generator
  
The Move Applier
  
The Rating Algorithm
  
The Search Algorithm
  
Putting it all together
  
The Robot
  
The Head
  
Moving the head
  
Movies
  
Downloads: Source Executables, MLCad Models
4-in-a-Robot
  
4-in-a-Robot - the Robot
  
The 4-in-a-Robot Base
  
The 4-in-a-Robot Delivery Mechanism
  
The 4-in-a-Robot Controller
  
4-in-a-Robot - the Code
  
The 4-in-a-Robot Algorithm
  
The 4-in-a-Robot Control Programming
  
The 4-in-a-Robot Robot-less version
  
Installing 4-in-a-robot
  
Playing the robotless 4-in-a-robot
  
View the source code
Speech
  
The problems with speech
  
Sounds familiar
  
H8 Timers Background
  
Trial and Error
  
Volume Zapper
  
Actually Speaking
  
Speak.c - the code
  
The VB code generator
Some ideas for the future
  
Room positioning robot
  
Neural Net Bot
  
Pianola
  
Text to speech
LEGO® Mindstorms® Links

[268703]

The Move Applier

 

The Move Applier


The move applier is a long, but relatively straighforward piece of code.
It takes a move, records it in the undo buffer, and applies it to the current board state.
Each of the possible types of move are covered with a piece of code, i.e.

Pawn moves



  • Reset the draw50 counter

  • Check for en-passant, removing the enemy piece

  • Check Pawn promotion

  • Move the pawn

  • If the pawn move is two squares, set up the en passant square for the next go


Castling Moves



  • Check all squares involved in the castle are not attacked, as one can't castle through check

  • Move both the king and the rook involved

  • Update the appropriate king position data


King moves


  • Clear all castling flags

Rook moves


  • Clear the approprate castling flag

All moves


The piece is moved in the board arrays to make the move

Left in check?


We then check to see if the current player is in check, and if so we mark the move as invalid

Three move draw


The three move draw test is based on that found in TCSP as described by John Stanback. It's a little difficult to describe, but I'll try and put up some more details here later.

If the move was invalid, we call the undo move function to reset the board state to how it was before the move.
Finally, we return whether the move was invalid.

The Move Undo-er


This is pretty much the same as the move applier, but in reverse.


Back to: The Move Generator

Show Topic: The Program

Next Page: The Rating Algorithm