Intro
Here in part 6 we won't go very in-depth into the code. There were just too many changes, so I'll post a link to the full solution at the bottom of this post for you to download and peruse at your pleasure. I'll cover some of the highlights below though so you know what's different from last week.ChessValidMoveCalculator
A number of files have been modified to make this week possible. First and foremost, ChessValidMoveCalculator. It has been very heavily modified to include the following types of chess piece movement:- basic knight moves
- basic bishop moves
- basic rook moves
- basic queen moves
- basic king moves
- can't move a piece on top of another piece of the same color
- only the person whose turn it is can move
- pawns can't jump over pieces
- knights CAN jump over pieces
- bishops can't jump over pieces
- rooks can't jump over pieces
- queens can't jump over pieces
- pawns can go 2 squares only if they start on row1 or row7
- pawns can move diagonal only to capture piece
Default.aspx and Default.aspx.cs In BlogChessApiFlexer
I modified these pages only to facilitate testing of the Web API. But hey, it's still useful!BlogChessController (the Web API Main Unit)
I also modified this unit to facilitate testing. The method PostBestMove, which is supposed to calculate and return the best move, has now been tasked with calculating and returning the complete list of valid moves. Later on when we can evaluate boards we'll set it back to its rightful purpose, but for now it's a great way to debug the code that's currently available.Action Shot
I kinda feel like I need to show this product in action, so here's a screenshot of it doing it's thing:The above shows the valid moves, as calculated by our code, assuming a standard chess starting position. Recall those piece values from a couple blogs ago? 0=empty square,1=pawn,2=knight,3=bishop,4=rook,5=queen,6=king, with black pieces being the negative value. Pretty cool huh? I hope you're enjoying this project, I certainly am. Lotta work though!
What's Next?
We still haven't attempted victory conditions, so we'll still have to do those at some point. We also skipped 2 types of movement that I just didn't have time for this week: pawn capture en-passant, and castling. We'll probably tackle at least those 2 next week.And as promised, here is the solution file.
No comments:
Post a Comment