ranged.tgz
snippets · 4.8 KB · 2010-03-30
Ranged search code by Justice (June 13, 2006).
Download « Back to the snippets list
ranged/readme.txt
Ranged Search Code
by Justice (Kwon J. Ekstrom)
Updated: June 13, 2006
Special thanks to:
------------------------
Hypereye for the use of his server as a test site.
Samson for information regarding SmaugFUSS and dlsym.
Description:
------------------------
This code was originally written to handle the ranged search capabilities
of a from-scratch C++ codebase. It was ported to SmaugFUSS for distribution
at "http://www.mudbytes.net/".
The purpose of this snippet is to reduce the code necessary for ranged
systems. It does this by delegating an object to handle each room
individually while a separate algorithm determines what rooms are
searched and their order.
The code consists primarily of 3 parts:
algorithms, search_frame, search_callback
Algorithms:
------------------------
The algorithms implement how the search is conducted. Currently there are
3 algorithms implemented which should be sufficient for most ranged searches
for a room based mud.
The search_BFS class implements a "breadth first search" which works similar
to how track does in a standard SMAUG.
The search_LOS class implements a "line of sight search" which works by
expanding outward in any direction available from the start room.
The search_DIR class is similar to search_LOS but only expands in a given
direction.
Search Frame:
------------------------
The search_frame class stores the current state of the search.
Search Callback:
------------------------
The callback objects are where you would implement the purpose behind any
given search. It defines only one abstract method. It takes a search frame
as input and returns true if the target is "found" or false to keep searching.
Examples:
------------------------
Included with the source are 2 examples. A basic scan function and a mini-map.
Archive contents (4 files)
| File | Size |
|---|---|
| ranged/install.txt | 777 B |
| ranged/readme.txt | 1.8 KB |
| ranged/search.c | 14.3 KB |
| ranged/search.h | 3.3 KB |