TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
State.h
1#include <string>
2#include <vector>
3#include <tt/world/Signature.h>
4#include <tt/world/Assignment.h>
5
6#pragma once
7
8#ifndef STATE_H
9#define STATE_H
10
11namespace tt {
18 class State {
19 public:
20 // default constructor for json deserialization
21 State() {};
22
28 std::string toString() const;
29
35 const std::string& getDescription() const;
36
45 const std::string& getCode() const;
46
53 const std::vector<const Assignment*>& getAssignments() const;
54
62 const Value* get(const Variable* variable) const;
63
64 bool operator==(const State& rhs) const;
65
66 friend void from_json(const nlohmann::json& j, State& obj);
67 friend void to_json(nlohmann::json& j, const State& obj);
68 friend std::ostream& operator<<(std::ostream& os, const State& a);
69 private:
71 std::string description;
73 std::string code;
75 std::vector<std::unique_ptr<Assignment>> assignments;
77 mutable std::vector<const Assignment *> assignmentsPtrs;
78 };
79
80 void from_json(const nlohmann::json& j, State& obj);
81 void to_json(nlohmann::json& j, const State& obj);
82
90 std::ostream& operator<<(std::ostream& os, const State& a);
91}
92
93#endif
A state is an assignment of values to each variable in a story world.
Definition State.h:18
std::string toString() const
Returns a string representation of this object.
Definition State.cpp:8
const std::string & getDescription() const
Returns a human-readable natural language description of the object.
Definition State.cpp:19
const Value * get(const Variable *variable) const
Returns the value assigned to the given variable, or nullptr if the variable does not exist in this s...
Definition State.cpp:41
friend std::ostream & operator<<(std::ostream &os, const State &a)
Override stream insertion operator to allow printing the State class.
const std::string & getCode() const
Returns a string of 1's and 0's that uniquely represents this object among other objects of the same ...
Definition State.cpp:24
const std::vector< const Assignment * > & getAssignments() const
Returns an unmodifiable list of assignments of a value to each variable in the state.
Definition State.cpp:29
A value is a logical expression which evaluates to itself.
Definition Value.h:17
A variable is an asset that represents a feature of the story world state that can change.
Definition Variable.h:19
Tandem Tales is a platform that enables short, paired storytelling exercises between two agents over ...
Definition Client.h:22
std::ostream & operator<<(std::ostream &os, const Client &a)
Override stream insertion operator to allow printing the Client class.
Definition Client.cpp:556