Navigating and Searching the MUDIn order for a bot to search the MUD, it must have a way to navigate. In other words, it must have a method for moving from room to room.
Important Data Structures for Navigating the MUDThe most important data structure in the MUD is called the room. Besides the fact that the room metaphor is the abstraction that helps keep the environment coherent and understandable, rooms form the 'context' of computation. For the purposes of search and navigation, rooms have the following properties:
Object NumbersEvery object in the MUD has a unique object number assigned by the system. In navigation and search it is often useful to maintain a list of rooms that have been visited, to help avoid navigating and searching the same areas over and over again.
Maintaining Lists of ObjectsThere are two methods for maintaining lists of objects. In the case of navigating and search rooms, the first method is to keep every object in the order it was visited. Suppose a bot had a property defined that was named .room_list - the method for keeping a complete list of every room visted could be done like this:
The second method is to record rooms using the idea of mathematical sets, where only one instance of an object can appear in a set - the method for maintaining such a list would be this:
Equally important is the ability to determine whether an object is on a list or not. This is most easily achieved using the 'in' operator. For example, suppose a bot had a local variable named 'roompos' for temporarily storing the position of a room object in a list of rooms. That could be done like this:
Room TypesEvery room inherits functions/verbs and properties from its ancestors. All rooms inherit from 'generic room(#3)'. In Blackwood, all the rooms also inherit from 'GameRoom(#1805)'. The following are all children of $g.gameroom:
ExitsEvery room has a '.exits' property, listing the exits leaving the room. Exits have the following properties:
The .exits property is usually private (only visible to the room's owner), so there is a 'wizardly' function defined on $g used to access this property. Suppose a bot had a local variable named 'current_exits', then the exits of the current room could be stored there as follows:
Important Functions for Navigating the MUDThe 'proper' way for bots to navigate the MUD is by going from room to room using connecting exits. This is accomplished using the 'move' function defined on $exit (the generic exit). Suppose, for example, a bot wished to move from its current room to the first room on the list of exits connected to the current room. This could be accomplished like this:
For next time, suppose the bot only wanted to visit a new room if it was of type $g.street and had never been vistied before.
Searching the MUDThe basis for searching the MUD is called a 'best-first' search algorithm, because it is possible in this problem-space to evaluate the relative values of competing paths. In the case of the Blackwood Mine search assignment, there is a value defined on each $g.street named '.to_mine' that contains an integer representing the distance from that room to the mine. Therefore, in this particular case, lower numbers are better.
For our purposes, the basic algorithm given on pages 73-79 of the Rich and Knight textbook as simplified below, is enough to form the basis of the assignment.
In LambdaMOO termsThe 'skeleton' of your search algorithm will look like this:
Contact: email@example.com; Modified: 14nov06