Skip to content

Commit

Permalink
fix watch wakeup test (#1791)
Browse files Browse the repository at this point in the history
This improves the test introduced in #1736 in a few ways:
* Place the system robot's code inline in the `program` field
    * even though the system bot had been using `instant`, the `run` command itself incurs a delay.  So this ensures the system robot is ready to monitor the cell immediately
* System robot uses exclusively `Intangible` commands in its monitoring loop
    * This allows removal of the `instant` command.
    * `Surveil`, which does not appear in any scenario yet, is made `Intangible`.
* Remove the initial `wait 2` in the player robot's solution.

Tested to ensure that this still exercises the problem that #1736 set out to solve, by commenting out this line (causing the scenario to fail).

https://github.com/swarm-game/swarm/blob/01ae0e45d75c30619af76ae2438dc1b92ef61e08/src/swarm-engine/Swarm/Game/State/Robot.hs#L396

## Demo

    scripts/play.sh -i data/scenarios/Testing/1598-detect-entity-change.yaml --autoplay --speed 1
  • Loading branch information
kostmo authored Mar 15, 2024
1 parent 01ae0e4 commit 02eecba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
19 changes: 17 additions & 2 deletions data/scenarios/Testing/1598-detect-entity-change.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,26 @@ robots:
invisible: true
dir: [1, 0]
program: |
run "scenarios/Testing/_1598-detect-entity-change/setup.sw"
def doUntilCorrect =
herenow <- ishere "dial (G)";
if herenow {
give base "flower";
} {
loc <- whereami;
surveil loc;
wait 1000;
doUntilCorrect;
}
end;
def go =
doUntilCorrect;
end;
go;
inventory:
- [1, flower]
solution: |
wait 2;
move;
move;
swap "dial (G)";
Expand Down
17 changes: 0 additions & 17 deletions data/scenarios/Testing/_1598-detect-entity-change/setup.sw

This file was deleted.

10 changes: 7 additions & 3 deletions src/swarm-lang/Swarm/Language/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,13 @@ constInfo c = case c of
, "Any change to entities at the monitored locations will cause the robot to wake up before the `wait` timeout."
]
Surveil ->
command 1 short . doc (Set.singleton $ Query $ Sensing EntitySensing) "Interrupt `wait` upon (remote) location changes." $
[ "Like `watch`, but with no restriction on distance."
]
command 1 Intangible $
doc
(Set.singleton $ Query $ Sensing EntitySensing)
"Interrupt `wait` upon (remote) location changes."
[ "Like `watch`, but instantaneous and with no restriction on distance."
, "Supply absolute coordinates."
]
Heading -> command 0 Intangible $ shortDoc (Set.singleton $ Query $ Sensing RobotSensing) "Get the current heading."
Blocked -> command 0 Intangible $ shortDoc (Set.singleton $ Query $ Sensing EntitySensing) "See if the robot can move forward."
Scan ->
Expand Down

0 comments on commit 02eecba

Please sign in to comment.