Created
November 28, 2012 07:52
-
-
Save Hydrotoast/4159725 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef BOARD_CONFIG_H | |
#define BOARD_CONFIG_H | |
class BoardConfig { | |
public: | |
unsigned int rows; | |
unsigned int cols; | |
unsigned int kLength; | |
bool gravityFlag; | |
}; | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef BOARD_STATE_H | |
#define BOARD_STATE_H | |
#include "BoardConfig.h" | |
#include "Cell.h" | |
#include <list> | |
#define BLANK ' ' | |
#define X 'X' | |
#define O 'O' | |
#define WIN_X 1000000 | |
#define WIN_O -1000000 | |
#define MAX_HEURISTIC 1000000 | |
#define MIN_HEURISTIC -1000000 | |
class BoardState { | |
public: | |
BoardState(BoardConfig config); | |
~BoardState(); | |
BoardState(const BoardState& state); | |
BoardState& operator=(const BoardState& state); | |
BoardState clone(); | |
bool hasGravity() const; | |
bool isOccupied(size_t row, size_t col); | |
bool inRange(size_t row, size_t col); | |
bool isMarkGood(char mark); | |
char at(size_t row, size_t col); | |
bool occupy(size_t row, size_t col, char mark); | |
unsigned int evaluate(); | |
bool tie(); | |
bool win(char &mark); | |
std::list<Cell> getAvailable(const char** board); | |
private: | |
int numMoves; | |
bool playersMove; | |
long humanSeconds; | |
long computerSeconds; | |
unsigned int M; | |
unsigned int N; | |
unsigned int K; | |
bool gravityFlag; | |
int depthLevel; | |
char computerMark; // mark played by AI player for board evaluation | |
char** board; // board is index by [row][column] | |
int numOccupied; | |
}; | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CK_PLAYER_H | |
#define CK_PLAYER_H | |
#include "BoardState.h" | |
#include <string> | |
#define PLAYER_1 1 | |
#define PLAYER_2 2 | |
struct Point { | |
unsigned int row; | |
unsigned int col; | |
}; | |
class CKPlayer { | |
public: | |
CKPlayer(BoardState board, int player); | |
virtual Point getMove(BoardState board, int deadline = 0) = 0; | |
std::string toString(); | |
private: | |
BoardState board; | |
std::string teamName; | |
int player; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment