Giter Club home page Giter Club logo

clchess's Introduction

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.

clchess's People

Contributors

arc891 avatar

Stargazers

 avatar Max Gallup avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.