- First, I pick a direction (say left), and, starting from the soldier, I mark every obstacle in the direction:
LEFT [soldier |...| Obstacle no mark] -> [soldier |...| Obstacle mark]
- Then, I do the same in the opposite direction, this time starting from the agent. If the ray encounters a marked obstacle, it means the obstacle is between the two players, and I mark the player as safe.
RIGHT [agent |...| Obstacle mark] -> [agent safe |...| Obstacle mark]
- Finally I cast another ray from the soldier in the first direction, this time looking for the agent. If it is not marked as safe, it means it is visible, so I switch its state consequently.
- Before going on with the other directions I make sure to unmark the obstacles and the agent.
[mark] -> []
[safe] -> []
Aucun commentaire:
Enregistrer un commentaire