module Robot
where
import Types
data Memory = Memory
{visited::[Point]
,dfsstack::[Point]
,currentPoz::Point
}deriving(Eq)
{-
When the robot enters the mine it receives as input the size of the mine (it
is always placed at (0, 0)). This function should return the initial memory
element of the robot.
-}
--startRobot :: Size -> a
startRobot s = (Memory [] [] (0, 0))
--can_go_there :: Point -> [Point] -> Bool
--can_go_there p lst
-- |
--can_not_go_there b =
{-
At each time step the robot sends a light beam in all 4 cardinal directions,
receives the reflected rays and computes their intensity (the first argument
of the function).
The robot sees nearby pits. The second argument of this function is the list
of neighbouring pits near the robot (if empty, there are no pits).
Taking into account the memory of the robot (third argument of the function),
it must return a tuple containing a new cardinal direction to go to and a new
memory element.
If the cardinal direction chosen goes to a pit or an wall the robot is
destroyed. If the new cell contains minerals they are immediately collected.
-}
--perceiveAndAct :: SVal -> [Cardinal] -> a -> (Action, a)
perceiveAndAct s cs m
| elem W cs && elem N cs && elem E cs && notElem S cs = (Just S, m)
| notElem W cs && elem N cs && elem E cs && elem S cs = (Just W, m)
| elem W cs && elem N cs && notElem E cs && elem S cs = (Just E, m)
| elem W cs && notElem N cs && elem E cs && elem S cs = (Just N, m)
| elem W cs && elem N cs && notElem E cs && notElem S cs = (Just E, m)
| notElem W cs && elem N cs && elem E cs && notElem S cs = (Just S, m)
| elem W cs && notElem N cs && notElem E cs && elem S cs = (Just N, m)
| elem W cs == False && elem N cs == False && elem E cs && elem S cs = (Just W, m)
| elem W cs && elem N cs == False && elem E cs && elem S cs == False = (Just N, m)
| elem W cs == False && elem N cs && elem E cs == False && elem S cs = (Just E, m)
| elem W cs && elem N cs == False && elem E cs == False && elem S cs == False = (Just N, m)
| elem W cs == False && elem N cs && elem E cs == False && elem S cs == False = (Just E, m)
| elem W cs == False && elem N cs == False && elem E cs && elem S cs == False = (Just S, m)
| elem W cs == False && elem N cs == False && elem E cs == False && elem S cs = (Just W, m)
| otherwise = (Just S, m)