Code Monkey home page Code Monkey logo

chessplusplus's Introduction

ChessPlusPlus

Chess in C++

Introduction

ChessPlusPlus is a side project inspired by The Queen's Gambit on Netflix. I saw the game of chess as an opportunity to perhaps apply a binary search tree to analyze the tree of moves at any given board arrangement. In addition, I wanted to gain a better understanding of C++ topics like raw memory access, namespaces, etc. The best way to learn is to do so I did. I hope this project encourages you to actually go out and try something new that you learned.

In Development

Currently, I'm working on ironing out the bugs in the piece movement. The main method is setup to run a simple simulated chess game move by move. Most of the pieces are working as expected and the simulation will go pretty far until it crashes.

The good news is that the move grading system, capture system, and inCheck systems are working. You can see them in action during the simulation.

Progress

So far, I have created the game of chess in a way that was intuitive to me but also in ways that favor a specific area that I wanted to gain experience with.

Once the pieces will all move as expected, I can then try to enhance the move selection.

A milestone that preceds the one in the following paragraph is analyzing if the king is in check. You do that by looping through your opponent's possible moves and see if any of them would capture the king. This milestone is completed which opens the door to many other possibilities.

One of the milestones is to be able to simulate how a move is going to play out before actually selecting it. From my research and math alone, there are too many possibilities to simulate than there is time and resources. But simulating a few moves ahead would be cool.

The Board and Pieces

When I was first conceptualizing this project, I knew I was going to have to create a board of pieces. I decided that I wanted the board to be a 2d vector so that I could easily iterate spaces with for loops. But vectors of what data type?

The traditional OOP approach would be to create a Piece class with subclasses for each type of piece, King, Rook, Pawn, etc... I knew that the differentiating factor between the types of pieces was going to be how each type can move. You could construct the pieces this way but then you can't use vectors because the data needs to all be the same type. Plus, I wanted to try namespaces out. So instead, I created a piece class with a switch case that calls the correct functionality for the given piece type. Essentially, a namespace of functions for each piece type.

Going back to the board, the type is vector<vector<Piece*>>. The board is a 2d vector of Piece object pointers.

chessplusplus's People

Contributors

jocon15 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.