Robot challenge

new topic     » topic index » view thread      » older message » newer message

Since there were no takers for my "real life" programming
example, let's try writing some robot logic. There should
be some creative ways to code this. (Also possible to pit
one algorithm against another)

---------------------------------------------------------------
-- Given a maze (which may change at any time)
-- write a robot routine to navigate the maze starting
-- at the green dot in the upper lefthand corner, and ending
-- at the red rectangle in the lower right.
-- Do not refer to the coordinates in the draw_maze routine!
-- your initial robot position is given: {24,24}
-- (center of the green dot)
---------------------------------------------------------------
include graphics.e
include image.e
include get.e

atom key

procedure draw_maze()
object playfield
 playfield = {{20,20},{120,20},{120,120},{20,120},{20,20}}
 polygon(BLUE,1,playfield) -- blue field cause green looks yucky
 polygon(YELLOW,0,playfield) -- border in yellow for visibility
 draw_line(YELLOW,{{20,40},{110,40}}) -- draw a few walls
 draw_line(YELLOW,{{40,60},{100,60}})
 draw_line(YELLOW,{{40,60},{40,40}})
 draw_line(YELLOW,{{20,80},{60,80}})
 draw_line(YELLOW,{{60,88},{60,70}})
 draw_line(YELLOW,{{80,120},{80,100}})
 draw_line(YELLOW,{{90,80},{120,80}})
 draw_line(YELLOW,{{90,80},{60,100}})
 draw_line(YELLOW,{{80,100},{100,100}})
 ellipse(GREEN,1,{22,22},{26,26})
 polygon(RED,1,{{110,110},{118,110},{118,118},{110,118},{110,110}})
end procedure

if graphics_mode(19) then
end if

draw_maze()
--------------------------------
-- your bot procedure(s) here
--------------------------------

key = wait_key()

if graphics_mode(-1) then
end if

-- Irv

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu