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

merge

parents 9a966442 34412ade
No related branches found
No related tags found
No related merge requests found
ai_vs_ai=1
ai_think_time=3000
ai_think_time=5000
ai_vs_ai_game_count=100
heuristic_ai_1=points
heuristic_ai_1=movement_freedom
heuristic_ai_2=default
send_game_to_gui=1
......@@ -2,6 +2,8 @@
#include <iostream>
#include <fstream>
#include <algorithm>
#include "movement_freedom_heuristic.hpp"
#include "points_heuristic.hpp"
namespace game {
......@@ -81,6 +83,8 @@ namespace game {
if(value == "points") {
std::cout << "POINTS" << std::endl;
*h = new mcts::points_heuristic();
if(value == "movement_freedom") {
*h = new mcts::movement_freedom_heuristic();
}
if(value == "default") {
......
#include <iostream>
#include "penguin_heuristic.hpp"
#include "movement_freedom_heuristic.hpp"
#include "penguin.hpp"
#define MAX_NB_MOVES 60
using namespace std;
namespace mcts
{
float movement_freedom_heuristic::get_value(const game::penguin& game, uint8_t move) const
{
std::shared_ptr<game::penguin> played = game::copy(game);
//TEST SOLUTION 1
played->play(move);
game::penguin_state state = played->get_state();
uint32_t* penguins = state.peng_blue;
if(!state.current_player_red) {
penguins = state.peng_red;
}
uint32_t nb_moves = 0;
for(int i=0; i< 4; i++) {
nb_moves += PENGUIN_TOT_MOVES(penguins[i]);
}
float res = 2.0f*(float)nb_moves / (float)MAX_NB_MOVES - 1.0f;
return res;
//TEST SOLUTION 2
/*
played->play(move);
uint32_t nb_moves = played->number_of_moves();
float res = 2.0f*(float)nb_moves / (float)MAX_NB_MOVES - 1.0f;
return res;
*/
//TEST SOLUTION 3
/*
played->play(move);
game::penguin_state state = played->get_state();
uint32_t nb_moves = state.nb_moves_blue;
if(!state.current_player_red) {
nb_moves = state.nb_moves_red;
}
float res = 2.0f*(float)nb_moves / (float)MAX_NB_MOVES - 1.0f;
return res;
*/
}
int movement_freedom_heuristic::get_count(const game::penguin& game, uint8_t move) const
{
return 100000000;
}
}
#ifndef __MOVEMENT_FREEDOM_HEURISTIC_HPP__
#define __MOVEMENT_FREEDOM_HEURISTIC_HPP__
#include "penguin.hpp"
#include "penguin_heuristic.hpp"
namespace mcts
{
class movement_freedom_heuristic : public penguin_heuristic
{
public:
float get_value(const game::penguin& game, uint8_t move) const;
int get_count(const game::penguin& game, uint8_t move) const;
};
};
#endif
......@@ -35,7 +35,8 @@ 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 points_heuristic.cpp main.cpp config.cpp
test_mcts_two_players.cpp bits.cpp test_bits.cpp penguin_heuristic.cpp main.cpp config.cpp movement_freedom_heuristic.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