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

World description DSL #1376

Merged
merged 105 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
76cd623
fix documentation
byorgey Jun 13, 2023
e126c57
early draft of world description DSL
byorgey Jun 13, 2023
4a949dd
fiddling around with intrinsically typed EDSL for world functions
byorgey Jun 19, 2023
d0f7e8b
more work on intrinsically typed DSL
byorgey Jun 20, 2023
a452d88
buncha work on world DSL
byorgey Jun 21, 2023
f82a130
bit more work + notes for later
byorgey Jun 21, 2023
01e2b3d
fix syntax error
byorgey Jun 21, 2023
978c8d7
working on subtyping and inference
byorgey Jun 22, 2023
518246a
work on inference, delete old code
byorgey Jun 25, 2023
eb2f9ab
Merge branch 'main' into feature/world-dsl
byorgey Jun 27, 2023
e96c194
great progress!
byorgey Jun 28, 2023
27cae70
copy in code for compiling to combinators
byorgey Jun 28, 2023
5d2763a
more work on inference (let, overlay)
byorgey Jun 29, 2023
069eebf
wibbles
byorgey Jun 29, 2023
4eca03d
split into modules
byorgey Jul 7, 2023
7530766
fix for recent GHCs
byorgey Jul 7, 2023
15626de
basic parser for cell values
byorgey Jul 7, 2023
c1a45de
WIP
byorgey Jul 7, 2023
89ad0d5
work on world DSL parser
byorgey Jul 14, 2023
35a8c08
get basic world described with DSL program working!
byorgey Jul 15, 2023
7a9a796
error framework, get overlay working
byorgey Jul 17, 2023
5445c69
start to get testWorld2 DSL description working
byorgey Jul 17, 2023
2550a6e
get two more biomes working (add `hash`, `abs`)
byorgey Jul 17, 2023
a583ccd
finish transcribing test world 2 to DSL
byorgey Jul 17, 2023
ac41297
delete dead code
byorgey Jul 17, 2023
3ecdac8
get world offset working for DSL worlds
byorgey Jul 17, 2023
60dc12e
blank world can use the DSL!
byorgey Jul 17, 2023
7a0ff43
classic mode can use the DSL!
byorgey Jul 17, 2023
5e2163a
more flexible cell syntax
byorgey Jul 17, 2023
4f81b7c
rename test file
byorgey Jul 17, 2023
f5cb71d
fix cell parser
byorgey Jul 17, 2023
889215d
update todos
byorgey Jul 17, 2023
ab8846d
move todos to PR description
byorgey Jul 17, 2023
7ab4c72
add `Semigroup` and `Monoid` instances for `TerrainType`
byorgey Jul 18, 2023
05b4771
interpret BTerms for comparison
byorgey Jul 20, 2023
1fe06b1
Merge branch 'main' into feature/world-dsl
byorgey Jul 20, 2023
f0078cd
fix merge
byorgey Jul 20, 2023
95386c7
store world DSL expressions in `worlds/*.world` + enable import
byorgey Jul 21, 2023
5b6ad5c
update all "classic world" scenarios to import `worlds/classic.world`
byorgey Jul 21, 2023
2d6818c
fix warnings
byorgey Jul 21, 2023
071dfe1
Merge branch 'main' into feature/world-dsl
byorgey Jul 21, 2023
2cad10c
get rid of `testWorld2` + make blank world default
byorgey Jul 21, 2023
964dc2b
WIP: do away with default, make `WorldFun` a `Monoid`
byorgey Jul 21, 2023
5902494
get `Erasable` to work for specifying cells in palette
byorgey Jul 21, 2023
268d773
fix type errors, and get rid of `default` for good
byorgey Jul 21, 2023
038ed2a
update comment and remove dead code
byorgey Jul 21, 2023
bae128f
rename `Swarm.WorldGen` -> `Swarm.World.Gen`
byorgey Jul 21, 2023
eac4dc3
wibble
byorgey Jul 21, 2023
ed0666b
extract entities in classic world automatically
byorgey Jul 22, 2023
0794262
fix missing `interpConst` case
byorgey Jul 22, 2023
2f3a5cb
use `NotFun` to get rid of pattern-match warnings
byorgey Jul 23, 2023
c4aabb2
split out `Abstract` and `Interpret`, implement rotate + reflect
byorgey Jul 23, 2023
e5e4941
reorganization and a bunch of documentation
byorgey Jul 24, 2023
8b10fff
more cleanup, implement compiling for reflect + rot
byorgey Jul 24, 2023
4390159
more documentation + comments
byorgey Jul 24, 2023
54f8e19
link TODOs to issues
byorgey Jul 27, 2023
c32aa12
Merge branch 'main' into feature/world-dsl
byorgey Jul 27, 2023
5a6a195
work on fixing up merge (WIP)
byorgey Jul 27, 2023
a13e9a0
finish fixing up merge
byorgey Jul 27, 2023
130835c
remove redundant import
byorgey Jul 27, 2023
f473fbf
turn XXX into TODO with issue reference
byorgey Jul 27, 2023
728f71c
WIP: move typechecking for world DSL terms earlier, during JSON parsing
byorgey Jul 27, 2023
93a27c8
fix tests
byorgey Jul 27, 2023
3d08b92
remove dead cod
byorgey Jul 27, 2023
cc585c3
fix warning
byorgey Jul 27, 2023
7b1f0bb
fix benchmark
byorgey Jul 27, 2023
9336924
enable `TypeFamilies`, needed for older GHC versions
byorgey Jul 27, 2023
d4e15d1
add notes to XXX comments
byorgey Jul 27, 2023
76dfddf
add `GADTs` extension for GHC <= 9.2
byorgey Jul 27, 2023
c31b85d
fix more warnings / add needed extensions for older GHC
byorgey Jul 27, 2023
72e5178
address some review comments
byorgey Jul 27, 2023
827ba36
Restyled by fourmolu (#1398)
restyled-io[bot] Jul 27, 2023
76a8075
clean up and start working on type errors + pretty-printing
byorgey Jul 27, 2023
affaa99
Merge branch 'feature/world-dsl' of github.com:swarm-game/swarm into …
byorgey Jul 27, 2023
1cd417a
type errors
byorgey Jul 28, 2023
65d4dd0
PrettyPrec instance for Cell
byorgey Jul 28, 2023
6610d4a
require entire DSL term to be parsed
byorgey Jul 28, 2023
26b3060
turn `prettyCheckErr` into `PrettyPrec` instance
byorgey Jul 28, 2023
ee6e415
rename `WExpMap` to `WorldMap`
byorgey Jul 28, 2023
32c12a6
rename `runTTerm` -> `runWorld`
byorgey Jul 28, 2023
0ac5934
Merge branch 'main' into feature/world-dsl
byorgey Aug 7, 2023
4cc7f3b
finish merge
byorgey Aug 8, 2023
6540900
Merge branch 'main' into feature/world-dsl
byorgey Aug 9, 2023
69e8e5f
fix formatting
byorgey Aug 9, 2023
9226b48
world DSL tests
byorgey Aug 9, 2023
7f7a95a
add override test to 00-ORDER.txt
byorgey Aug 9, 2023
a36b58e
move world loading code into `Swarm.Game.World.Load`
byorgey Aug 9, 2023
13d2827
improve `rotTuple` implementation
byorgey Aug 9, 2023
4725801
add some comments
byorgey Aug 9, 2023
5452801
delete empty file
byorgey Aug 9, 2023
6a98dca
use `ignoreWarnings`
byorgey Aug 9, 2023
f5b3882
link to blog post with more info
byorgey Aug 9, 2023
c3db0ba
add Haddock comment
byorgey Aug 9, 2023
f0095be
improve Haddocks
byorgey Aug 9, 2023
4957aec
add some explanatory comments to `classic.world`
byorgey Aug 13, 2023
2dc91ce
Update src/Swarm/Util/Erasable.hs
byorgey Aug 13, 2023
f14bb1b
fix flag in README
byorgey Aug 13, 2023
f67fa49
mention 'seed' variable
byorgey Aug 13, 2023
d7631f8
update scenario authoring guide to mention world DSL
byorgey Aug 13, 2023
d765208
add README re: world DSL
byorgey Aug 13, 2023
351db28
simplify implementation of `runCTerm`
byorgey Aug 16, 2023
5c691f9
allow whitespace before world DSL terms!
byorgey Aug 16, 2023
e2b46a9
fix redundant import warning
byorgey Aug 16, 2023
7ef049c
add reminder to update `worlds/README` when modifying parser
byorgey Aug 16, 2023
08ac9c2
Merge branch 'main' into feature/world-dsl
mergify[bot] Aug 17, 2023
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
3 changes: 2 additions & 1 deletion bench/Benchmark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Swarm.Language.Pipeline (ProcessedTerm)
import Swarm.Language.Pipeline.QQ (tmQ)
import Swarm.TUI.Model (gameState)
import Swarm.TUI.Model.StateUpdate (classicGame0)
import Swarm.Util.Erasable

-- | The program of a robot that does nothing.
idleProgram :: ProcessedTerm
Expand Down Expand Up @@ -87,7 +88,7 @@ mkGameState robotMaker numRobots = do
(mapM addTRobot robots)
( (initAppState ^. gameState)
& creativeMode .~ True
& multiWorld .~ M.singleton DefaultRootSubworld (newWorld (WF $ const (fromEnum DirtT, Nothing)))
& multiWorld .~ M.singleton DefaultRootSubworld (newWorld (WF $ const (fromEnum DirtT, ENothing)))
)

-- | Runs numGameTicks ticks of the game.
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/2048.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ robots:
- [1, "1"]
known: [water, wavy water, flower, tree]
world:
default: [stone]
dsl: |
{stone}
palette:
"Ω": [grass, null, base]
"┌": [stone, upper left corner]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/Mazes/easy_cave_maze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ entities:
- The place you're trying to reach! You win by executing `grab` on this item.
properties: [known, portable]
world:
default: [ice]
dsl: |
{ice}
palette:
'Ω': [stone, null, base]
' ': [stone, null]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/Mazes/easy_spiral_maze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ entities:
- The place you're trying to reach! You win by executing `grab` on this item.
properties: [known, portable]
world:
default: [ice]
dsl: |
{ice}
palette:
'Ω': [stone, null, base]
' ': [stone, null]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/Mazes/invisible_maze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ entities:
- The place you're trying to reach! You win by executing `grab` on this item.
properties: [known, portable]
world:
default: [grass]
dsl: |
{grass}
palette:
'Ω': [grass, null, base]
'.': [grass, null]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/Mazes/loopy_maze.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ entities:
- The place you're trying to reach! You win by executing `grab` on this item.
properties: [known, portable]
world:
default: [grass]
dsl: |
{grass}
palette:
'Ω': [grass, null, base]
'.': [grass, null]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/Ranching/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ entities:
properties: [known]
known: [flower, tree]
world:
default: [grass]
dsl: |
{grass}
upperleft: [0, 0]
offset: false
palette:
Expand Down
9 changes: 5 additions & 4 deletions data/scenarios/Challenges/Ranching/gated-paddock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,15 @@ seed: 0
solution: |
run "scenarios/Challenges/Ranching/_gated-paddock/fence-construction.sw"
world:
default: [dirt, water]
dsl: |
{dirt, water}
palette:
'B': [grass, null, base]
'.': [grass]
'B': [grass, erase, base]
'.': [grass, erase]
't': [dirt, tree]
'x': [stone, mountain]
'c': [stone, cabin]
's': [grass, null, sheep]
's': [grass, erase, sheep]
'%': [grass, clover, null]
'H': [stone, pier, null]
'~': [dirt, water]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/Ranching/powerset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ entities:
properties: [known, growable, portable]
known: [sand]
world:
default: [grass]
dsl: |
{grass}
upperleft: [-1, -1]
offset: false
palette:
Expand Down
5 changes: 3 additions & 2 deletions data/scenarios/Challenges/Sliding Puzzles/3x3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,8 @@ recipes:
time: 0
known: []
world:
default: [grass]
dsl: |
{grass}
upperleft: [-3, 2]
offset: false
palette:
Expand All @@ -739,4 +740,4 @@ world:
..x....x..........
..xxxxxx..........
..................
zy................
zy................
7 changes: 4 additions & 3 deletions data/scenarios/Challenges/Sokoban/Gadgets/no-reverse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ entities:
properties: [known, unwalkable, portable]
known: [mountain, water, flower]
world:
default: [grass, water]
dsl: |
{grass, water}
upperleft: [-1, 1]
offset: false
palette:
'B': [grass, null, base]
'.': [grass]
'B': [grass, erase, base]
'.': [grass, erase]
'@': [grass, monolith]
'A': [grass, mountain]
'*': [grass, flower]
Expand Down
7 changes: 4 additions & 3 deletions data/scenarios/Challenges/Sokoban/Gadgets/one-way.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ entities:
properties: [known, unwalkable, portable]
known: [mountain, water, flower]
world:
default: [grass, water]
dsl: |
{grass, water}
upperleft: [-1, 1]
offset: false
palette:
'B': [grass, null, base]
'.': [grass]
'B': [grass, erase, base]
'.': [grass, erase]
'@': [grass, monolith]
'A': [grass, mountain]
'*': [grass, flower]
Expand Down
9 changes: 5 additions & 4 deletions data/scenarios/Challenges/Sokoban/Simple/trapdoor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ entities:
properties: [known, unwalkable, portable]
known: [mountain, water, flower]
world:
default: [grass, water]
dsl: |
{grass, water}
upperleft: [-1, 1]
offset: false
palette:
'B': [ice, null, base]
'.': [grass]
'x': [dirt]
'B': [ice, erase, base]
'.': [grass, erase]
'x': [dirt, erase]
'@': [grass, monolith]
'A': [grass, mountain]
'*': [grass, flower]
Expand Down
11 changes: 6 additions & 5 deletions data/scenarios/Challenges/Sokoban/foresight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,22 @@ entities:
properties: [known, unwalkable]
known: [mountain, water, 3D printer, flower]
world:
default: [grass, water]
dsl: |
{grass, water}
upperleft: [-21, 10]
offset: false
palette:
'B': [ice, null, base]
'.': [grass]
'B': [ice, erase, base]
'.': [grass, erase]
'*': [grass, flower]
'b': [grass, boat]
'3': [grass, 3D printer]
'@': [grass, monolith]
'c': [grass, crate]
'A': [grass, wall]
'w': [dirt, water]
'x': [stone]
'z': [dirt]
'x': [stone, erase]
'z': [dirt, erase]
map: |
..................3...A.
.................AAAA.A*
Expand Down
5 changes: 3 additions & 2 deletions data/scenarios/Challenges/arbitrage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ recipes:
- [1, drill]
known: []
world:
default: [dirt]
dsl: |
{dirt}
upperleft: [0, 0]
offset: false
palette:
Expand Down Expand Up @@ -413,4 +414,4 @@ world:
...X****7****1...
........*........
B....p.p.p.p.p...
/.............../
/.............../
17 changes: 9 additions & 8 deletions data/scenarios/Challenges/blender.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,23 @@ recipes:
known: [water]
seed: 0
world:
default: [stone, water]
dsl: |
{stone, water}
upperleft: [0, 0]
offset: false
palette:
'0': [stone, water]
'@': [stone, granite boulder]
'.': [grass]
'L': [stone]
'.': [grass, erase]
'L': [stone, erase]
'>': [stone, bind gt]
'=': [stone, bind eq]
H: [dirt]
H: [dirt, erase]
A: [grass, water, ccw_robot]
a: [grass, water, ccw_robot_down]
B: [grass, null, cw_robot]
b: [grass, null, cw_robot_down]
Ω: [grass, null, base]
B: [grass, erase, cw_robot]
b: [grass, erase, cw_robot_down]
Ω: [grass, erase, base]
f: [stone, Amulet of Yoneda]
x: [stone, locked door]
k: [grass, door key]
Expand All @@ -225,4 +226,4 @@ world:
..@@@@@@@@@.@@@@@@@.@@@@@@@.@..
..Ω.........@.....@.........@..
@@@@@@@@@@@@@.>>=.@@@@@@@@@@@..
...............................
...............................
1 change: 0 additions & 1 deletion data/scenarios/Challenges/bridge-building.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ recipes:
known: [water, sand, flower, iron mine]
seed: 0
world:
default: [blank]
palette:
'.': [blank]
'/': [blank, left roof]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/bucket-brigade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ recipes:
known: [boulder, lignite mine]
seed: 0
world:
default: [grass]
dsl: |
{grass}
palette:
'B': [dirt, null, base]
'.': [dirt]
Expand Down
7 changes: 4 additions & 3 deletions data/scenarios/Challenges/chess_horse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ robots:
char: '♚'
known: [water]
world:
default: [ice, water]
dsl: |
{ice, water}
palette:
'.': [grass]
'#': [ice]
'.': [grass, erase]
'#': [ice, erase]
'┌': [stone, upper left corner]
'┐': [stone, upper right corner]
'└': [stone, lower left corner]
Expand Down
3 changes: 1 addition & 2 deletions data/scenarios/Challenges/hackman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ solution:
known: []
seed: 0
world:
default: [blank]
palette:
'B': [blank]
'Ω': [blank, null, base]
Expand Down Expand Up @@ -307,4 +306,4 @@ world:
x.....x....x....x.....x
x.xxxxxxxx.x.xxxxxxxx.x
x.....................x
xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/hanoi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ known:
- blocked two
- blocked three
world:
default: [grass, null]
dsl: |
{grass}
palette:
',': [grass]
'_': [stone]
Expand Down
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/ice-cream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ recipes:
- [1, scoop]
known: []
world:
default: [grass]
dsl: |
{grass}
upperleft: [0, 0]
offset: false
palette:
Expand Down
3 changes: 1 addition & 2 deletions data/scenarios/Challenges/lights-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ recipes:
time: 0
known: []
world:
default: [blank]
upperleft: [-1, 1]
offset: false
palette:
Expand All @@ -160,4 +159,4 @@ world:
.xxxxx.
.xxxxx.
z......


3 changes: 2 additions & 1 deletion data/scenarios/Challenges/maypole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ entities:
properties: [known, unwalkable]
known: [bitcoin]
world:
default: [grass]
dsl: |
{grass}
upperleft: [0, 0]
offset: false
palette:
Expand Down
7 changes: 4 additions & 3 deletions data/scenarios/Challenges/teleport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ robots:
);
known: [water, wavy water, flower, tree]
world:
default: [ice, water]
dsl: |
{ice, water}
palette:
',': [ice, water]
' ': [ice, water]
'~': [ice, wavy water]
'*': [grass, flower]
'T': [grass, tree]
'.': [grass]
'_': [stone]
'.': [grass, erase]
'_': [stone, erase]
'┌': [stone, upper left corner]
'┐': [stone, upper right corner]
'└': [stone, lower left corner]
Expand Down
3 changes: 1 addition & 2 deletions data/scenarios/Challenges/wolf-goat-cabbage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ entities:
known: [water, boulder]
seed: 0
world:
default: [blank]
palette:
'A': [stone, boulder]
'B': [stone, boulder, base]
Expand All @@ -122,4 +121,4 @@ world:
AAA~~~~~~~~~~~~~~~AAA
AAAAA~~~~~~~~~~~AAAAA
AAAAAAAA~~~~~AAAAAAAA
AAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAA
3 changes: 2 additions & 1 deletion data/scenarios/Challenges/word-search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ recipes:
- [1, highlighter]
known: [boulder]
world:
default: [dirt]
dsl: |
{dirt}
upperleft: [0, 0]
offset: false
palette:
Expand Down
Loading
Loading