![]() |
Conquer Chess
Chess and Starcraft combined
|
#include <algorithm>#include <cassert>#include <cmath>#include <string>#include <vector>

Go to the source code of this file.
Functions | |
| std::string | bool_to_str (const bool b) noexcept |
| Convert 'true' to 'true' and 'false' to 'false'. | |
| double | calc_angle_degrees (const double dx, const double dy) |
| Calculate the angle in degrees. | |
| double | calc_angle_radians (const double dx, const double dy) |
| Calculate the angle in radians. | |
| double | calc_distance (const double dx, const double dy) noexcept |
| Calculate the Euclidean distance between two points. | |
| template<class T > | |
| bool | is_close (const T &lhs, const T &rhs, const T &max) |
| Determine if the difference between two values is less than the maximum tolerated value. | |
| template<class T > | |
| bool | is_present_in (const T &element, const std::vector< T > &collection) |
| Determine if a value if part of a collection. | |
| std::vector< int > | make_sequence (const int from, const int to, const int increment=1) |
| Make a sequence in an inclusive way. | |
| std::vector< std::string > | read_lines (const std::string &filename) |
| Convert a file's content to a collection of strings. | |
| template<class T > | |
| void | remove_first (T &v) |
| Remove the first element from a collection. | |
| std::vector< std::string > | split_str (const std::string &s, const char seperator=' ') |
| Split a string. | |
| void | test_helper () |
| Test the help functions. | |
| std::wstring | to_wstring (const std::string s) |
| Convert a string to a wide string. | |
|
noexcept |
Convert 'true' to 'true' and 'false' to 'false'.
| double calc_angle_degrees | ( | const double | dx, |
| const double | dy | ||
| ) |
Calculate the angle in degrees.
Calculate the angle in degrees.
| dx | dy | o'clock | degrees |
|---|---|---|---|
| 1 | 0 | 3 | 0 |
| 0 | 1 | 6 | 270 |
| -1 | 0 | 9 | 180 |
| 0 | -1 | 12 | 90 |
| double calc_angle_radians | ( | const double | dx, |
| const double | dy | ||
| ) |
Calculate the angle in radians.
Calculate the angle in radians.
| dx | dy | o'clock | radians |
|---|---|---|---|
| 1 | 0 | 3 | 0.0 * pi |
| 0 | 1 | 6 | 1.5 * pi |
| -1 | 0 | 9 | 1.0 * pi |
| 0 | -1 | 12 | 0.5 * pi |
|
noexcept |
Calculate the Euclidean distance between two points.
Calculate the Euclidean distance between two points.
| bool is_close | ( | const T & | lhs, |
| const T & | rhs, | ||
| const T & | max | ||
| ) |
Determine if the difference between two values is less than the maximum tolerated value.
| bool is_present_in | ( | const T & | element, |
| const std::vector< T > & | collection | ||
| ) |
Determine if a value if part of a collection.
| std::vector< int > make_sequence | ( | const int | from, |
| const int | to, | ||
| const int | increment = 1 |
||
| ) |
Make a sequence in an inclusive way.
Make a sequence in an inclusive way: the first element will be 'from', the last element will be 'to' Assumes 'from' and 'to' are different
| std::vector< std::string > read_lines | ( | const std::string & | filename | ) |
Convert a file's content to a collection of strings.
| void remove_first | ( | T & | v | ) |
Remove the first element from a collection.
Remove the first element from a collection.
| std::vector< std::string > split_str | ( | const std::string & | s, |
| const char | seperator = ' ' |
||
| ) |
Split a string.
| void test_helper | ( | ) |
Test the help functions.
Test the help functions.
| std::wstring to_wstring | ( | const std::string | s | ) |
Convert a string to a wide string.