bot: added ability to skip display delay between specific generations
This commit is contained in:
parent
05f78d67fd
commit
b18ce89970
@ -30,6 +30,7 @@ namespace snakeplusplus
|
|||||||
if (isBotControlled) { while (!bot.path.empty()) { bot.path.pop(); } }
|
if (isBotControlled) { while (!bot.path.empty()) { bot.path.pop(); } }
|
||||||
PrepareGameBoard();
|
PrepareGameBoard();
|
||||||
isGameOver = false;
|
isGameOver = false;
|
||||||
|
graphics.SetShowGame((amountPlayed + 1) % 50 == 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ namespace snakeplusplus
|
|||||||
RegenerateFood();
|
RegenerateFood();
|
||||||
currentScore = player.body.size() * 100;
|
currentScore = player.body.size() * 100;
|
||||||
//bot.UpdateProbability(player.body.size());
|
//bot.UpdateProbability(player.body.size());
|
||||||
//graphics.DisplayGameState(gameBoard, currentScore);
|
graphics.DisplayGameState(gameBoard, currentScore);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ namespace snakeplusplus
|
|||||||
void PlayerOutput::DisplayGameState(std::vector< std::vector<char> >& gameBoard, int score)
|
void PlayerOutput::DisplayGameState(std::vector< std::vector<char> >& gameBoard, int score)
|
||||||
{
|
{
|
||||||
CheckWindowEvents();
|
CheckWindowEvents();
|
||||||
|
if (delay == sf::milliseconds(0)) { return; }
|
||||||
char* letterOnBoard;
|
char* letterOnBoard;
|
||||||
for (float y = 0; y < gameBoundaries.y; y++)
|
for (float y = 0; y < gameBoundaries.y; y++)
|
||||||
{
|
{
|
||||||
@ -120,6 +121,12 @@ namespace snakeplusplus
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerOutput::SetShowGame(bool isShowing) {
|
||||||
|
if (isShowing) { delay = sf::milliseconds(2); }
|
||||||
|
else { delay = sf::milliseconds(0); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerOutput::CheckWindowEvents(void)
|
void PlayerOutput::CheckWindowEvents(void)
|
||||||
{
|
{
|
||||||
while (gameWindow.pollEvent(event))
|
while (gameWindow.pollEvent(event))
|
||||||
|
@ -20,6 +20,7 @@ namespace snakeplusplus
|
|||||||
void DisplayGameState(std::vector< std::vector<char> >& gameBoard, int score);
|
void DisplayGameState(std::vector< std::vector<char> >& gameBoard, int score);
|
||||||
void DisplayScore(int score);
|
void DisplayScore(int score);
|
||||||
void StartGameWindow(void);
|
void StartGameWindow(void);
|
||||||
|
void SetShowGame(bool isShowing);
|
||||||
private:
|
private:
|
||||||
void CheckWindowEvents(void);
|
void CheckWindowEvents(void);
|
||||||
void DisplayEndScreen(void);
|
void DisplayEndScreen(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user