-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathround.cpp
41 lines (34 loc) · 1.15 KB
/
round.cpp
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
#include "simulation/round.hpp"
#include "simulation/zimo.hpp"
#include "simulation/round_state.hpp"
#include "simulation/paishan.hpp"
#include "simulation/game_state.hpp"
#include "simulation/game_log.hpp"
#include "common/throw.hpp"
#include <vector>
#include <functional>
#include <any>
#include <stdexcept>
#include <cstdint>
namespace Kanachan{
bool simulateRound(
std::vector<std::uint_least32_t> const &seed, Kanachan::GameState &game_state,
Kanachan::Paishan const * const p_test_paishan, Kanachan::GameLog &game_log)
{
Kanachan::RoundState round_state(seed, game_state, p_test_paishan);
game_log.onBeginningOfRound();
std::function<std::any()> next_step = std::bind(
&Kanachan::zimo, std::ref(round_state), std::ref(game_log));
for (;;) {
std::any next_step_ = next_step();
if (std::any_cast<std::function<std::any()>>(&next_step_) != nullptr) {
next_step = std::any_cast<std::function<std::any()>>(next_step_);
continue;
}
if (std::any_cast<bool>(&next_step_) != nullptr) {
return std::any_cast<bool>(next_step_);
}
KANACHAN_THROW<std::logic_error>("A logic error.");
}
}
} // namespace Kanachan