File: Variant.h

package info (click to toggle)
pentobi 29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,892 kB
  • sloc: cpp: 25,719; javascript: 875; xml: 40; makefile: 13; sh: 6
file content (189 lines) | stat: -rw-r--r-- 4,164 bytes parent folder | download | duplicates (4)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//-----------------------------------------------------------------------------
/** @file libpentobi_base/Variant.h
    @author Markus Enzenberger
    @copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------

#ifndef LIBPENTOBI_BASE_VARIANT_H
#define LIBPENTOBI_BASE_VARIANT_H

#include <memory>
#include <string>
#include <vector>
#include "Color.h"
#include "Geometry.h"
#include "libboardgame_base/PointTransform.h"

namespace libpentobi_base {

using libboardgame_base::PointTransform;

//-----------------------------------------------------------------------------

enum class PieceSet
{
    classic,

    junior,

    trigon,

    nexos,

    callisto,

    gembloq
};

//-----------------------------------------------------------------------------

enum class BoardType
{
    classic,

    duo,

    trigon,

    trigon_3,

    nexos,

    callisto,

    callisto_2,

    callisto_3,

    gembloq,

    gembloq_2,

    gembloq_3
};

//-----------------------------------------------------------------------------

enum class GeometryType
{
    classic,

    trigon,

    nexos,

    callisto,

    gembloq
};

//-----------------------------------------------------------------------------

/** Game variant. */
enum class Variant
{
    classic,

    classic_2,

    classic_3,

    duo,

    junior,

    trigon,

    trigon_2,

    trigon_3,

    nexos,

    nexos_2,

    callisto,

    callisto_2,

    /** Callisto two-player four-color. */
    callisto_2_4,

    callisto_3,

    gembloq,

    gembloq_2,

    /** GembloQ two-player four-color. */
    gembloq_2_4,

    gembloq_3
};

//-----------------------------------------------------------------------------

/** Get name of game variant as in the GM property in Blokus SGF files. */
const char* to_string(Variant variant);

/** Get a short lowercase string without spaces that can be used as
    a identifier for a game variant.
    The strings used are "classic", "classic_2", "classic_3", "duo", "junior",
    "trigon", "trigon_2", "trigon_3", "nexos", "nexos_2", "callisto",
    "callisto_2", "callisto_2_4", "callisto_3", "gembloq", "gembloq_2",
    "gembloq_2_4", "gembloq_3". */
const char* to_string_id(Variant variant);

/** Parse name of game variant as in the GM property in Blokus SGF files.
    The parsing is case-insensitive, leading and trailing whitespaced are
    ignored.
    @param s
    @param[out] variant
    @result True if the string contained a valid game variant. */
bool parse_variant(const string& s, Variant& variant);

/** Parse short lowercase name of game variant as returned to_string_id().
    @param s
    @param[out] variant
    @result True if the string contained a valid game variant. */
bool parse_variant_id(const string& s, Variant& variant);

Color::IntType get_nu_colors(Variant variant);

inline Color::Range get_colors(Variant variant)
{
    return Color::Range(get_nu_colors(variant));
}

Color::IntType get_nu_players(Variant variant);

const Geometry& get_geometry(BoardType board_type);

const Geometry& get_geometry(Variant variant);

GeometryType get_geometry_type(Variant variant);

BoardType get_board_type(Variant variant);

PieceSet get_piece_set(Variant variant);

/** Get invariance transformations for a game variant.
    The invariance transformations depend on the symmetry of the board type and
    the starting points.
    @param variant The game variant.
    @param[out] transforms The invariance transformations.
    @param[out] inv_transforms The inverse transformations of the elements in
    transforms. */
void get_transforms(Variant variant,
                    vector<unique_ptr<PointTransform<Point>>>& transforms,
                    vector<unique_ptr<PointTransform<Point>>>& inv_transforms);

/** Is the variant a two-player variant with the board including the starting
    points invariant through point reflection through its center? */
bool has_central_symmetry(Variant variant);

//-----------------------------------------------------------------------------

} // namespace libpentobi_base

#endif // LIBPENTOBI_BASE_VARIANT_H