diff options
author | zedarider <ymherklotz@gmail.com> | 2016-11-10 18:19:22 +0000 |
---|---|---|
committer | zedarider <ymherklotz@gmail.com> | 2016-11-10 18:19:22 +0000 |
commit | 95f75aa7aacf5e0e1ef11e8d200f84de44bd891f (patch) | |
tree | 5ffafeb62866e121453b82e11e402a27a6a30256 /include | |
parent | 375e4b989af8b4ac2c3479ea32f9324f29ce9071 (diff) | |
download | ChessAI-95f75aa7aacf5e0e1ef11e8d200f84de44bd891f.tar.gz ChessAI-95f75aa7aacf5e0e1ef11e8d200f84de44bd891f.zip |
finished the tester
Diffstat (limited to 'include')
-rw-r--r-- | include/chess_ai.hpp | 13 | ||||
-rw-r--r-- | include/chess_tester.hpp | 89 |
2 files changed, 99 insertions, 3 deletions
diff --git a/include/chess_ai.hpp b/include/chess_ai.hpp index 380d406..fc05b2a 100644 --- a/include/chess_ai.hpp +++ b/include/chess_ai.hpp @@ -112,6 +112,9 @@ namespace chess_ai { // Create a chess board depending on the state chess_board(board_state state); + + // destructor to clean up the variables + ~chess_board(); // prints the current board state void print_board(); @@ -132,6 +135,9 @@ namespace chess_ai { // move piece using only x and y (for pawns) move_error move_piece(unsigned x, unsigned y); + // moves a piece to an x, y coordinate + move_error move_piece(chess_piece piece, unsigned x, unsigned y); + // move piece with x and y as original and final destination move_error move_piece(unsigned orig_x, unsigned orig_y, unsigned dest_x, unsigned dest_y); @@ -140,8 +146,6 @@ namespace chess_ai { move_error move_piece(unsigned orig_x, unsigned orig_y, unsigned dest_x, unsigned dest_y, chess_piece& taken_piece); - - move_error move_piece(chess_piece piece, unsigned x, unsigned y); // iterate through the list and return the pointer to change square_iterator& iterate_board(square_iterator& it, unsigned x, @@ -153,7 +157,7 @@ namespace chess_ai { // initialises vector void init_board_vector(); - // moves the pawn + // moves the pawn and tests all the cases that it should. move_error move_pawn(square_iterator it, square_iterator new_it, chess_piece& taken_piece); @@ -180,6 +184,9 @@ namespace chess_ai { chess_piece(piece_type type, piece_colour colour, unsigned x, unsigned y); + // destructor to clean up the variables + ~chess_piece(); + // Set the type of the chess_piece void set_type(piece_type type); diff --git a/include/chess_tester.hpp b/include/chess_tester.hpp new file mode 100644 index 0000000..c0c2f1c --- /dev/null +++ b/include/chess_tester.hpp @@ -0,0 +1,89 @@ +#ifndef CHESS_TESTER_HPP +#define CHESS_TESTER_HPP + +#define CHESS_TEST_SIZE 7 + +#include <string> +#include <vector> +#include <cstdio> +#include <cstdlib> +#include <ctime> +#include <algorithm> +#include <iostream> + +struct tested_pieces { + std::string piece_name; + int num_passed; + int num_failed; + + friend bool operator==(const tested_pieces& tp1, const tested_pieces& tp2) { + if(tp1.piece_name == tp2.piece_name) { + return true; + } + return false; + } + + friend bool operator<(const tested_pieces& tp1, const tested_pieces& tp2) { + if(tp1.piece_name < tp2.piece_name) { + return true; + } + return false; + } +}; + +class chess_tester { + +public: + + // sets all the initial values for the tester + chess_tester(); + + // begins the test suite so that this class can record the results and + // analyse them + void chess_begin_test_suite(); + + // begins the test + int chess_begin_test(std::string test_name); + + // records the result of the test + void chess_end_test(int test_id, bool passed); + + // analyses the results and prints them out + void chess_end_test_suite(); + + // see if the test is acceptable + bool is_in_arr(const std::string& test_piece) const; + + // see if test is in vector + bool is_in_vec(const tested_pieces& piece) const; + +private: + + // checks if the test suite is running + bool ts_begin; + + // list of pieces to test + const std::string chess_test_pieces[CHESS_TEST_SIZE] = { + "<INTERNAL>", + "PAWN", + "ROOK", + "KNIGHT", + "BISHOP", + "QUEEN", + "KING" + }; + + // vector that contains the tested pieces + std::vector<tested_pieces> test_piece; + + // the test_id of the current instruction + int test_id; + + // the test id of the test that has been started + int test_id_test; + + // the current test that is being tested + std::string current_test; +}; + +#endif |