Difference between revisions of "Maze1Bot"

From BerryBots Wiki
Jump to: navigation, search
(page for bot Maze1Bot)
 
m (path)
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
A sample ship that comes packaged with BerryBots (as <code>bots/sample.maze1bot.lua</code>). It is designed to solve [[sample.maze1]] with a hard coded path produced through trial and error. Demonstrates a very simple and naive approach to solving [[:Category:Maze Stages|mazes]].
+
A sample ship packaged with BerryBots as <tt>sample/maze1bot.lua</tt>. It's designed to solve [[sample.maze1]] with a hard coded path produced through trial and error. Demonstrates a very simple and naive approach to solving [[:Category:Maze Stages|mazes]].
  
 
== Source code ==
 
== Source code ==
 
<source>
 
<source>
-- A sample bot to navigate sample.maze1.lua. Path is developed through trial
+
-- A ship designed to navigate sample.maze1.lua. Path is developed through trial
 
-- and error, hard coded and not doing anything intelligent.
 
-- and error, hard coded and not doing anything intelligent.
  

Latest revision as of 01:57, 12 March 2013

A sample ship packaged with BerryBots as sample/maze1bot.lua. It's designed to solve sample.maze1 with a hard coded path produced through trial and error. Demonstrates a very simple and naive approach to solving mazes.

[edit] Source code

-- A ship designed to navigate sample.maze1.lua. Path is developed through trial
-- and error, hard coded and not doing anything intelligent.
 
ship = nil
world = nil
 
function init(shipArg, worldArg)
  ship = shipArg
  world = worldArg
end
 
function run()
  time = world:time()
  if (time <= 10) then
    ship:fireThruster(math.pi * .25, 1)
  elseif (time > 35 and time <= 45) then
    ship:fireThruster(math.pi * 1.25, 1)
  elseif (time > 45 and time <= 55) then
    ship:fireThruster(math.pi * 1.85, 1)
  elseif (time > 100 and time <= 110) then
    ship:fireThruster(math.pi * .5, 1)
  elseif (time > 120 and time <= 130) then
    ship:fireThruster(math.pi * .85, 1)
  elseif (time > 133 and time <= 143) then
    ship:fireThruster(math.pi, 1)
  elseif (time > 143 and time <= 153) then
    ship:fireThruster(math.pi * 1.5, 1)
  elseif (time > 170 and time <= 180) then
    ship:fireThruster(math.pi * .5, 1)
  elseif (time > 200 and time <= 210) then
    ship:fireThruster(math.pi * 1.5, 1)
  end
end
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox