Symphony 1.0
Loading...
Searching...
No Matches
definitions.h
Go to the documentation of this file.
1
6#ifndef DEFINITIONS_H
7#define DEFINITIONS_H
8
9#include <string>
10#include <vector>
11#include <memory>
12
18class State {
19public:
23 State() {}
24
28 virtual ~State() {}
29
35 virtual void print() {}
36};
37
43class Action {
44public:
45 std::string name; // Action name (e.g., "Up", "Down")
46 double cost; // Cost of the action
47 std::shared_ptr<State> source_state; // Source state
48 std::shared_ptr<State> effect; // Resulting state after applying the action
49
50 // Constructor
51 Action(const std::string &name, double cost, std::shared_ptr<State> source_state, std::shared_ptr<State> effect)
53};
54
55
56
63class Problem {
64public:
69
73 virtual ~Problem() {}
74
80 virtual State *initial_state() { return initial_state_; }
81
90 virtual bool goal_test(State *state) = 0;
91
100 virtual std::vector<std::shared_ptr<Action>> actions(std::shared_ptr<State> state) = 0;
101
110 virtual double heuristic(State *state) = 0;
111
114};
115
116#endif // DEFINITIONS_H
Represents an abstract action that can be performed on a state.
Definition definitions.h:43
std::shared_ptr< State > effect
Definition definitions.h:48
double cost
Definition definitions.h:46
std::string name
Definition definitions.h:45
std::shared_ptr< State > source_state
Definition definitions.h:47
Action(const std::string &name, double cost, std::shared_ptr< State > source_state, std::shared_ptr< State > effect)
Definition definitions.h:51
Represents an abstract problem that needs to be solved.
Definition definitions.h:63
virtual bool goal_test(State *state)=0
Tests if a given state satisfies the goal condition.
virtual double heuristic(State *state)=0
Computes a heuristic estimate for a given state.
virtual std::vector< std::shared_ptr< Action > > actions(std::shared_ptr< State > state)=0
Retrieves the set of actions applicable to a given state.
virtual State * initial_state()
Retrieves the initial state of the problem.
Definition definitions.h:80
State * initial_state_
Pointer to the initial state of the problem.
Problem()
Constructor for the Problem class.
Definition definitions.h:68
virtual ~Problem()
Virtual destructor for the Problem class.
Definition definitions.h:73
Represents an abstract state in a problem.
Definition definitions.h:18
virtual void print()
Prints the state details.
Definition definitions.h:35
virtual ~State()
Virtual destructor for the State class.
Definition definitions.h:28
State()
Constructor for the State class.
Definition definitions.h:23