Added scoring and chance-based algorithm picking #3

Merged
Trianta merged 3 commits from dev into master 2023-10-24 00:55:31 -05:00
Showing only changes of commit 014aaffc0a - Show all commits

View File

@ -41,10 +41,11 @@ namespace snakeplusplus
void AISnake::GetNewPath(const std::vector< std::vector<char> >& gameBoard, const sf::Vector2f& source, const sf::Vector2f& boundaries, const int snakeSize)
{
// Search for food
if (snakeSize < 135) {
BFS(gameBoard, source, boundaries);
} else {
BFS(gameBoard, source, boundaries);
if (gameBoard[botPathUnsanitized.top().y][botPathUnsanitized.top().x] != 'X') {
while (!botPathUnsanitized.empty()) { botPathUnsanitized.pop(); }
DFS(gameBoard, source, boundaries);
while (botPathUnsanitized.size() > 15) { botPathUnsanitized.pop(); }
}
// Create path for food
path.push(botPathUnsanitized.top());