refactor: merge final cleanups before working on AI #6
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
snakeplusplus::GameEngine game;
|
||||
GameEngine game;
|
||||
game.Start();
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user