Skip to content

Commit

Permalink
make halted robots immediately wake up
Browse files Browse the repository at this point in the history
  • Loading branch information
byorgey committed Jan 3, 2025
1 parent c3a83b1 commit b03a19d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/scenarios/Testing/00-ORDER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ Achievements
2086-structure-palette.yaml
2239-custom-entity.yaml
2240-overridden-entity-capabilities.yaml
2253-halt-waiting.yaml
27 changes: 27 additions & 0 deletions data/scenarios/Testing/2253-halt-waiting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 1
name: Halt a waiting robot
description: |
Calling `halt` on a waiting robot should make it immediately idle,
so it can e.g. be `reprogram`med
creative: true
objectives:
- goal:
- Get some gold
condition: |
as base { has "gold" };
robots:
- name: base
dir: north
devices:
- logger
solution: |
r <- build {move; wait 10000};
wait 2;
halt r; wait 1; reprogram r {create "gold"; give base "gold"}
world:
dsl: |
{grass}
palette:
'B': [grass, null, base]
map: |
B
5 changes: 3 additions & 2 deletions src/swarm-engine/Swarm/Game/Step/Const.hs
Original file line number Diff line number Diff line change
Expand Up @@ -893,9 +893,10 @@ execConst runChildProg c vs s k = do
omni <- isPrivilegedBot
case omni || not (target ^. systemRobot) of
True -> zoomRobots $ do
-- Cancel its CESK machine, and put it to sleep.
-- Cancel its CESK machine, and wake it up to ensure
-- it can do cleanup + run to completion.
robotMap . at targetID . _Just . machine %= cancel
sleepForever targetID
activateRobot targetID
return $ mkReturn ()
False -> throwError $ cmdExn c ["You are not authorized to halt that robot."]
_ -> badConst
Expand Down
1 change: 1 addition & 0 deletions test/integration/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ testScenarioSolutions rs ui key =
assertBool "Error message should mention tank treads but not treads" $
not (any ("- treads" `T.isInfixOf`) msgs)
&& any ("- tank treads" `T.isInfixOf`) msgs
, testSolution Default "Testing/2253-halt-waiting"
]
where
-- expectFailIf :: Bool -> String -> TestTree -> TestTree
Expand Down

0 comments on commit b03a19d

Please sign in to comment.