Difference between revisions of "Hedgemaze"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
(Use that code frequently, so might as well just paste it in!)
imported>Bale
m
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Adventuring|
 
  
 
function1={{Function|
 
function1={{Function|
Line 14: Line 13:
 
}}|
 
}}|
  
function_description=Attempts to complete the hedge maze puzzle and returns its success.|
+
function_description=Attempts to complete the hedge maze puzzle, first to get the key, then to find the exit. It returns true if the maze is complete.|
  
  
Line 24: Line 23:
 
boolean hedging() {
 
boolean hedging() {
 
     boolean success = false;
 
     boolean success = false;
int maze_trips = 0;
+
  int maze_trips = 0;
 
+
while(my_adventures() > 0 && !success) {
+
  while(my_adventures() > 0 && !success) {
if(item_amount($item[hedge maze puzzle]) == 0) {
+
      if(item_amount($item[hedge maze puzzle]) == 0) {
adventure(1, $location[hedge maze]);
+
        adventure(1, $location[hedge maze]);
maze_trips = maze_trips + 1;
+
        maze_trips = maze_trips + 1;
if(maze_trips > 1)
+
        if(maze_trips > 1)
print("Entered the Hedge Maze "+ maze_trips + " times.");
+
            print("Entered the Hedge Maze "+ maze_trips + " times.");
else  
+
        else  
print("Entered the Hedge Maze once.");
+
            print("Entered the Hedge Maze once.");
}
+
      }
if(item_amount($item[hedge maze puzzle]) > 0)
+
      if(item_amount($item[hedge maze puzzle]) > 0)
success = hedgemaze();
+
        success = hedgemaze();
}
+
  }
return success;
+
  return success;
 
}
 
}
 
+
 
void main() {
 
void main() {
if(!contains_text(visit_url("lair3.php"), "lair4.php"))
+
  if(!contains_text(visit_url("lair3.php"), "lair4.php"))
hedging();
+
      hedging();
print("Hedge Maze solved!", "green");
+
  print("Hedge Maze solved!", "green");
 
}
 
}
 
</syntaxhighlight>}}|
 
</syntaxhighlight>}}|
Line 51: Line 50:
 
cli_equiv=The CLI command "entryway" will perform the same tasks.|
 
cli_equiv=The CLI command "entryway" will perform the same tasks.|
 
}}
 
}}
{{RFI|Does this function complete the entire maze (both getting the key and getting the exit)?}}
+
 
 +
[[Category:Adventuring]]

Latest revision as of 22:19, 21 May 2010

Function Syntax

boolean hedgemaze()

Attempts to complete the hedge maze puzzle, first to get the key, then to find the exit. It returns true if the maze is complete.

Hedging

A complete program that solves the Hedge Maze, killing as many hedge golems as necessary to get mazes and counting the turns used.

boolean hedging() {
    boolean success = false;
   int maze_trips = 0;
 
   while(my_adventures() > 0 && !success) {
      if(item_amount($item[hedge maze puzzle]) == 0) {
         adventure(1, $location[hedge maze]);
         maze_trips = maze_trips + 1;
         if(maze_trips > 1)
            print("Entered the Hedge Maze "+ maze_trips + " times.");
         else 
            print("Entered the Hedge Maze once.");
      }
      if(item_amount($item[hedge maze puzzle]) > 0)
         success = hedgemaze();
   }
   return success;
}
 
void main() {
   if(!contains_text(visit_url("lair3.php"), "lair4.php"))
      hedging();
   print("Hedge Maze solved!", "green");
}

CLI Equivalent

The CLI command "entryway" will perform the same tasks.

See Also

chamber() | entryway() | guardians() | tavern()