cmpsc330hw5/harshit/custom_player.h
Sandipsinh Rathod 3ecbd34211
tmp: add harshit
2024-12-06 20:52:13 -05:00

54 lines
1.6 KiB
C++

#ifndef __CUSTOM_PLAYER__
#define __CUSTOM_PLAYER__
#include "player.h"
#include "common.h"
#include "board.h"
#include <string>
#include <vector>
class CustomPlayer : public IPlayer {
private:
Board board; // Game board to track state
char player_box; // Character representing the player's boxes
char player_line; // Character representing the player's lines
Loc* empty_lines; // Array to store available line locations
int empty_lines_count; // Number of available line locations
public:
CustomPlayer();
~CustomPlayer();
// Initializes the player with board details and player symbols
void Init(int dots_in_rows, int dots_in_cols, char player_box, char player_line) override;
// Cleans up dynamically allocated memory
void Close() override;
// Returns the player information
std::string PlayerInfo() override;
// Called when a line is added to the board
void EventAddLine(char bar, const Loc& loc) override;
// Called when a box is completed on the board
void EventAddBox(char box, const Loc& loc) override;
// Determines the next move based on the current state of the board
Loc SelectLineLocation() override;
private:
// Updates the list of available line locations
void ListEmptyLines();
// Helper function to check if a line completes a box
bool DoesLineCompleteBox(const Loc& loc);
// Helper function to avoid giving the opponent a chance to complete a box
bool WouldGiveOpponentBox(const Loc& loc);
// Evaluate the best line location strategically
Loc GetBestStrategicMove();
};
#endif