EC Challenge 3.4 BFS MUD Driver
[ ← Module List ]

2 challenges
Challenges
EC3.4 Level 01 - MUD Driver 1
— solves
Objective
Create a BFS search that will figure out the path from the player's current location to the desired room id.
HINT: Don't forget we did a lab on BFS that will help with the skeleton code here
Requirements
- Get familiar with the
muddydriverfolder, there's 4 files in there - Create an enum in
data.htypedef enum Directions { NORTH = 'n', SOUTH = 's', EAST = 'e', WEST = 'w' } Directions; - Check out the class BFSMuddyDriver in bfs_muddy_driver.h
- Define methods for
BFSMuddyDriverinbfs_muddy_driver.cpp- READ through the comments
- Inside the method
solve:- Initialize the cameFrom at the starting location to -1 (this will help with re-tracing steps)
- Must use the following for loop so that a room's exits are explored in the order NORTH, SOUTH, EAST, WEST
for (auto move : moves) { ... } - find the exit resulting from moving in the particular direction, the object can access
rooms[roomId] - When there's an exit and that room has not been visited then push it, mark it as visited, and show how the agent got to this room by marking this room with the room the agent traveled from
cameFrom[exploringRoom] = currentRoom - When the room being explored is the finishing room then create the solution and return true
If you want the full reward of an AIV then you must add a print statement to the end that says "Directions to your desired location discovered"
- Add a "f" / "find" command to the MUD's operational commands
- After the player inputs "find", prompt them to enter the room Id of the destination.
- Use the
BFSMuddyDriver.solveand pass in the starting room id and the destination room id
Starting…Open Workspace
EC3.4 Level 02 - MUD Driver
— solves
Objective
Populate the solution vector, which is implemented in the MuddyDriver base class. The solution vector will contain the directions taken to get from the start to the destination.
Steps to Complete
- Modify BFSMuddyDriver::createSolution to populate the solution vector using the path stored in the cameFrom variable
- Read the comment describing the process and implment the functionality.
- Update operations.cpp
- Add on to your code from the prior level to get the solution vector from the MuddyDriver object.
- Print out the solution vector space delimited using the Directions enum (so that it only prints the first letter of each direction).
- Example output:
s w s e e s w
Starting…Open Workspace