Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make halted robots immediately wake up #2254

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading