Friday, 28 October 2016

Finally checkers is complete

Wohoooooooo!
I have finally completed my checkers game. Last time I posted, I had not made the visibility of King, its movement and its capture. I had also not done the win condition.

But, now everything is complete.

How I did this all?

1) It was actually very simple. The work I needed to do was repetitive. My lines of code did increase from 350 to 750 but again the stuff that I did was copy and paste from my own code with some minor changes.
2) For movement of kings,Since kings move in both directions, I just used the logic of movement of black and white pieces and their capture.

So finally white pieces can move and capture black pieces. Black pieces move and capture white pieces. White king moves, captures black king and black pieces. Black king moves, captures white king and white pieces.

Two integers to maintain the count of pieces. If either of the pieces go to zero, that particular player wins.  

No comments:

Post a Comment