DEV Community

Tensie
Tensie

Posted on

Chess Engine

So yesterday i started working on my chess engine, written in c++,i'm writing these blogs and a couple more i'll write in the future for quite a selfish reason (to track my progress) and also because i want someone else, confused like me in the future to use this, hopefully, as a road map to write their engine.

right so i started yesterday, i started with well board representation, I'm a programmer not a writer so please forgive my fuck ups here and there, some times i won't make sense but lie to yourself and pretend you do understand what i'm on.

I chose the most intuitive approach, the 8x8 array representation.
i basically made an enum, something like this
`
enum {empty, whitepawn, whiteknight..., blackking};

`
from there i basically hard-coded each each in the 8x8 array.

and then proceeded to have print function, which prints the pieces on the console, it maps a string i hard-coded to the enum values.

something like

1.pieces = " PNBRQKpnbrqk"

  1. loop through array[8x8]
  2. check if array[i][j]!=empty if yes print " . " if no print pieces[array[i][j]]

about this pieces[array[i][j]]

it works only because the string indices and the enum piece value match, hopefully that makes sense

right now i just implemented a simple no rule move function
it receive from coordinates and to coordinates
manipulates the array by making from coordinate empty and to coordinate with the previous from coordinate, the re-prints
the board.

this is my repo to keep up if you like
https://github.com/PainIam/Pain_ENGINE

Top comments (0)