Skip to content

olly-evans/chess-engine-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

282 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess and Engine Programming

Intro

So turns out to write a chess engine you first have to write the game of chess, I know right who would of thought. Writing chess the game so far has been much harder than I thought it would be, but has also been very rewarding. I'm particularly proud of my on_left_mouse_press() function :)

If you're asking why I didn't use a prebuilt chess GUI its because of my limited Object-Oriented programming experience. And Chess is for sure a great way to practise this with its board and piece hierarchies. But also because Dear Imgui and others in Visual Studio scares me to my core, so here I am.

For anyone cloning, I would recommend playing on the default 1280x1280 window width found in board.hpp. But it is up to you and the program will adapt dynamically.

Goals

The goal for this project is to learn more about C++, CMake and SFML. And also to become more familiar with common software design patterns.

I'll put the rest of my goals in a more formal list below, for readability:

  • Discuss methods and techniques and why I used them
  • Develop a functioning chess game with mouse movement and clicks
  • Develop a competent AI to play against
  • Develop a welcome screen to select black/white for the player and perhaps a welcome message
  • Have fun and be creative

Blog

If you'd like the full story I'd highly suggest checking out the blog for this project on my website where I have practically documented almost every step. And will continue to do so until completion.

The full blog is available here: Blog

TODO List (I'm forgetful)

  • also now need some idea of a turn/team turn, gamestate class.

  • perhaps need some sort of gamestate class that holds whos turn, and game state like checkmate stalemate etc..

  • is_white_turn in moves bit.

  • for castling, occupancy call and & all bitboards.

  • extract fen token code to functions in fenparser.

  • add global bitboard viewer to debug, overhaul piece cycle to be more dynamic. Wanna init a window and use it to print debug shit.

  • only for pawns we're resetting captures to zero at the start of the function, perhaps a future issue not sure, not sure why its working for other pieces.

  • continue with algebraic move logging.

  • perhaps is piece->bit changes we just auto calc the file/rank.

  • check bitboards are equal with temp ones we store before undoing move.

  • get_piece() probably doesnt have to use a pointer to get the piece on a certain bit we can just loop through the bitboards.

  • draw by fifty move rule, draw by threefold repitition.

  • may have to extract run logic from board. would make sense.

  • shared pointer to vector elements.

  • isolate event handling to an instantiated class.

  • then insantiate it perhaps in an app class where we have run()

  • en passant should be fairly trivial now.

-- CLEAN UP ENPASSANT LOGIC. -- HOW TO LOG ENPASSANT MOVE BLODDY HELL YMAN

-- pawn can enpassant capture in both directions when no pawn in one direction needs investigating.

About

Work in progress chess engine using C++, SFML and CMake.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors