I am doing a Poker Engine so that different PokerPlayer agents can play against each other in tournament simulations. Once my project is done, I would like people to submit their own agents in a PR. In order to do so, they would only have to derive the PokerPlayer class with their MyPokerPlayer class and override the play() method. But I want to make sure that their agents don't cheat. I don't want them to be able to change the money that they have, nor do I want them to be able to change the cards that they have been given at the beginning of the game.
The problem is that the Game class needs to be able to take a PokerPlayer's money when they bet (or give them the pot when they win) and needs to be able to set the PokerPlayer's card at the beginning of the Game. So PokerPlayer's derived classes cannot directly update their own money and cards but the external class Game can.
PokerPlayer.h (This is the class that sould be derived by agents)
class PokerPlayer
{
private:
bool alive = true;
QList<Card> cards;
int money;
public:
PokerPlayer();
int getMoney() const;
bool isAlive() const;
virtual Action* play() = 0;
};
Game.cpp (where I assign the Players their cards, take their bets, etc...)
...
void Game::assignCardsToEveryPlayer() {
foreach (PokerPlayer* player, this->getPlayers()) {
QSet<Card> cards = PokerGameManager::generateUniqueCards(2);
player->setCards(cards.toList());
}
}
...
What I do not want: MYPokerPlayer.cpp (An Agent)
Action* MYPokerPlayer::play() override {
this->setMoney(1000000);
this->setCards(ACE, ACE);
// you get the idea...
}
How could I achieve this?
Thank you for your time,