2023-08-19 12:56:40 -05:00
|
|
|
#ifndef BOTINTERFACE_HPP
|
|
|
|
#define BOTINTERFACE_HPP
|
|
|
|
|
|
|
|
#include "common.hpp"
|
2023-10-13 19:07:08 -05:00
|
|
|
#include <stack>
|
2023-08-19 12:56:40 -05:00
|
|
|
#include <SFML/System/Vector2.hpp>
|
|
|
|
|
2024-08-02 19:45:07 -05:00
|
|
|
class AISnake {
|
|
|
|
public:
|
|
|
|
std::stack<sf::Vector2f> path;
|
2024-08-21 02:29:50 -05:00
|
|
|
AISnake(void);
|
|
|
|
void GetNewPath(void);
|
|
|
|
PlayerDirection GetInput(void);
|
2024-08-02 19:45:07 -05:00
|
|
|
void UpdateProbability(int snakeSize);
|
|
|
|
void AdjustProbability(double amount);
|
2024-08-03 01:26:10 -05:00
|
|
|
void AddIteration(const int size);
|
|
|
|
void ResetPath(void);
|
|
|
|
int amountPlayed = 0;
|
2024-08-02 19:45:07 -05:00
|
|
|
private:
|
2024-08-03 01:26:10 -05:00
|
|
|
int totalLength = 0;
|
|
|
|
double average = 0;
|
2024-08-21 02:29:50 -05:00
|
|
|
double probabilityBFS = 0.200;
|
2024-08-03 20:42:34 -05:00
|
|
|
bool pathFailed = false;
|
2024-08-14 03:35:04 -05:00
|
|
|
|
|
|
|
// Generic search algorithms
|
2024-08-02 19:45:07 -05:00
|
|
|
std::stack<sf::Vector2f> botPathUnsanitized;
|
2024-08-21 02:29:50 -05:00
|
|
|
void BFS(void);
|
|
|
|
void DFS(void);
|
|
|
|
sf::Vector2f GetAnyOpenPath(void);
|
2024-08-03 01:26:10 -05:00
|
|
|
void UnvisitBoard(void);
|
|
|
|
void UpdateAverage(const int size);
|
|
|
|
void TrimPath(void);
|
2024-08-03 20:42:34 -05:00
|
|
|
void EmptyPath(void);
|
2024-08-14 03:35:04 -05:00
|
|
|
|
|
|
|
// Unsupervised learning
|
|
|
|
// Make decisions about current state of board
|
|
|
|
double probabilityUp = 0.25;
|
|
|
|
double probabilityDown = 0.25;
|
|
|
|
double probabilityLeft = 0.25;
|
|
|
|
double probabilityRight = 0.25;
|
|
|
|
PlayerDirection CurrentBestDecision(void);
|
|
|
|
void CheckLocalFreedom(void);
|
|
|
|
void CheckFoodDirection(void);
|
|
|
|
void RemoveImpossibleChoice(void);
|
|
|
|
|
2024-08-02 19:45:07 -05:00
|
|
|
};
|
2023-08-19 12:56:40 -05:00
|
|
|
|
|
|
|
#endif
|