Skip to content

Commit

Permalink
Add hint about adding parameters to the main parameter struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ll-nick committed Oct 24, 2024
1 parent 675a92d commit 1c1d1ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/tasks/2_extend_arbitration_graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Integrate the `ChaseGhost` behavior component into the arbitration graph defined

- Take a look at how the other behavior components are defined in `include/demo/pacman_agent.hpp`.
- Add the `ChaseGhost` behavior component as a new member of the `PacmanAgent` class and initialize it in the constructor.
- Extend the `PacmanAgent` parameter struct to include the parameters for the `ChaseGhost` behavior component.
- Add a new option to the priority arbitrator.
- Run the game, take a look at the new arbitration graph and observe how PacMan behaves.

Expand All @@ -42,6 +43,16 @@ private:
ChaseGhostBehavior::Ptr chaseGhostBehavior_;
```

Extend the `PacmanAgent` parameter struct to include the parameters for the `ChaseGhost` behavior component:
```cpp
struct Parameters {
AvoidGhostBehavior::Parameters avoidGhostBehavior;
// Add the parameters for the ChaseGhost behavior component
ChaseGhostBehavior::Parameters chaseGhostBehavior;
MoveRandomlyBehavior::Parameters moveRandomlyBehavior;
};
```
In the constructor of the `PacmanAgent` class, initialize the `ChaseGhost` behavior component and add it to the priority arbitrator:
```cpp
explicit PacmanAgent(const entt::Game& game)
Expand Down
13 changes: 13 additions & 0 deletions docs/tasks/5_cost_arbitration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Finish the implementation of the `CostEstimator` and replace the random arbitrat

- In `cost_estimator.cpp`, fill in the blanks to compute `nDots` and `nCells`.
- Add an instance of the `CostEstimator` to the `PacmanAgent` class and initialize it in the constructor.
Don't forget to include the necessary headers and extend the parameter struct with the parameters for the `CostEstimator`.
- Replace the random arbitrator with a cost arbitrator in the `PacmanAgent` class. Pass the `CostEstimator` instance to the `addOption` method.

## Solution
Expand Down Expand Up @@ -79,6 +80,18 @@ private:
CostEstimator::Ptr costEstimator_;
```

Extend the `Parameters` struct to contain the parameters for the `CostEstimator`:
```cpp
struct Parameters {
AvoidGhostBehavior::Parameters avoidGhostBehavior;
ChaseGhostBehavior::Parameters chaseGhostBehavior;
MoveRandomlyBehavior::Parameters moveRandomlyBehavior;

// Add the parameters for the CostEstimator
CostEstimator::Parameters costEstimator;
};
```
As always, the magic happens in the constructor of the `PacmanAgent` class.
Instantiate the cost estimator and pass it in the `addOption` calls:
```cpp
Expand Down

0 comments on commit 1c1d1ea

Please sign in to comment.