![]() |
Conquer Chess
Chess and Starcraft combined
|
#include "helper.h"#include <cassert>#include <cmath>#include <fstream>#include <sstream>#include <vector>
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. | |
| std::vector< int > | make_sequence (const int from, const int to, const int increment) |
| 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. | |
| 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.
| 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.
| 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.