DigitalCurling3
1.0.0
A curling simulation system for curling AIs
team.hpp
Go to the documentation of this file.
1
// MIT License
2
//
3
// Copyright (c) 2022 UEC Takeshi Ito Laboratory
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
25
26
#ifndef DIGITALCURLING3_TEAM_HPP
27
#define DIGITALCURLING3_TEAM_HPP
28
29
#include <cstdint>
30
#include <cassert>
31
#include <string>
32
#include <type_traits>
33
34
namespace
digitalcurling3
{
35
36
37
39
enum class
Team
: std::int8_t {
40
k0
= 0,
41
k1
= 1,
42
kInvalid
43
};
44
49
inline
Team
GetOpponentTeam
(
Team
team)
50
{
51
switch
(team) {
52
case
Team::k0
:
return
Team::k1
;
53
case
Team::k1
:
return
Team::k0
;
54
case
Team::kInvalid
:
return
Team::kInvalid
;
55
default
:
56
assert(
false
);
57
return
Team::kInvalid
;
58
}
59
}
60
65
inline
std::string
ToString
(
Team
team)
66
{
67
switch
(team) {
68
case
Team::k0
:
return
"team0"
;
69
case
Team::k1
:
return
"team1"
;
70
case
Team::kInvalid
:
return
"invalid"
;
71
default
:
72
assert(
false
);
73
return
std::string();
74
}
75
}
76
81
template
<
class
T>
82
inline
std::underlying_type_t<T>
ToUType
(T value)
83
{
84
return
static_cast<
std::underlying_type_t<T>
>
(value);
85
}
86
87
88
// json
89
NLOHMANN_JSON_SERIALIZE_ENUM(
Team
, {
90
{
Team::k0
,
"team0"
},
91
{
Team::k1
,
"team1"
},
92
{
Team::kInvalid
,
nullptr
},
93
})
94
95
}
// namespace digitalcurling3
96
97
#endif // DIGITALCURLING3_TEAM_HPP
digitalcurling3::Team
Team
チームを識別するために用いる列挙体です.
Definition:
team.hpp:39
digitalcurling3::ToString
std::string ToString(Team team)
チームを文字列に変換する
Definition:
team.hpp:65
digitalcurling3::Team::k1
@ k1
チーム1.最初のエンドで後攻のチーム.
digitalcurling3::GetOpponentTeam
Team GetOpponentTeam(Team team)
相手チームを得る
Definition:
team.hpp:49
digitalcurling3::ToUType
std::underlying_type_t< T > ToUType(T value)
enum class を std::underlying_type_t に変換する
Definition:
team.hpp:82
digitalcurling3
Digital Curling ライブラリはこの名前空間の中に定義されます
Definition:
polymorphic_json.hpp:37
digitalcurling3::Team::k0
@ k0
チーム0.最初のエンドで先攻のチーム.
digitalcurling3::Team::kInvalid
@ kInvalid
無効な値
include
digitalcurling3
detail
team.hpp
Generated by
1.8.17