Skip to content
Snippets Groups Projects
penguin.cpp 3.29 KiB
Newer Older
Gaste Adrien's avatar
Gaste Adrien committed
#include "penguin.hpp"
#include <sstream>

using namespace std;

namespace game
{
	penguin::penguin()
	{
	}

	shared_ptr<game<penguin_state>> penguin::do_copy() const
	{
		return shared_ptr<penguin>(new penguin(*this));
	}

	penguin_state penguin::get_state()
	{
		return state;
	}
	
	void penguin::set_state(const penguin_state& s)
	{
		state = s; 
	}

	bool penguin::end_of_game() const
	{
		return false;
		//return state.first_player_win || state.second_player_win || state.total_moves == 9;
	}

	bool penguin::won(std::uint8_t player) const
	{
		return false;
		//if (player == CROSS) return state.first_player_win;
		//return state.second_player_win;
	}
	
	bool penguin::lost(std::uint8_t player) const
	{
		return false;
		/*if (player == CIRCLE) return state.first_player_win;
		return state.second_player_win;*/
	}

	bool penguin::draw(std::uint8_t player) const
	{
		return false;
		/*if (state.first_player_win || state.second_player_win) return false;
		return state.total_moves == 9;*/
	}

	uint8_t penguin::current_player() const
	{
		return 0;
		/*return state.total_moves & 1 ? CIRCLE : CROSS; // CROSS even, CIRCLE odd*/
	} 

	int penguin::value(uint8_t player) const
	{
		/*if (player == CROSS) {
			return state.first_player_win ? 1 : (state.second_player_win ? -1 : 0);
		}
		else if (player == CIRCLE) {
			return state.second_player_win ? 1 : (state.first_player_win ? -1 : 0);
		}
		return 0;*/
		return 0;
	}

	/* Number of moves that you can play */
	uint16_t penguin::number_of_moves() const
	{
		//return 9 - state.total_moves;
		return 0;
	}
	
	//Play the mth move in the possible moves list.
	void penguin::play(uint16_t m)
	{   
		/*uint64_t possible_moves = state.possible_moves;
		possible_moves = possible_moves >> 4*m; //A move is coded with 4 bit
		uint16_t move = possible_moves & 15; //15 = 1111
		//cout << "You choose the possible move number " << m << endl;
		//cout << "You choose move " << move << endl;
		if (current_player() == CROSS)
			state.cross_bitboard |= (((uint16_t) 1) << move);
		else
			state.circle_bitboard |= (((uint16_t) 1) << move);
		
		//State update
		state.total_moves++;
		update_win();
		update_moves();
		return;*/
	}
	
	string penguin::player_to_string(uint8_t player) const
	{
		//return player == CROSS ? "X" : (player == CIRCLE ? "O" : " ");
		return "TODO";
	}
	
	
	string penguin::move_to_string(uint16_t m) const
	{
		//return std::to_string((state.possible_moves >> (4 * m)) & 0xf);
		return "TODO";
	}

	set<int> penguin::to_input_vector() const
	{
		return set<int>();
	}

	void penguin::from_input_vector(const std::set<int>& input)
	{
	}

	string penguin::to_string() const
	{
		/*string result = "-------\n";
		for (int row = 2; row >= 0; row--)
		{
			result += "|";
			for (int col = 2; col >= 0; col--)
			{
				if(((state.cross_bitboard >> (3*row)) >> col) & 1)
					result += player_to_string(CROSS)+"|";
				else if (((state.circle_bitboard >> (3*row)) >> col) & 1)
					result += player_to_string(CIRCLE)+"|";
				else
					result += std::to_string(row * 3 + col) + "|";
			}
			result += "\n-------\n";
		}
		return result;
		*/
		return "TODO";
	}

	std::uint64_t penguin::hash() const
	{
		return 0;
	}

	std::uint64_t penguin::hash(std::uint16_t m) const
	{
		return 0;
	}
	
	ostream& operator<<(ostream& os, const penguin& pen)
	{
		os << pen.to_string() << endl;
		return os;
	}
}