-- Strategy for moving randomly

class
	RANDOM_MOVE

inherit
  STRATEGY

creation
  make

feature{NONE}

  directions : RANDOM_INTEGERS is
  -- Random number generator for when I don't have a clue
  -- where to move.
  once
    !!result.make
  end

  try_one_direction( d : INTEGER ) is
  -- Try direction `d'.
  do
    inspect d
    when 0 then mobile.try_north
    when 1 then mobile.try_east
    when 2 then mobile.try_south
    when 3 then mobile.try_west
    end
  end

  try_directions( dir : INTEGER ) is
  -- Try direction `dir' first, but try others if
  -- I can't go there.
  local i, d : INTEGER
  do
    d := dir
    from i := 1 until mobile.success or else i > 4
    loop
      try_one_direction( d )
      d := ( d + 1 ) \\ 4
      i := i + 1
    end
  end

feature

  try_move is
  do
    check not mobile.success end
    directions.randomize( 4 )
    try_directions( directions.random_integer )
  end

end -- class RANDOM_MOVE
