Skip to content
Snippets Groups Projects
Commit 10929d4a authored by Salard Xavier's avatar Salard Xavier
Browse files

Debug non concluant de direction freedom heuristic

parent 33446367
No related branches found
No related tags found
No related merge requests found
ai_vs_ai=1
ai_think_time=1000
ai_think_time=5000
ai_vs_ai_game_count=100
heuristic_ai_1=left_up
heuristic_ai_1=direction_freedom
heuristic_ai_2=default
send_game_to_gui=1
......@@ -81,7 +81,7 @@ namespace game {
mcts::penguin_heuristic** h = player == 1 ? &heuristic_ai_1 : &heuristic_ai_2;
if(value == "left_up") {
*h = new mcts::go_left_up_heuristic();
}else if(value == "direction_freeddom") {
}else if(value == "direction_freedom") {
*h = new mcts::number_direction_freedom_heuristic();
}else if(value == "points") {
std::cout << "POINTS" << std::endl;
......
......@@ -30,7 +30,7 @@ std::string get_test_results_file_name()
if(gethostname(hostname,100) == 0)
{
return std::string(hostname) + ".stats";
}
}else return nullptr;
}
bool save_stats(std::string dir, int win_v1,int win_v2, int draws)
{
......
......@@ -18,7 +18,7 @@ namespace mcts
for(int i=0; i< 4; i++) {
sPos+=PENGUIN_POS(penguins[i]);
}
double res = (double) (-(-118.0 + sPos) / 118.0);
double res = (double) ((-118.0 + sPos) / 118.0);
return res;
}
......
......@@ -4,8 +4,8 @@ using namespace std;
//Count the number of direction in which a penguin can move
int8_t number_of_direction_penguin(uint32_t penguin){
int8_t res = 0 ;
uint8_t number_of_direction_penguin(uint32_t penguin){
uint8_t res = 0 ;
if(PENGUIN_MOVES_A(penguin)>0) res++;
if(PENGUIN_MOVES_B(penguin)>0) res++;
if(PENGUIN_MOVES_C(penguin)>0) res++;
......@@ -21,18 +21,15 @@ namespace mcts
{
std::shared_ptr<game::penguin> played = game::copy(game);
game::penguin_state before_state = played->get_state();
//game::penguin_state before_state = played->get_state();
played->play(move);
game::penguin_state after_state = played->get_state();
uint32_t* penguins;
printf("before : " );
if(before_state.current_player_red){ //If the player is red
/*if(before_state.current_player_red){ //If the player is red
penguins = before_state.peng_red;
printf("red ");
}else{ //if the player is blue
penguins = before_state.peng_blue;
printf("blue ");
}
//For each penguins, count the number of direction it can move
int8_t number_of_direction_before = 0;
......@@ -40,39 +37,31 @@ namespace mcts
for(int8_t i=0; i< 4; i++) {
number_of_direction_before+= number_of_direction_penguin(penguins[i]);
}
*/
printf("with %d direction \n", number_of_direction_before );
printf("after : " );
if(!after_state.current_player_red){ //If the player was red
penguins = after_state.peng_red;
printf("red ");
}else{ //if the player was blue
penguins = after_state.peng_blue;
printf("blue ");
}
int8_t number_of_direction_after = 0;
uint8_t number_of_direction_after = 0;
for(int8_t i=0; i< 4; i++) {
for(uint8_t i=0; i< 4; i++) {
number_of_direction_after+= number_of_direction_penguin(penguins[i]);
}
std::cout << "number of direction : " << "("+std::to_string(number_of_direction_after)+" : " + std::to_string((number_of_direction_after - 12.0)/24.0)+")" <<std::endl;
printf("with %d direction \n", number_of_direction_after);
printf("The difference is %d, the value is %f\n\n",(number_of_direction_after - number_of_direction_before),((number_of_direction_after - number_of_direction_before)/12.0));
// Return a float between -1.0 and 1.0 related to the change of the number of direction in which you can play before and after the move
return ((number_of_direction_after - number_of_direction_before)/12.0);
return ((number_of_direction_after - 12.0)/24.0);
//return (-(number_of_direction_after - number_of_direction_before)/12.0);
}
int number_direction_freedom_heuristic::get_count(const game::penguin& game, uint8_t move) const
{
return 10000000;
return 100000000;
}
}
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