Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ur_player_cpu_random.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPPLAYERCPURANDOM_H
13#define ZOAPPPLAYERCPURANDOM_H
14
15#include <random>
16
17#include "toymaker/sim_system.hpp"
18
19#include "ur_controller.hpp"
20
26class PlayerCPURandom: public ToyMaker::SimObjectAspect<PlayerCPURandom> {
27public:
28 PlayerCPURandom(): SimObjectAspect<PlayerCPURandom>{0} {}
29 inline static std::string getSimObjectAspectTypeName() { return "UrPlayerCPURandom"; }
30 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
31 std::shared_ptr<BaseSimObjectAspect> clone() const override;
32
33private:
38 std::string mControllerPath {};
39
46 std::unique_ptr<UrPlayerControls> mControls {};
47
52 std::random_device mRandomDevice {};
53
58 std::default_random_engine mRandomEngine { mRandomDevice() };
59
64 void onActivated() override;
65
71 void onMovePrompted(GamePhaseData phaseData);
72
77 ToyMaker::SignalObserver<GamePhaseData> mObserveMovePrompted { *this, "MovePromptedObserved", [this](GamePhaseData phaseData) { this->onMovePrompted(phaseData); }};
78public:
79};
80
81#endif
ToyMaker::SignalObserver< GamePhaseData > mObserveMovePrompted
The observer connected with this aspect, responsible for receiving and responding to move prompt even...
Definition ur_player_cpu_random.hpp:77
void onMovePrompted(GamePhaseData phaseData)
Callback for an event from GameOfUrController, prompting this player for a new game-related action.
Definition ur_player_cpu_random.cpp:25
std::random_device mRandomDevice
The device responsible for providing this class with random numbers.
Definition ur_player_cpu_random.hpp:52
void onActivated() override
Broadcasts its existence to UrController and receives in exchange an instance of UrPlayerControls.
Definition ur_player_cpu_random.cpp:16
std::default_random_engine mRandomEngine
An engine using the random device.
Definition ur_player_cpu_random.hpp:58
std::string mControllerPath
The path to the game controller this player interfaces with.
Definition ur_player_cpu_random.hpp:38
std::shared_ptr< BaseSimObjectAspect > clone() const override
A method which must be overridden to specify how a new aspect should be constructed as a copy of this...
Definition ur_player_cpu_random.cpp:10
std::unique_ptr< UrPlayerControls > mControls
The controls object created by the game controller.
Definition ur_player_cpu_random.hpp:46
A SignalObserver object, which can subscribe to Signals matching its data signature and receive signa...
Definition signals.hpp:412
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
Data returned by GameOfUrModel when queried about the current phase of the game.
Definition model.hpp:112
Contains the class definition for UrController, the aspect responsible for managing and reporting the...