Compare commits
2 Commits
677466d99e
...
c6197e84dc
Author | SHA1 | Date | |
---|---|---|---|
|
c6197e84dc | ||
|
2cb54b68c4 |
@ -39,16 +39,16 @@ PlayerDirection AISnake::GetInput(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AISnake::UpdateProbability(int snakeSize) {
|
void AISnake::UpdateProbability(int snakeSize) {
|
||||||
probabilityBFS = 1 - ((double) snakeSize) / 1000;
|
thresholdDFS = 1 - ((double) snakeSize) / 1000;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AISnake::AdjustProbability(double amount) {
|
void AISnake::AdjustProbability(double amount) {
|
||||||
probabilityBFS += amount;
|
thresholdDFS += amount;
|
||||||
if (probabilityBFS > 1.0)
|
if (thresholdDFS > 1.0)
|
||||||
probabilityBFS = 1.0;
|
thresholdDFS = 1.0;
|
||||||
if (probabilityBFS < 0.0)
|
if (thresholdDFS < 0.0)
|
||||||
probabilityBFS = 0.0;
|
thresholdDFS = 0.0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ void AISnake::GetNewPath(void) {
|
|||||||
// Search for food
|
// Search for food
|
||||||
// Probability-based approach for fun
|
// Probability-based approach for fun
|
||||||
double roll = ((double) GenerateRandomNumber(RAND_MAX)) / ((double) RAND_MAX);
|
double roll = ((double) GenerateRandomNumber(RAND_MAX)) / ((double) RAND_MAX);
|
||||||
if (roll <= probabilityBFS)
|
if (roll <= thresholdDFS)
|
||||||
BFS();
|
BFS();
|
||||||
else
|
else
|
||||||
DFS();
|
DFS();
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int totalLength = 0;
|
int totalLength = 0;
|
||||||
double average = 0;
|
double average = 0;
|
||||||
double probabilityBFS = 0.200;
|
double thresholdDFS = 0.200;
|
||||||
bool pathFailed = false;
|
bool pathFailed = false;
|
||||||
|
|
||||||
// Generic search algorithms
|
// Generic search algorithms
|
||||||
|
@ -14,6 +14,8 @@ void GameEngine::Start(void) {
|
|||||||
PrepareGameBoard();
|
PrepareGameBoard();
|
||||||
if (!state.m_bNoDisplay)
|
if (!state.m_bNoDisplay)
|
||||||
graphics.StartGameWindow();
|
graphics.StartGameWindow();
|
||||||
|
if (state.m_bIsBotControlled)
|
||||||
|
graphics.SetShowGame(true);
|
||||||
Loop();
|
Loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user