Skip to content

Arc891/CLChess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLChess

This is just a small command line version of chess for me to get back into Python programming. My goal is to make it as complete as possible in terms of both functionality and looks.

TODO

  • Figuring out all possibles moves at any point
  • Implementing en passant, registering checks and checkmate

Checking possible moves:

While checking a piece's possible moves, every physical possible move is an easy calculation; which spaces are empty that the piece can move to, or if there is a spot where an opponent's piece is that it can take. However, some moves are illegal, for instance, a King cannot move into the range of another King, or another piece which could take it next turn for that matter. The same goes for other pieces moving which would put the King in check. All of these possibilities need to be checked for every turn. This creates a lot of extra complexity. How I envision implementing this is this; when selecting a piece, it checks for all it's possible squares where there is a space that is not occupied by another piece of the same color. The possible_moves list is now filled with 'Pieces' which's place it could move to. For each one of these moves, a global function should be ran which runs the select function of every Piece on the board with parameter 'check=1', so that it does not select them, but only updates their possible_moves list. Then, it needs to check if there is a Piece which has the King of the moving side in their sights, and if so, the move is now illegal and removed from the possible_moves list and not highlighted. This function should therefore have the possibility to be easily used for checking for when/if the King is in check, when/if the check can be blocked (though this might prove to be a bit of a bigger challenge), and when checkmate is on the board, which is a huge benefit.

Another hurdle to overcome is checking for possible en passant, and knowing when castling is allowed.

  • For castling, I need to somehow keep track of if the King and the rook have moved or not. I am doing this with a simple boolean 'moved', which is has helped implement pawns moving up 2 squares on the first move and castling as well. I only need to check if the castling does not go through an opponent piece's vision a.k.a. castle through check, but that is discussed above and still needs work.
  • For en passant, I need to have some sort of variable keeping track if an opposite pawn has moved 2 squares up, in a file next to it, exactly passing him and landing next to it, and then allowing that specific pawn to only take said pawn diagonally (to a square where the pawn isn't even at) only for the immediate turn afterwards. If anything feels like it's getting close to having to be hardcoded, it would be this. Any suggetions on how to do this cleanly and efficiently would be appreciated.

About

My own CLI version of Chess I'm working on

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages