-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
./scripts/play.sh --scenario data/scenarios/Fun/logo-burst.yaml ![image](https://user-images.githubusercontent.com/261693/213022706-9ef7f8dc-03ef-4e84-8772-6ccd5645268f.png)
- Loading branch information
Showing
4 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
GoL.yaml | ||
logo-burst.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,12 @@ | ||
def forever : cmd unit -> cmd unit = \c. c ; forever c end | ||
|
||
def alternate = | ||
wait 50; | ||
say "Green light"; | ||
make "bit (1)"; | ||
wait 100; | ||
say "Red light"; | ||
make "bit (0)"; | ||
end; | ||
|
||
forever alternate; |
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,67 @@ | ||
|
||
def repeat : int -> cmd unit -> cmd unit = | ||
\n. \c. if (n == 0) {} {c ; repeat (n-1) c} | ||
end | ||
def abs = \n. if (n < 0) {-n} {n} end | ||
def elif = \t. \then. \else. {if t then else} end | ||
def else = \t. t end | ||
|
||
def randdir : cmd dir = | ||
d <- random 4; | ||
return ( | ||
if (d == 0) {north} | ||
$ elif (d == 1) {east} | ||
$ elif (d == 2) {south} | ||
$ else {west} | ||
) | ||
end; | ||
|
||
def wander = | ||
d <- randdir; | ||
turn d; | ||
dist <- random 4; | ||
try {repeat dist move} {}; | ||
end; | ||
|
||
def disperse = | ||
r <- robotnamed "stoplight"; | ||
greenLight <- as r {has "bit (1)"}; | ||
if greenLight { | ||
wander; | ||
disperse; | ||
} {}; | ||
end; | ||
|
||
def converge = \loc. \currentLoc. | ||
|
||
let xDist = fst currentLoc - fst loc in | ||
let yDist = snd currentLoc - snd loc in | ||
|
||
if (xDist < 0) { | ||
turn east; | ||
} { | ||
if (xDist > 0) { | ||
turn west; | ||
} {}; | ||
}; | ||
repeat (abs xDist) move; | ||
|
||
if (yDist < 0) { | ||
turn north; | ||
} { | ||
if (yDist > 0) { | ||
turn south; | ||
} {}; | ||
}; | ||
repeat (abs yDist) move; | ||
end; | ||
|
||
def go = \loc. | ||
disperse; | ||
currentLoc <- whereami; | ||
converge loc currentLoc; | ||
go loc; | ||
end; | ||
|
||
loc <- whereami; | ||
go loc; |
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,84 @@ | ||
version: 1 | ||
name: Logo burst | ||
author: Karl Ostmo | ||
description: | | ||
Animate the Swarm logo | ||
creative: false | ||
seed: 0 | ||
robots: | ||
# We include a base robot to stabilize the screen at a fixed position. | ||
- name: base | ||
display: | ||
invisible: true | ||
dir: [1, 0] | ||
devices: | ||
- logger | ||
- hearing aid | ||
- name: botRight | ||
system: true | ||
display: | ||
invisible: false | ||
dir: [1, 0] | ||
program: | | ||
run "scenarios/Fun/_logo-burst/drone.sw" | ||
- name: botUp | ||
system: true | ||
display: | ||
invisible: false | ||
dir: [0, 1] | ||
program: | | ||
run "scenarios/Fun/_logo-burst/drone.sw" | ||
- name: botLeft | ||
system: true | ||
display: | ||
invisible: false | ||
dir: [-1, 0] | ||
program: | | ||
run "scenarios/Fun/_logo-burst/drone.sw" | ||
- name: botDown | ||
system: true | ||
display: | ||
invisible: false | ||
dir: [0, -1] | ||
program: | | ||
run "scenarios/Fun/_logo-burst/drone.sw" | ||
- name: stoplight | ||
system: true | ||
display: | ||
invisible: false | ||
dir: [0, 1] | ||
devices: | ||
- lodestone | ||
inventory: | ||
- [1, bit (0)] | ||
program: | | ||
run "scenarios/Fun/_logo-burst/coordinator.sw" | ||
known: [boulder, tree, water, wavy water] | ||
world: | ||
default: [blank] | ||
upperleft: [0, 0] | ||
offset: false | ||
palette: | ||
'Ω': [blank, null, base] | ||
's': [blank, null, stoplight] | ||
'.': [blank] | ||
' ': [blank] | ||
'@': [blank, boulder] | ||
'T': [blank, tree] | ||
'▒': [blank, water] | ||
'~': [blank, wavy water] | ||
'>': [blank, null, botRight] | ||
'^': [blank, null, botUp] | ||
'<': [blank, null, botLeft] | ||
'v': [blank, null, botDown] | ||
map: | | ||
s v . | ||
. . | ||
. v<^vv<<@ ^^ vv >^v^T ^^^v< <>< v > | ||
T ^< >^ < >> v> v< >T <v> <<▒^ @><> . | ||
. <@v^^>> @v > <T <v<T<Ω^> v><v< << <<T^ v< . | ||
. > >> v@ @@> << ~v < >~ ^~ >> @^ >v . | ||
. >>^v^^^ < ~ T~v v< <~ >>T <v vv ▒> . | ||
. ▒ . | ||
. ^ ^ v > > . |