Skip to content

Commit e73d271

Browse files
committed
Add script to post gliders from the command line for testing
1 parent ce919a3 commit e73d271

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

script/post_glider_at

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
# Posts a glider pattern at the specified world location using curl
4+
#
5+
# Usage: ./script/post_glider_at <tick> <x> <y>
6+
#
7+
# To post multiple gliders in parallel, using '&' in bash. e.g.:
8+
#
9+
# ./script/post_glider_at 100 15 15& ./script/post_glider_at 100 50 25
10+
#
11+
12+
TICK=$1
13+
X=$2
14+
Y=$3
15+
16+
function cell() {
17+
local CX=$1
18+
local CY=$2
19+
echo "{\"point\": [$(($X + $CX)), $(($Y + $CY))], \"alive\": true}"
20+
}
21+
22+
GLIDER="{\"tick\": $TICK, \"cells\": [$(cell 1 0), $(cell 2 1), $(cell 0 2), $(cell 1 2), $(cell 2 2)]}"
23+
24+
curl -d "$GLIDER" http://localhost:8000/world

0 commit comments

Comments
 (0)