-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
data/scenarios/Testing/2133-robot-function-tracing/00-ORDER.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2133-show-functions.yaml |
50 changes: 50 additions & 0 deletions
50
data/scenarios/Testing/2133-robot-function-tracing/2133-show-functions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
version: 1 | ||
name: Show functions | ||
description: | | ||
Show functions | ||
creative: false | ||
objectives: | ||
- teaser: Follow buddy | ||
goal: | ||
- You and your buddy each have half of a map to a cache of buried treasure. | ||
- | | ||
`give` him your `map piece`{=entity}, which he will use to | ||
locate the `bitcoin`{=entity}, which you must `grab`. | ||
condition: | | ||
as base { | ||
has "bitcoin"; | ||
} | ||
robots: | ||
- name: base | ||
dir: east | ||
devices: | ||
- ADT calculator | ||
- antenna | ||
- branch predictor | ||
- comparator | ||
- compass | ||
- dictionary | ||
- grabber | ||
- hourglass | ||
- logger | ||
- treads | ||
- name: rat | ||
dir: west | ||
system: true | ||
display: | ||
invisible: false | ||
devices: | ||
- logger | ||
program: | | ||
run "data/scenarios/Testing/2133-robot-function-tracing/_2133-show-functions/rat.sw" | ||
known: [bitcoin] | ||
world: | ||
dsl: | | ||
{grass} | ||
palette: | ||
'B': [blank, null, base] | ||
'r': [blank, null, rat] | ||
'.': [blank] | ||
upperleft: [-1, 0] | ||
map: | | ||
B.r |
23 changes: 23 additions & 0 deletions
23
data/scenarios/Testing/2133-robot-function-tracing/_2133-show-functions/rat.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def doWalk = | ||
move; | ||
move; | ||
move; | ||
end; | ||
|
||
def doTurn = | ||
turn left; | ||
end; | ||
|
||
def runSomeFunction = \f. | ||
f; | ||
end; | ||
|
||
def go = | ||
doWalk; | ||
wait 2; | ||
runSomeFunction doTurn; | ||
wait 2; | ||
go; | ||
end; | ||
|
||
go; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,14 @@ import Control.Lens as Lens hiding (Const, distrib, from, parts, use, uses, view | |
import Control.Monad (foldM, forM_, unless, when) | ||
import Data.Functor (void) | ||
import Data.IntMap qualified as IM | ||
import Swarm.Util.RingBuffer qualified as RB | ||
import Data.IntSet qualified as IS | ||
import Data.Map qualified as M | ||
import Data.Maybe (fromMaybe) | ||
import Data.Sequence ((><)) | ||
import Data.Sequence qualified as Seq | ||
import Data.Set (Set) | ||
import Data.Foldable (toList) | ||
import Data.Set qualified as S | ||
import Data.Text (Text) | ||
import Data.Text qualified as T | ||
|
@@ -533,7 +535,32 @@ processImmediateFrame v (SKpair s k) unreliableComputation = do | |
-- | The main CESK machine workhorse. Given a robot, look at its CESK | ||
-- machine state and figure out a single next step. | ||
stepCESK :: (Has (State GameState) sig m, Has (State Robot) sig m, Has (Lift IO) sig m, Has Effect.Time sig m) => CESK -> m CESK | ||
stepCESK cesk = case cesk of | ||
stepCESK cesk = do | ||
|
||
|
||
case cesk of | ||
In t _ _ _ -> evalBuffer @ConcreteRobot %= RB.insert (showT t) | ||
_ -> return () | ||
|
||
case cesk of | ||
In (TApp (TConst _) _) _ _ _ -> do | ||
return () | ||
-- In (TApp t _) _ _ _ -> do | ||
In (TVar t) _ _ _ -> do | ||
let functionsOfInterest = [ | ||
"doWalk" | ||
, "doTurn" | ||
, "runSomeFunction" | ||
, "go" | ||
] | ||
if any (`T.isInfixOf` prettyText t) functionsOfInterest | ||
Check warning on line 556 in src/swarm-engine/Swarm/Game/Step.hs GitHub Actions / HLint
|
||
then do | ||
r <- get @Robot | ||
let xs = r ^. evalBuffer | ||
currentFunction @ConcreteRobot .= Just (T.unlines $ toList $ RB.getValues xs) | ||
else return () | ||
_ -> return () | ||
case cesk of | ||
------------------------------------------------------------ | ||
-- Evaluation | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters