Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
game_coordinate.h
Go to the documentation of this file.
1#ifndef GAME_COORDINATE_H
2#define GAME_COORDINATE_H
3
4#include "ccfwd.h"
5#include "chess_color.h"
6
7#include <iosfwd>
8#include <random>
9
32{
33public:
34 explicit game_coordinate(const double x = 0, const double y = 0);
35
36 double get_x() const noexcept { return m_x; }
37 double get_y() const noexcept { return m_y; }
38
39private:
40
41 double m_x;
42 double m_y;
43};
44
46double calc_distance(const game_coordinate& lhs, const game_coordinate& rhs) noexcept;
47
50double calc_length(const game_coordinate& coordinat) noexcept;
51
54 std::default_random_engine& rng_engine
55);
56
59game_coordinate get_above(const game_coordinate& coordinat) noexcept;
60
63game_coordinate get_below(const game_coordinate& coordinat) noexcept;
64
67game_coordinate get_left(const game_coordinate& coordinat) noexcept;
68
71game_coordinate get_right(const game_coordinate& coordinat) noexcept;
72
76
80bool is_coordinat_on_board(const game_coordinate& c) noexcept;
81
87bool is_forward(
88 const chess_color color,
89 const square& from,
90 const square& to
91);
92
95
98std::string to_notation(const game_coordinate& g);
99
103
107std::string to_str(const game_coordinate& c) noexcept;
108
109std::ostream& operator<<(std::ostream& os, const game_coordinate& coordinat);
110
111bool operator==(const game_coordinate& lhs, const game_coordinate& rhs) noexcept;
112bool operator!=(const game_coordinate& lhs, const game_coordinate& rhs) noexcept;
115game_coordinate operator*(const game_coordinate& c, const double x) noexcept;
117game_coordinate operator/(const game_coordinate& coordinat, const double factor) noexcept;
118
119#endif // GAME_COORDINATE_H
chess_color
A chess piece color.
Definition chess_color.h:10
An exact coordinate anywhere on the board.
Definition game_coordinate.h:32
double get_x() const noexcept
Definition game_coordinate.h:36
double get_y() const noexcept
Definition game_coordinate.h:37
A chess square.
Definition square.h:58
game_coordinate create_random_game_coordinate(std::default_random_engine &rng_engine)
Create a random game_coordinate.
Definition game_coordinate.cpp:44
game_coordinate center_on_center(const game_coordinate &coordinat)
center a coordinat on the center of a square, i.e.
Definition game_coordinate.cpp:36
game_coordinate & operator+=(game_coordinate &lhs, const game_coordinate &rhs) noexcept
Definition game_coordinate.cpp:351
game_coordinate get_left(const game_coordinate &coordinat) noexcept
Get the game coordinat one square left of this one, i.e.
Definition game_coordinate.cpp:71
std::string to_notation(const game_coordinate &g)
Convert to coordinat to chess notation, e.g.
Definition game_coordinate.cpp:289
bool operator!=(const game_coordinate &lhs, const game_coordinate &rhs) noexcept
Definition game_coordinate.cpp:324
game_coordinate operator+(const game_coordinate &lhs, const game_coordinate &rhs) noexcept
Definition game_coordinate.cpp:343
std::ostream & operator<<(std::ostream &os, const game_coordinate &coordinat)
Definition game_coordinate.cpp:329
double calc_distance(const game_coordinate &lhs, const game_coordinate &rhs) noexcept
Calculate the euclidean distance between two points.
Definition game_coordinate.cpp:21
game_coordinate operator-(const game_coordinate &lhs, const game_coordinate &rhs) noexcept
Definition game_coordinate.cpp:335
game_coordinate get_below(const game_coordinate &coordinat) noexcept
Get the game coordinat one square below this one, i.e.
Definition game_coordinate.cpp:61
game_coordinate operator/(const game_coordinate &coordinat, const double factor) noexcept
Definition game_coordinate.cpp:357
bool operator==(const game_coordinate &lhs, const game_coordinate &rhs) noexcept
Definition game_coordinate.cpp:317
game_coordinate operator*(const game_coordinate &c, const double x) noexcept
Definition game_coordinate.cpp:366
game_coordinate get_above(const game_coordinate &coordinat) noexcept
Get the game coordinat one square above this one, i.e.
Definition game_coordinate.cpp:51
void test_game_coordinate()
Test this class and its free function.
Definition game_coordinate.cpp:121
double calc_length(const game_coordinate &coordinat) noexcept
Calculate the length of the vector, a.k.a.
Definition game_coordinate.cpp:28
bool is_coordinat_on_board(const game_coordinate &c) noexcept
Determine if the coordinat is on the chess board.
Definition game_coordinate.cpp:99
std::string to_str(const game_coordinate &c) noexcept
Converts the coordinate to a string.
Definition game_coordinate.cpp:302
bool is_forward(const chess_color color, const square &from, const square &to)
Is the 'to' coordinat forward, i.e.
Definition game_coordinate.cpp:109
game_coordinate get_rotated_coordinat(const game_coordinate &coordinat) noexcept
Rotate the coordinat, i.e.
Definition game_coordinate.cpp:91
game_coordinate get_right(const game_coordinate &coordinat) noexcept
Get the game coordinat one square right of this one, i.e.
Definition game_coordinate.cpp:81