refactor: merge final cleanups before working on AI #6

Merged
Trianta merged 12 commits from refactor into master 2024-08-10 15:05:56 -05:00
11 changed files with 601 additions and 630 deletions
Showing only changes of commit 0ff3ef3f62 - Show all commits

View File

@ -7,8 +7,6 @@
#include <stdexcept>
#include <SFML/System/Vector2.hpp>
namespace snakeplusplus
{
PlayerDirection lastKnownDirection = kNone;
AISnake::AISnake() {
@ -175,4 +173,3 @@ namespace snakeplusplus
visited.at(currentLocation.y).at(currentLocation.x) = true;
}
}
}

View File

@ -6,8 +6,6 @@
#include <vector>
#include <SFML/System/Vector2.hpp>
namespace snakeplusplus
{
class AISnake {
public:
std::stack<sf::Vector2f> path;
@ -22,6 +20,5 @@ namespace snakeplusplus
void BFS(const std::vector< std::vector<char> >& gameBoard, const sf::Vector2f& source, const sf::Vector2f& boundaries);
void DFS(const std::vector< std::vector<char> >& gameBoard, const sf::Vector2f& source, const sf::Vector2f& boundaries);
};
}
#endif

View File

@ -2,8 +2,6 @@
#include <random>
#include "common.hpp"
namespace snakeplusplus
{
std::default_random_engine generator;
void InitializeGenerator(void)
{
@ -15,7 +13,6 @@ namespace snakeplusplus
{
int generatedNumber;
std::uniform_int_distribution<> distribution(0, generationLimit - 1);
generatedNumber = distribution(snakeplusplus::generator);
generatedNumber = distribution(generator);
return generatedNumber;
}
}

View File

@ -1,8 +1,6 @@
#ifndef COMMON_HPP
#define COMMON_HPP
namespace snakeplusplus
{
void InitializeGenerator(void);
int GenerateRandomNumber(int generationLimit);
@ -15,6 +13,4 @@ namespace snakeplusplus
kRight = 4
};
}
#endif

View File

@ -7,8 +7,6 @@
#include "playerinterface.hpp"
#include "gamestate.hpp"
namespace snakeplusplus
{
GameEngine::GameEngine()
{
InitializeGenerator();
@ -163,9 +161,9 @@ namespace snakeplusplus
}
return;
}
void GameEngine::UpdateAverage() {
totalLength += player.body.size();
amountPlayed += 1;
average = (double)totalLength / amountPlayed;
}
}

View File

@ -3,12 +3,11 @@
#define GAMESTATE_HPP
#include <SFML/Graphics.hpp>
#include <memory>
#include "botinterface.hpp"
#include "snake.hpp"
#include "playerinterface.hpp"
namespace snakeplusplus
{
const int kUnitSpeed = 1;
class GameEngine
@ -39,6 +38,5 @@ namespace snakeplusplus
int amountPlayed = 0;
double average = 0;
};
}
#endif

View File

@ -2,7 +2,7 @@
int main(void)
{
snakeplusplus::GameEngine game;
GameEngine game;
game.Start();
return 0;
}

View File

@ -2,8 +2,6 @@
#include <SFML/System/Vector2.hpp>
#include <SFML/Window/Keyboard.hpp>
namespace snakeplusplus
{
PlayerDirection GetPlayerInput(void)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)
@ -171,4 +169,3 @@ namespace snakeplusplus
gameWindow.draw(drawObject);
return;
}
}

View File

@ -6,8 +6,6 @@
const int kGridSize = 25;
namespace snakeplusplus
{
PlayerDirection GetPlayerInput(void);
class PlayerOutput
@ -34,6 +32,5 @@ namespace snakeplusplus
bool isWindowAlive;
sf::Time delay = sf::milliseconds(1);
};
}
#endif

View File

@ -4,8 +4,6 @@
#include "common.hpp"
#include "snake.hpp"
namespace snakeplusplus
{
void Snake::Pop(void)
{
*(body.front()) = ' ';
@ -28,4 +26,3 @@ namespace snakeplusplus
location.y = GenerateRandomNumber(boundaries.y);
return;
}
}

View File

@ -5,8 +5,6 @@
#include <SFML/System/Vector2.hpp>
#include <queue>
namespace snakeplusplus
{
struct Snake
{
public:
@ -24,6 +22,5 @@ namespace snakeplusplus
char* food;
void GenerateNewFood(sf::Vector2f boundaries);
};
}
#endif