EC Challenge 3.4 BFS MUD Driver


Intro to Programming Languages.

[ ← Module List ]


Challenges

Objective

Creat 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

  1. Get familiar with the muddydriver folder, there's 4 files in there
  2. Create an enum in data.h
    
        typedef enum Directions {
                NORTH = 'n', SOUTH = 's', EAST = 'e', WEST = 'w'
        } Directions;
  3. Check out the class BFSMuddyDriver in bfs_muddy_driver.h
  4. Define methods for BFSMuddyDriver in bfs_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"

  5. 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.solve and pass in the starting room id and the destination room id

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

  1. Modify BFSMuddyDriver::createSolution to populate the solution vector using the path stored in the cameFrom variable
  2. Read the comment describing the process and implment the functionality.
  3. 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

30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score