Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
Classes | Functions
game_coordinate.h File Reference
#include "ccfwd.h"
#include "chess_color.h"
#include <iosfwd>
#include <random>
Include dependency graph for game_coordinate.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  game_coordinate
 An exact coordinate anywhere on the board. More...
 

Functions

double calc_distance (const game_coordinate &lhs, const game_coordinate &rhs) noexcept
 Calculate the euclidean distance between two points.
 
double calc_length (const game_coordinate &coordinat) noexcept
 Calculate the length of the vector, a.k.a.
 
game_coordinate create_random_game_coordinate (std::default_random_engine &rng_engine)
 Create a random game_coordinate.
 
game_coordinate get_above (const game_coordinate &coordinat) noexcept
 Get the game coordinat one square above this one, i.e.
 
game_coordinate get_below (const game_coordinate &coordinat) noexcept
 Get the game coordinat one square below this one, i.e.
 
game_coordinate get_left (const game_coordinate &coordinat) noexcept
 Get the game coordinat one square left of this one, i.e.
 
game_coordinate get_right (const game_coordinate &coordinat) noexcept
 Get the game coordinat one square right of this one, i.e.
 
game_coordinate get_rotated_coordinat (const game_coordinate &coordinat) noexcept
 Rotate the coordinat, i.e.
 
bool is_coordinat_on_board (const game_coordinate &c) noexcept
 Determine if the coordinat is on the chess board.
 
bool is_forward (const chess_color color, const square &from, const square &to)
 Is the 'to' coordinat forward, i.e.
 
void test_game_coordinate ()
 Test this class and its free function.
 
std::string to_notation (const game_coordinate &g)
 Convert to coordinat to chess notation, e.g.
 
game_coordinate center_on_center (const game_coordinate &coordinat)
 center a coordinat on the center of a square, i.e.
 
std::string to_str (const game_coordinate &c) noexcept
 Converts the coordinate to a string.
 
std::ostream & operator<< (std::ostream &os, const game_coordinate &coordinat)
 
bool operator== (const game_coordinate &lhs, const game_coordinate &rhs) noexcept
 
bool operator!= (const game_coordinate &lhs, const game_coordinate &rhs) noexcept
 
game_coordinate operator- (const game_coordinate &lhs, const game_coordinate &rhs) noexcept
 
game_coordinate operator+ (const game_coordinate &lhs, const game_coordinate &rhs) noexcept
 
game_coordinate operator* (const game_coordinate &c, const double x) noexcept
 
game_coordinateoperator+= (game_coordinate &lhs, const game_coordinate &rhs) noexcept
 
game_coordinate operator/ (const game_coordinate &coordinat, const double factor) noexcept
 

Function Documentation

◆ calc_distance()

double calc_distance ( const game_coordinate lhs,
const game_coordinate rhs 
)
noexcept

Calculate the euclidean distance between two points.

◆ calc_length()

double calc_length ( const game_coordinate coordinat)
noexcept

Calculate the length of the vector, a.k.a.

the distance between the coordinat and the origin

◆ center_on_center()

game_coordinate center_on_center ( const game_coordinate coordinat)

center a coordinat on the center of a square, i.e.

at coorddinat (x.5, y.5)

◆ create_random_game_coordinate()

game_coordinate create_random_game_coordinate ( std::default_random_engine &  rng_engine)

Create a random game_coordinate.

◆ get_above()

game_coordinate get_above ( const game_coordinate coordinat)
noexcept

Get the game coordinat one square above this one, i.e.

when the player presses up

◆ get_below()

game_coordinate get_below ( const game_coordinate coordinat)
noexcept

Get the game coordinat one square below this one, i.e.

when the player presses down

◆ get_left()

game_coordinate get_left ( const game_coordinate coordinat)
noexcept

Get the game coordinat one square left of this one, i.e.

when the player presses left

◆ get_right()

game_coordinate get_right ( const game_coordinate coordinat)
noexcept

Get the game coordinat one square right of this one, i.e.

when the player presses right

◆ get_rotated_coordinat()

game_coordinate get_rotated_coordinat ( const game_coordinate coordinat)
noexcept

Rotate the coordinat, i.e.

turn the board 180 degrees

◆ is_coordinat_on_board()

bool is_coordinat_on_board ( const game_coordinate c)
noexcept

Determine if the coordinat is on the chess board.

Any game_coordinate that is on the board can be converted to a square.

◆ is_forward()

bool is_forward ( const chess_color  color,
const square from,
const square to 
)

Is the 'to' coordinat forward, i.e.

at a rank forward, i.e. can a pawn move/attack in that direction? Note that, e.g., for white h8 and a8 are forward of a2, i.e. the file is ignored

◆ operator!=()

bool operator!= ( const game_coordinate lhs,
const game_coordinate rhs 
)
noexcept

◆ operator*()

game_coordinate operator* ( const game_coordinate c,
const double  x 
)
noexcept

◆ operator+()

game_coordinate operator+ ( const game_coordinate lhs,
const game_coordinate rhs 
)
noexcept

◆ operator+=()

game_coordinate & operator+= ( game_coordinate lhs,
const game_coordinate rhs 
)
noexcept

◆ operator-()

game_coordinate operator- ( const game_coordinate lhs,
const game_coordinate rhs 
)
noexcept

◆ operator/()

game_coordinate operator/ ( const game_coordinate coordinat,
const double  factor 
)
noexcept

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const game_coordinate coordinat 
)

◆ operator==()

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

◆ test_game_coordinate()

void test_game_coordinate ( )

Test this class and its free function.

◆ to_notation()

std::string to_notation ( const game_coordinate g)

Convert to coordinat to chess notation, e.g.

'e2' For invalid coordinats, returns '–'

◆ to_str()

std::string to_str ( const game_coordinate c)
noexcept

Converts the coordinate to a string.

Rounds of to one decimal behind the comma.