Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef __PENGUIN_HPP__
#define __PENGUIN_HPP__
#include "game.hpp"
#include <random>
#include <array>
#include <iostream>
#include <memory>
namespace game
{
struct penguin_state
{
uint64_t one_fish = 0x7F59398348146BD; //Position of one-fish tiles (bitboard)
uint64_t two_fish = 0x86C628366B102; //Position of two-fish tiles (bitboard)
uint64_t three_fish = 0x802000548180840; //Position of three-fish tiles (bitboard)
//Penguins
uint32_t p1_red = 0;
uint32_t p2_red = 1;
uint32_t p3_red = 8;
uint32_t p4_red = 9;
uint32_t p1_blue = 51;
uint32_t p2_blue = 52;
uint32_t p3_blue = 58;
uint32_t p4_blue = 59;
bool red_player_win = false;
bool blue_player_win = false;
int score_red = 0;
int score_blue = 0;
bool current_player_red = true; //True if red must play now
};
class penguin : public game<penguin_state>
{
public:
penguin();
penguin(const penguin& pen) = default;
penguin& operator=(const penguin& pen) = default;
bool end_of_game() const; //Is the game ended? (draw or won)
int value(std::uint8_t player) const; //Returns if the player win, loose or nothing
bool won(std::uint8_t player) const;
bool lost(std::uint8_t player) const;
bool draw(std::uint8_t player) const;
uint8_t current_player() const; //The player that has to play next (at the beginning, the first player)
std::uint16_t number_of_moves() const; //Number of moves that you can play
void play(std::uint16_t m); //Play the move m (updates the state).
void undo(std::uint16_t m) {}
std::string player_to_string(std::uint8_t player) const; //String representation of a player
std::string move_to_string(std::uint16_t m) const; //String representation of a move (for example, A1)
std::string to_string() const; //String representation of the entire game
std::set<int> to_input_vector() const;
void from_input_vector(const std::set<int>& input);
penguin_state get_state(); //Return the state
void set_state(const penguin_state& state); //Replace the current state with the one passed as a parameter
std::shared_ptr<game<penguin_state>> do_copy() const;
std::uint64_t hash(std::uint16_t m) const;
std::uint64_t hash() const;
private:
penguin_state state;
};
std::ostream& operator<<(std::ostream& os, const penguin& pen);
}
#endif