File: Setup.h

package info (click to toggle)
pentobi 26.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,068 kB
  • sloc: cpp: 25,986; javascript: 897; xml: 57; makefile: 13; sh: 11
file content (46 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (5)
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
//-----------------------------------------------------------------------------
/** @file libpentobi_base/Setup.h
    @author Markus Enzenberger
    @copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------

#ifndef LIBPENTOBI_BASE_SETUP_H
#define LIBPENTOBI_BASE_SETUP_H

#include "ColorMap.h"
#include "Move.h"
#include "libboardgame_base/ArrayList.h"

namespace libpentobi_base {

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

/** Definition of a setup position.
    A setup position consists of a number of pieces that are placed at once
    (in no particular order) on the board and a color to play next. */
struct Setup
{
    /** Maximum number of pieces on board per color. */
    static constexpr unsigned max_pieces = 24;

    using PlacementList = libboardgame_base::ArrayList<Move, max_pieces>;


    Color to_play = Color(0);

    ColorMap<PlacementList> placements;

    void clear();
};

inline void Setup::clear()
{
    to_play = Color(0);
    for_each_color([&](Color c) { placements[c].clear(); });
}

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

} // namespace libpentobi_base

#endif // LIBPENTOBI_BASE_SETUP_H