Rorso Wizard
Joined: 14 Oct 2000 Posts: 1368
|
Posted: Wed Sep 08, 2004 4:43 pm
Explore all mapped rooms |
I changed my auto-mapping script to be able to do auto-exploring. The algorithm used is depth-first search adapted to work with graphs.
#CLASS {mapexplorer} {setdef}
#ALIAS explore {
#priority {
#echo exploring
#noop // Is there some unexplored exit in this room?
#if ((@lastroom=%roomnum( )) and (@recovering="false")) {
#echo I am stuck! Trying to recover!
#stop
#nodir
#find
recovering=true
} {
#if (@recovering="true") {
unexplored = %delitem( @lastroom, @unexplored)
ignorerooms=%push( @lastroom|@lastexit, @ignorerooms)
recovering=false
}
}
explored=%push( %roomnum( ), @explored)
counter=0
exit=%item( exits, @counter)
#forall @exits {
#if (%roomlink( , %i) > 0) {
#if (not %ismember( %roomnum( )|%i, @ignorerooms) and not %ismember( %roomlink( , %i), @explored)) {
exit=%i
counter=%eval( @counter+1)
}
}
}
#if (@exit!=%null) {
#noop // We found an exit. If we have unexplored exits left add this location to the 'unexplored' list.
#if (@counter>1) {unexplored=%push( %roomnum( ), @unexplored)}
lastroom=%roomnum( )
lastexit=@exit
#exec @exit
} {
#noop // No exit found. Do we have any in the 'unexplored' list?
#if (@unexplored!=%null) {
roomnumber=%pop( unexplored)
lastroom=%roomnum( )
#echo Walking to @roomnumber from %roomnum( )
#walk @roomnumber
} {
#echo Exploration Finished
#t- autoexplorer
}
}
}
}
#VAR unexplored {}
#VAR exits {north|south|east|west|up|down}
#VAR ignorerooms {}
#VAR lastexit {west}
#VAR lastroom {198}
#VAR recovering {false}
#VAR explored {}
#ALARM "autoexplorer" {-1} {#if (%inwalk( )!="1") {explore}} "" {disable}
#BUTTON 1 {Auto-map} {
unexplored=""
ignorerooms=""
lastexit=""
lastroom=""
recovering=false
explored=""
#t+ autoexplorer
} {} {#t- autoexplorer} {%class(autoexplorer)} {1} {} {} {} {} {} {} {} {} {} {} {} "" {} {} {autoexplorerbutton}
#CLASS 0 |
|