Skip to content
Snippets Groups Projects
Commit c7e1656e authored by Felton Samuel's avatar Felton Samuel
Browse files

Modified the heuristics call and methods to take into account the move to be played

parent 8dd48905
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,4 @@ ai_think_time=1000
ai_vs_ai_game_count=1
heuristic_ai_1=left_up
heuristic_ai_2=default
send_game_to_gui=0
send_game_to_gui=1
......@@ -25,7 +25,6 @@
#include "learning.hpp"
#include "penguin_heuristic.hpp"
#include "config.hpp"
#include "test_penguin_game.hpp"
#include <omp.h>
using namespace std;
......
......@@ -7,8 +7,8 @@ namespace mcts
class heuristic
{
public:
virtual float get_value(const Game& game) const = 0;
virtual int get_count(const Game& game) const = 0;
virtual float get_value(const Game& game, uint8_t move) const = 0;
virtual int get_count(const Game& game, uint8_t move) const = 0;
virtual ~heuristic(){};
};
......@@ -17,11 +17,11 @@ namespace mcts
class zero_knowledge : public heuristic<Game>
{
public:
float get_value(const Game& game) const
float get_value(const Game& game, uint8_t move) const
{
return 0.f;
}
int get_count(const Game& game) const
int get_count(const Game& game, uint8_t move) const
{
return 1;
}
......
......@@ -130,8 +130,8 @@ void mcts_two_players<Game>::expand(const std::shared_ptr<Game>& game, node* n)
for (unsigned int i = 0; i < nb_children; ++i)
{
node* child = children + i;
child->get_statistics_ref().count = heuristic_.get_count(*game);
child->get_statistics_ref().value = heuristic_.get_value(*game);
child->get_statistics_ref().count = heuristic_.get_count(*game, i);
child->get_statistics_ref().value = heuristic_.get_value(*game, i);
}
n->set_children(children);
n->set_number_of_children(nb_children);
......
......@@ -4,23 +4,26 @@ using namespace std;
namespace mcts
{
float penguin_heuristic::get_value(const game::penguin& game) const
float penguin_heuristic::get_value(const game::penguin& game, uint8_t move) const
{
return 0.f;
}
int penguin_heuristic::get_count(const game::penguin& game) const
int penguin_heuristic::get_count(const game::penguin& game, uint8_t move) const
{
return 1;
}
float go_left_up_heuristic::get_value(const game::penguin& game) const
float go_left_up_heuristic::get_value(const game::penguin& game, uint8_t move) const
{
std::shared_ptr<game::penguin> played = game::copy(game);
played->play(move);
return 0.f;
}
int go_left_up_heuristic::get_count(const game::penguin& game) const
int go_left_up_heuristic::get_count(const game::penguin& game, uint8_t move) const
{
return 1;
}
......
......@@ -9,14 +9,14 @@ namespace mcts
class penguin_heuristic : public heuristic<game::penguin>
{
public:
virtual float get_value(const game::penguin& game) const;
virtual int get_count(const game::penguin& game) const;
virtual float get_value(const game::penguin& game, uint8_t move) const;
virtual int get_count(const game::penguin& game, uint8_t move) const;
};
class go_left_up_heuristic : public penguin_heuristic
{
public:
float get_value(const game::penguin& game) const;
int get_count(const game::penguin& game) const;
float get_value(const game::penguin& game, uint8_t move) const;
int get_count(const game::penguin& game, uint8_t move) const;
};
};
......
......@@ -35,7 +35,7 @@ AIInclude=-I $(AISRC)/game -I $(AISRC)/util -I $(AISRC)/monte_carlo -I $(AISRC)/
# Cpp source files
AISourceFile = omp_util.cpp fast_log.cpp display_node.cpp penguin.cpp test_two_players_game.cpp monte_carlo.cpp \
test_fast_log.cpp statistics.cpp node.cpp allocator.cpp test_allocator.cpp openings.cpp mcts_two_players.cpp \
test_mcts_two_players.cpp bits.cpp test_bits.cpp penguin_heuristic.cpp main.cpp config.cpp test_penguin_game.cpp
test_mcts_two_players.cpp bits.cpp test_bits.cpp penguin_heuristic.cpp main.cpp config.cpp
# Directories in which make will search for files
vpath %.cpp $(AISRC)/game $(AISRC)/main $(AISRC)/util $(AISRC)/monte_carlo $(AISRC)/mcts $(AISRC)/gdl
# Flags passed to the compiler
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment