Commit Graph

28 Commits

Author SHA1 Message Date
Brent Yorgey
5fb85328b0 better tutorial/log screenshot 2022-10-02 15:51:30 -05:00
Brent Yorgey
e58c43e16c put some screenshots in alpha release blog post 2022-10-02 15:45:28 -05:00
Brent Yorgey
8b8c16a71b
switch from U+2591 Light Shade to U+2592 Medium Shade (#449)
Some terminals (*e.g.* `gnome-terminal`) use the character to decide
how dark or light the color should be, rather than showing the
character itself (like *e.g.* `rxvt-unicode`).  Light Shade looks OK
in terminals that display the actual character, but too dark in
terminals that use it as a brightness hint.  Medium Shade seems to
look good (at least, IMO) in both.

See https://github.com/swarm-game/swarm/issues/196#issuecomment-1147298159 .
2022-06-20 17:56:55 +00:00
Brent Yorgey
389e3b7940 progress report blog post 2022-06-20 11:29:14 -05:00
Brent Yorgey
7237a37e65
put base in a 32x32 patch with all necessary starting resources (#412)
Fixes #385 .  Note, we will need to update `TUTORIAL.md` since this changes what world 0 looks like, but I wanted to get some feedback before launching into updating that.
2022-06-17 22:11:02 +00:00
Ondřej Šebek
9a72bc52a5
Reformat codebase with Fourmolu (#370)
Run
```bash
fourmolu -i $(find . -name '*.hs')
```
2022-06-08 22:32:12 +00:00
Brent Yorgey
c8d0c4bd76
Add a main menu shown on startup (#326)
Lots of refining, adding more menu options, etc. that still needs to happen, but this adds a basic menu.  Quitting a game now quits to the menu rather than quitting the entire application.
2022-05-05 13:08:50 -05:00
Brent Yorgey
f80c689e5b check in logo image 2022-03-19 09:51:12 -05:00
Brent Yorgey
b62d27e566
Use a new opaque type for robots instead of strings (#303)
The basic idea of this change is to create a new `robot` type and use it to identify robots instead of `string` names.  Internally, a `robot` value is just a (unique) `Int`. 

Closes #212 .

This ended up turning into a sort of constellation of related changes.

- Add the `robot` type and change the type of various built-in functions which used to take a robot name so they now take a `robot` (`give`, `install`, `reprogram`, `view`, `upload`) and change `build` so it returns a `robot`.
- All internal data structures that store robots are now keyed by a unique (`Int`) robot ID rather than by name.
- Add a `setname` command for setting a robot's display name (which no longer needs to uniquely identify a robot).
- Import a big list of words which we can use to randomly pick names for robots, just for fun.  This is why the diff says "+31,050  -265"; I did not write 31 thousand lines of code.
- Add constants `base`, `parent`, and `self` for getting a `robot` value referring to the base, one's parent, and one's self, respectively.
- Top-level binders like `r <- build {move}` now export a variable binding which can be used in later expressions entered at the REPL; additionally, unlike Haskell, a binder can now appear as the last statement in a block.
- Fix the pretty-printer for `Value` by doubling down on our current strategy of injecting `Value`s back into `Term`s and then pretty-printing the result.  I am now convinced this is the Right Way (tm) to do this; it only required adding a couple additional kinds of `Term` which represent internal results of evaluation and cannot show up in the surface language (`TRef`, `TRobot`).
- Update the tutorial.
- While updating the tutorial, I noticed that #294 had introduced a bug, where the inventory display no longer updated when 0 copies of an entity are added to the inventory (as with `scan` + `upload`), so I fixed that by changing the way inventory hashes are computed.

I tried running the benchmarks both before & after this change.  I was hoping that it might speed things up to be using `IntMap` and `IntSet` instead of looking things up by `Text` keys in a `Map` all the time.  However, if I'm interpreting the results correctly, it seems like it didn't really make all that much difference, at least for the particular benchmarks we have.
2022-03-02 03:00:44 +00:00
Ondřej Šebek
a0e65d9e66
Add vscode editor integration (#255)
- adds `editors` directory
- migrates [xsebek/swarm-vscode](https://github.com/xsebek/swarm-vscode) repo to `editors/`
- updates the highlighting (drill, sum types,...)
- adds some notes how to test and build the extension
- part of #100 
- closes #123
2021-11-11 16:15:17 +00:00
Ondřej Šebek
e5166e31c9
Hide unknown entities with ? (#276)
- closes #49 

**TODO:**
- [x] update TUTORIAL.md
- [x] add a creative mode check
2021-11-07 15:03:20 +00:00
Brent Yorgey
c982e81790
Delay type (#223)
Make explicit in the type system when evaluation of a computation should be delayed.  This gives the user fine-grained control over selective laziness (for example, once we have sum types and recursive types, one could use this to define lazy infinite data structures).  It also allows us to guarantee that certain commands such as `build` and `reprogram` delay evaluation of their arguments, and lets the user e.g. define their own modified versions of `build` without compromising those guarantees.

- Delay is indicated by curly braces both at the value and type levels, that is, if `t : ty` then `{t} : {ty}`.
- `force : {ty} -> ty` is now exposed in the surface language.
- Change from a CEK machine to a CESK machine. Recursive `let` and `def` delay via allocating a cell in the store.  For now, there is no other way to allocate anything in the store, but see discussion at #150 for some possible future directions.
- change the types of `build` and `reprogram` to require a delayed program, e.g. `build : string -> {cmd a} -> cmd string`
- `if` and `try` also require delayed arguments.
- don't elaborate Build and Reprogram with extra Delay wrappers since one is now required by the type
- Division by zero, negative exponents, and bad comparisons now throw exceptions.

Closes #150.  Closes #226.
2021-10-25 13:28:41 +00:00
Brent Yorgey
2b146586d2
Add scrolling for bottom-left info panel and logger device for message logs (#128)
The original main goals of this PR are to (1) solve #36 , that is, make the bottom-left info area fully wrapped and scrollable; and (2) solve #40 , that is, persist the info in that bottom-left info area even when switching to other panels.  In order to address those I ended up making a rather large constellation of related changes, which in the end I hope work well with each other.  Eager to hear others' feedback either from looking at the code or just trying out the game with this PR.

- In order to make the bottom-left area scrollable, split it out into its own panel.  Now we can focus it and then use normal keybindings to scroll it.
- The bottom-left info panel now indicates whether it has additional content scrolled off the top or bottom.
- The bottom-left panel used to display a global list of log/error messages when the inventory was not focused.  So where will those messages be viewable now, if the information displayed in the bottom-left panel persists?  My answer: there is a special `logger` device (#39) which, when focused, now displays the log messages.
    - This means that logs are now per-robot instead of global.
    - The base starts with a `logger` installed.
    - A `log` command can be used to write to a logger.
    - Uncaught exceptions also now write to a logger (instead of using `say`), or are simply discarded if there is no `logger` device installed.
    - The first time a robot's inventory is viewed after a message has been appended to its log, the `logger` device will be automatically focused and the log scrolled all the way to the bottom to show the new entry.  This means that e.g. typing `move` at the REPL will immediately show an exception in the lower left.
- Add a `salvage` command, making it possible to access the log of a dead robot after the fact, once we implement #17 .

There are still a few issues to address which I think can be done in separate PRs:

- The global message log still exists, and the `say` command still appends to it, but there is no way to view it.  Obviously we need to do something with this --- either get rid of it, or figure out a sensible way to view it, etc.
- Exception messages should probably be reformatted to not include any newlines, now that we know they will be wrapped.

Closes #36.  Closes #40.  Closes #39.  Closes #21.
2021-10-08 21:53:16 +00:00
Ondřej Šebek
77c7fd686d
Add seed option to CLI (#170)
- adds CLI option `--seed` and propagates it to `testWorld2` (Closes #14)
- moves the base in the tree shade (Closes #90)
- makes the `random` command depend on initial seed (Closes #13)
2021-10-05 19:43:52 +00:00
Brent Yorgey
d76bc31a58
nicely formatted recipes with ASCII art (#127)
Draw nicely formatted recipes using ASCII art, showing inputs on the left, outputs on the right, and any other required entities at the top, and with the focused entity highlighted in one color, and missing or insufficient ingredients highlighted in a different color.  Thanks to Mark Goadrich for the idea!

Closes #122 .
2021-10-02 20:02:05 +00:00
Brent Yorgey
4320da4d5e upload some images for blog post 2021-10-01 14:23:03 -05:00
Brent Yorgey
1023a63802
add scanner device, scan and upload commands (#106)
Closes #96.

- Delete the `rangefinder` entity.
- A `scanner` now provides the capability to execute `blocked`.
- Add a new direction, `down`, to be used for scanning the current
  cell (i.e. `scan down`).  Can also be used with `drill` in the future.
- `scan` and `upload` commands work as described in #96.

This PR does not implement showing things as question marks, that can
be decided and implemented separately.
2021-09-30 16:38:13 +00:00
Brent Yorgey
23f69a142f Make grab return the name of the thing grabbed
Closes #51.
2021-09-24 10:56:49 -05:00
Brent Yorgey
21d9333149 put images in the right place 2021-09-23 18:40:31 -05:00
Brent Yorgey
2798a3028e display type of the REPL input in top right corner of panel
Also update the tutorial to match.
Closes #34.
2021-09-23 14:23:03 -05:00
Brent Yorgey
d15ac2a8e7 updates to tutorial 2021-09-23 00:00:21 -05:00
Brent Yorgey
6df230ed90 More edits to tutorial. First draft is finished! 2021-09-22 21:42:45 -05:00
Brent Yorgey
97b46653b1 more work on the tutorial 2021-09-22 21:28:58 -05:00
Brent Yorgey
ca0597fd8b add a life support system to the initial base devices 2021-09-22 16:44:41 -05:00
Brent Yorgey
93b4f42c02 fix tutorial images 2021-09-22 11:51:13 -05:00
Brent Yorgey
0f5737cc7b start working on overall design/vision document and tutorial 2021-09-22 11:49:22 -05:00
Brent Yorgey
51dafbbd03 use a more exciting and up-to-date image for the README 2021-09-05 21:40:49 -05:00
Brent Yorgey
67342d5d3d check in a simple representative screenshot 2021-08-29 17:43:52 -05:00