Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
Functions
chess_move.cpp File Reference
#include "chess_move.h"
#include "game.h"
#include "fen_string.h"
#include <cassert>
#include <iostream>
#include <regex>
Include dependency graph for chess_move.cpp:

Functions

bool is_capture (const pgn_move_string &s)
 Conclude if the move is a capture from a PGN string E.g.
 
std::optional< squareget_from (const fen_string &g, const pgn_move_string &m)
 Get the square the piece doing the move came from, if any.
 
square get_from_for_bishop (const fen_string &s, const pgn_move_string &m)
 Get the square the bishop doing the move came from.
 
square get_from_for_king (const fen_string &s, const pgn_move_string &m)
 Get the square the king doing the move came from.
 
square get_from_for_knight (const fen_string &s, const pgn_move_string &m)
 Get the square the knight doing the move came from.
 
square get_from_for_pawn (const fen_string &s, const pgn_move_string &m)
 Get the square the pawn doing the move came from.
 
square get_from_for_queen (const fen_string &s, const pgn_move_string &m)
 Get the square the queen doing the move came from.
 
square get_from_for_rook (const fen_string &s, const pgn_move_string &m)
 Get the square the rook doing the move came from.
 
bool is_capture (const chess_move &move) noexcept
 Get if the move is a capture.
 
bool is_castling (const chess_move &move) noexcept
 Get if the move is a castling.
 
bool is_draw (const chess_move &move) noexcept
 Get if the move is a win.
 
bool is_promotion (const chess_move &move) noexcept
 Get if the move is a promotion.
 
bool is_simple_move (const chess_move &move) noexcept
 Get if the move is a move, i.e.
 
bool is_win (const chess_move &move) noexcept
 Get if the move is a win.
 
void test_chess_move ()
 Test this class and its free functions.
 
bool operator== (const chess_move &lhs, const chess_move &rhs) noexcept
 
std::ostream & operator<< (std::ostream &os, const chess_move &m) noexcept
 

Function Documentation

◆ get_from()

std::optional< square > get_from ( const fen_string s,
const pgn_move_string m 
)

Get the square the piece doing the move came from, if any.

Even with, e.g., castling, it is the king at e1 that needed to be selected to do that move

◆ get_from_for_bishop()

square get_from_for_bishop ( const fen_string s,
const pgn_move_string m 
)

Get the square the bishop doing the move came from.

◆ get_from_for_king()

square get_from_for_king ( const fen_string s,
const pgn_move_string m 
)

Get the square the king doing the move came from.

Even with, e.g., castling for white, it is the king at e1 that needed to be selected to do that move

◆ get_from_for_knight()

square get_from_for_knight ( const fen_string s,
const pgn_move_string m 
)

Get the square the knight doing the move came from.

◆ get_from_for_pawn()

square get_from_for_pawn ( const fen_string s,
const pgn_move_string m 
)

Get the square the pawn doing the move came from.

◆ get_from_for_queen()

square get_from_for_queen ( const fen_string s,
const pgn_move_string m 
)

Get the square the queen doing the move came from.

◆ get_from_for_rook()

square get_from_for_rook ( const fen_string s,
const pgn_move_string m 
)

Get the square the rook doing the move came from.

◆ is_capture() [1/2]

bool is_capture ( const chess_move move)
noexcept

Get if the move is a capture.

◆ is_capture() [2/2]

bool is_capture ( const pgn_move_string pgn_str)

Conclude if the move is a capture from a PGN string E.g.

'Nxc3' will result in true

◆ is_castling()

bool is_castling ( const chess_move move)
noexcept

Get if the move is a castling.

◆ is_draw()

bool is_draw ( const chess_move move)
noexcept

Get if the move is a win.

◆ is_promotion()

bool is_promotion ( const chess_move move)
noexcept

Get if the move is a promotion.

◆ is_simple_move()

bool is_simple_move ( const chess_move move)
noexcept

Get if the move is a move, i.e.

if it moves one piece, without a capture, no castling, no promotion, no win and no draw

◆ is_win()

bool is_win ( const chess_move move)
noexcept

Get if the move is a win.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const chess_move m 
)
noexcept

◆ operator==()

bool operator== ( const chess_move lhs,
const chess_move rhs 
)
noexcept

◆ test_chess_move()

void test_chess_move ( )

Test this class and its free functions.