Skip to content
Snippets Groups Projects
Forked from Bariatti Francesco / pingouins
34 commits ahead of the upstream repository.
movement_freedom_heuristic.cpp 1.88 KiB
#include <iostream>

#include "penguin_heuristic.hpp"
#include "movement_freedom_heuristic.hpp"
#include "penguin.hpp"

#define MAX_NB_MOVES	60.0f

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 (MARCHE ?)
	/*
    	played->play(move);
	game::penguin_state state = played->get_state();

	uint32_t* penguins_r = state.peng_red;
	uint32_t* penguins_b = state.peng_blue;
	float nb_moves_r = 0;
	float nb_moves_b = 0;

	for(int i=0; i< 4; i++) {
		nb_moves_r += PENGUIN_TOT_MOVES(penguins_r[i]);
		nb_moves_b += PENGUIN_TOT_MOVES(penguins_b[i]);
	}

	float res = -(nb_moves_r - nb_moves_b)/MAX_NB_MOVES;
	return res;
	*/

	//TEST SOLUTION 2 (MARCHE ?)
	/*
	game::penguin_state state = played->get_state();
	uint32_t* penguins = state.peng_red;
	float nb_moves_before = 0;
	for(int i=0; i< 4; i++) {
		nb_moves_before += PENGUIN_TOT_MOVES(penguins[i]);
	}

    	played->play(move);

	state = played->get_state();
	penguins = state.peng_red;
	float nb_moves = 0;
	for(int i=0; i< 4; i++) {
		nb_moves += PENGUIN_TOT_MOVES(penguins[i]);
	}

	float res = -(nb_moves - nb_moves_before)/MAX_NB_MOVES;
	return res;
	*/


	//TEST SOLUTION 3 (MARCHE PAS, DONNE NB MOVES DU BLEU)
	/*
    	played->play(move);
	float nb_moves = (float)played->number_of_moves();

	float res = 2.0f*nb_moves / MAX_NB_MOVES - 1.0f;
	return res;
	*/


	//TEST SOLUTION 4 (MARCHE PAS)
	/*
    	played->play(move);
	game::penguin_state state = played->get_state();
	uint32_t* penguins = state.peng_red;
	float nb_moves = 0;
	for(int i=0; i< 4; i++) {
		nb_moves += PENGUIN_TOT_MOVES(penguins[i]);
	}

	float res = 2.0f*nb_moves / MAX_NB_MOVES - 1.0f;
	return res;
	*/
  }

  int movement_freedom_heuristic::get_count(const game::penguin& game, uint8_t move) const
  {
    return 100000000;
  }
}