Commit Graph

73 Commits

Author SHA1 Message Date
Brent Yorgey
62470f3513
Split out swarm-doc and swarm-tui sublibraries (#1834)
Split the final remaining default library into `swarm-doc` and `swarm-tui`.  Closes #1043 .
2024-05-11 02:08:49 +00:00
Karl Ostmo
d4982c838e
fix schema renderer (#1823)
Was crashing because `enum` type was not supported.

# Test
```
scripts/gen/schema-docs.sh
```

[New generated doc](ebe28c3a78/data/scenarios/_doc-fragments/SCHEMA.md (directions)) now contains "Directions" enum.
2024-05-06 01:29:16 +00:00
Brent Yorgey
0a001a6fa4
rename doc-fragments to _doc-fragments (#1821)
Recently the test suite started failing for me with an error about not finding an `00-ORDER.txt` file in `doc-fragments`.  I'm not sure why it never failed before, but the reason for the failure is clear enough: any folder under `data/scenarios` which does not start with an underscore is assumed to contain scenarios.
2024-05-05 00:36:23 +00:00
Brent Yorgey
786dea9ff2
Update recipe graph generation to take yields into account (#1814)
I noticed this when regenerating the recipe graph on the wiki and saw that `tea leaves` was sitting there with no input.  `tea leaves` are obtained by harvesting `tea plant`s (which now occur naturally in the world) but we were not taking such "yield" pairs into account when creating the graph.  This PR adds a directed edge for each entity that `yields` another.

The image is already updated on the wiki with the output from this PR:

  https://github.com/swarm-game/swarm/wiki/Recipes-cheat-sheet
2024-04-30 17:10:27 +00:00
Karl Ostmo
d749c5e473
Upload and parse scenarios (#1798)
Towards #1797

Hosts an online repository of scenarios, against which solutions may be submitted.  This is the foundational layer that may support more structured "tournaments", scenario ranking, or other social activity.

# Demo

## Live server

http://swarmgame.net/list-games.html

One can use the [`submit.sh`](https://github.com/swarm-game/swarm/pull/1798/files#diff-450877e3442a0ec1c5cbe964808a263d67f1e680d3aa3c3bf9ae6f51eca682fb) script and see valid uploads reflected live on the website.

## Local testing

### Automated tests

These are database-agnostic.

    scripts/run-tests.sh swarm:test:tournament-host

### Manual tests

These test database interactions.  It requires first setting up a local Postgres server.

1. Start `tournament/scripts/demo/server-native.sh` in one console
2. Run `tournament/scripts/demo/client/test-cases/local/good-submit.sh` in another

# Features

* Upload and validates scenarios
* Download scenarios with solution redacted
* Submit, validate, execute, and score solutions

# Key components

* Servant server
* Hosted on AWS in a Docker container
* Stores to a Postgres database in Amazon RDS
* Shares some code with the integration tests for evaluating scenarios and solutions

The production database uses IAM to manage logins.  The web app uses the AWS API to fetch a "token" which can be used to log in instead of a password.  This avoids having to store a password on the server.

# TODO
- [ ] User authentication (GitHub OpenID?)
2024-04-25 20:11:11 +00:00
Karl Ostmo
f5ecd3fa53
Capability exercise cost (#1777)
Closes #1684
Closes #1262

# Demo

A simple "puzzle" that makes use of consumables:

    scripts/play.sh -i data/scenarios/Testing/1777-capability-cost.yaml --autoplay

Demo of enabled commands and costs display in left pane:

    scripts/play.sh -i data/scenarios/Testing/1262-display-device-commands.yaml

![Screenshot from 2024-03-01 22-39-12](https://github.com/swarm-game/swarm/assets/261693/03fc0e4f-d219-4aa1-8775-cb5112eb0b90)


# In this PR

* Supports specifying capabilities both as plain lists and as maps from capabilities to ingredients in YAML
* JSON Schema support for both capability specification styles
* New integration test
* Removed redundant `tshow` implementation from `Swarm.Doc.Util`

# Entity lookup approaches

The cost of exercising a capability in terms of "ingredients" is specified by the `_entityCapabilities` field within an `Entity` definition.  Each ingredient itself is an entity, specified by name.
For many purposes, having ingredients just of type `EntityName` is sufficient.  But for `Swarm.Game.Recipe.findLacking` in particular, the ingredients list must be actual `Entity` objects, not just names of entities.  So at some point the names need to be looked up in the global entity map to be promoted to `Entity` objects.

The full list of entities is not available at `Entity` parse time to look up an ingredient entity by name, so we cannot store ingredients lists of type `(Count, Entity)` within a parent `Entity` object.

Approaches considered were:

* Store a copy of the `entityMap` in `RobotR`, for use by the `equippedDevices` lens
* Introduce a type parameter to `Entity` representing a "parse phase"
* **Allow a redundant "entity lookup" (and validation) at command execution time**

## Store `entityMap` in `RobotR`

One approach explored was to add a field to `RobotR`:
```
  , _globalEntityMap :: EntityMap
```

This allowed the `equippedDevices` lens implementation to promote the `EntityName`s to `Entity`s when setting the value of the `_robotCapabilities` field.  However, it was rather invasive as it entailed threading the `EntityMap` through many new code paths.

## `Entity` type parameter

Currently, `Entity` has a field:
```
_entityCapabilities :: SingleEntityCapabilities EntityName
```

This would entail a huge refactoring, with:
```
data Entity e = Entity
  ...
  , _entityCapabilities :: SingleEntityCapabilities e
```

At initial parse time we would obtain a list of `Entity EntityName`, but somewhere later during `Scenario` parse time, we can do another pass to obtain `Entity Entity` objects.

This would at least have the advantage of doing the entity lookup/validation on ingredient lists in exactly one place, at parse time.

## Defer `EntityName -> Entity` promotion to command execution time

This is what is implemented in this PR.  The global set of capability costs is validated at scenario parse time.  But it is also redundantly validated in the `payExerciseCost` function, which is not ideal.
2024-04-25 19:39:54 +00:00
Karl Ostmo
326305653d
Refactor hierarchy of state inputs (#1799)
Towards #1797

Combines `TerrainEntityMaps` and `WorldMap` into a single record, `ScenarioInputs`.

Establishes a Matroska-style arrangement of records to represent various scopes of state, eliminating several redundant fields.
2024-04-10 19:02:51 +00:00
Karl Ostmo
936b30d22a
extensible terrain (#1775)
Closes #1641

The `data/terrain.yaml` file is now the authoritative source of terrains, though `BlankT` is still a hard-coded special case.

I have not changed the underlying integer representation of terrain in the world function, which means that the `terrainIndexByName` Map in the `TerrainMap` record is needed for translating between `Int` and `TerrainType`.

# Demo

    scripts/play.sh -i data/scenarios/Testing/1775-custom-terrain.yaml

![Screenshot from 2024-02-22 16-51-53](https://github.com/swarm-game/swarm/assets/261693/1d263c8b-4e9c-40bf-bdc8-bf5ba8e33c4d)

# Changes

* There used to be a function called `integrateScenarioEntities` that combined the `EntityMap` stored in the `Scenario` record with the global entity map.  However, the global entity map is accessible at parse time of the `Scenario`, so we do the combining there and only ever store the combined map in the `Scenario` record.
* JSON Schema for terrain
* Removed the distinction between "World" attributes and "Terrain" attributes
* Unit tests for scenario-defined terrain and related validations
    * Validate existence of referenced terrain at scenario parse time
    * Validate attributes referenced by terrains at parse time
2024-02-29 06:22:21 +00:00
Karl Ostmo
9253b0eb94
decompose scenario record (#1771)
Peripheral to #1715.
2024-02-19 19:53:43 +00:00
Karl Ostmo
30f6f59385
preview rendered world with inotify (#1756)
Opens a live-reloading preview of the world in VS Code.

The renderer has been modified to optionally render a blank image instead of crashing upon invalid YAML.

## Prerequisites:
Install inotify tools:

    sudo apt install inotify-tools

## Usage:

    scripts/preview-world-vscode.sh data/scenarios/Fun/horton.yaml

Once the VS Code editor tabs are opened, one can press <kbd>CTRL</kbd> + <kbd>\\</kbd> (backslash) with the image selected to split the editor pane horizontally.
One may then navigate to the left-pane's copy of the image preview with <kbd>CTRL</kbd> + <kbd>PageUp</kbd>, and then <kbd>CTRL</kbd> + <kbd>w</kbd> will close the redundant image preview.

## Screenshot

![Screenshot from 2024-01-29 18-53-55](https://github.com/swarm-game/swarm/assets/261693/63a4728c-0ccb-4c08-8cde-61d65e8322b4)
2024-01-31 19:23:43 +00:00
Karl Ostmo
a18258c20d
extract scene renderer to its own binary (#1752)
Closes #1715

Extract scene renderer to its own binary with `swarm-scenario` as its only dependency.

This was mainly enabled by moving the `Landscape` sub-record out of the `swarm-engine` sublibrary and into `swarm-scenario`, and refactoring rendering functions to only depend on `Landscape` rather than the entire `GameState`.

# Demo

    stack build --fast swarm:swarm-scene && stack exec swarm-scene -- data/scenarios/Fun/horton.yaml --png -w 180 -h 150

![output](https://github.com/swarm-game/swarm/assets/261693/e2df3aad-3b65-46bf-8485-352facdffc76)
2024-01-29 18:01:56 +00:00
Karl Ostmo
aacdbf3473
Remove Benchmark dependence on AppState and TUI (#1746)
`stack bench` is now independent of the TUI and `AppState`.
2024-01-26 17:56:39 +00:00
Karl Ostmo
669163384e
apply hlint 3.8 suggestions (#1744)
As title
2024-01-26 01:36:13 +00:00
Karl Ostmo
5f53082971
Render command matrix (#1658)
## Demo

1. Run `scripts/play.sh`
2. Load http://localhost:5357/command-matrix.html

The rows are sortable by column.

### Also

    stack build swarm:swarm-docs --fast && stack exec swarm-docs -- cheatsheet --matrix



## Screenshot

![Screenshot from 2024-01-21 21-32-56](https://github.com/swarm-game/swarm/assets/261693/f92f5ac9-8440-4aac-9a4b-9e5edac616f2)
2024-01-26 01:02:14 +00:00
Karl Ostmo
3d87e71939
Use type family for robot CESK machine field (#1729)
Towards #1715 and #1043.

This refactoring step is a prerequisite for #1719 to extricate references to the `CESK` module from the base `RobotR` definition.

In this PR:
* `Swarm.Game.CESK` is imported qualified to more easily track usages
* A new `RobotMachine` type family is added to parameterize the `_machine` field.
* `CESK` is a new parameter to `addTRobot`
2024-01-14 20:11:44 +00:00
Brent Yorgey
ded3c24223
Depend only on vty-crossplatform (#1727)
Closes #1623.

Note that we still have to list both `vty-unix` and `vty-windows` in `stack.yaml` but that's OK; it just means they are both made available as extra dependencies, but only whichever is needed will actually be installed.  In the codebase itself, we now get to avoid CPP on imports, and the code is quite a bit simpler.
2024-01-13 23:47:17 +00:00
Karl Ostmo
47a8ffe115
rename 'portable' to 'pickable' (#1706)
Closes #1695.

Updating occurrences was pretty easy:

    yq --inplace '(.[].properties[] | select(. == "portable")) |= "pickable"' data/entities.yaml

and

    find data/scenarios -type f -name '*.yaml' -print0 | xargs --max-args 1 --null yq --inplace '(select(has("entities")) | .entities[] | select(has("properties")) | .properties[] | select(. == "portable")) |= "pickable"'
2024-01-05 19:58:19 +00:00
Karl Ostmo
1da74a79dd
move ReadableIORef to util sublibrary (#1700)
As title.
2024-01-01 02:29:07 +00:00
Karl Ostmo
f6f01b264c
web sublibrary (#1697)
Towards #1043

Creates a new sub-library for the web service.  Also moved the `Swarm.App` module from the `swarm` library to the `swarm` executable.
2024-01-01 02:06:58 +00:00
Karl Ostmo
b8d37a9364
extract doc generator to separate executable (#1671)
Closes #1443.

Also added `-Wunused-packages` to clean up dependencies.

## Demo

This still works as usual:

    stack run

Output editor keywords:

    stack run swarm-docs -- editors --emacs
2023-12-04 03:45:07 +00:00
Karl Ostmo
01a5b070e7
render map to PNG format (#1632)
Towards #1415.

## Uses

This capability could be used to quickly iterate on DSL world descriptions, e.g. when tuning noise parameters.

## Implementation notes

* For the hard-coded ANSI terminal color names, I chose RGB triples that matched my own terminal settings.  This means that a rendered PNG might not exactly match one's own terminal colors.
* `Blank` terrain corresponds to a transparent pixel.
* Implemented parse-time validation of `attr` references.  Previously, referencing a nonexistent `attr` by an entity would fail silently at runtime.
* Normalization: strings like `"rock"` now only exist once; the string is shared via toplevel variable definitions
* Entities and terrain have TUI-independent color definitions from which VTY Attrs are derived, but all TUI user-interface colors are defined only as VTY Attrs.

## Demos
Each pixel in the output image correponds to one world cell.  To enlarge, can use [imagemagick](https://legacy.imagemagick.org/Usage/resize/#scale):

    stack run -- map data/scenarios/classic.yaml --seed 0 --png -w 300 -h 200 && convert output.png -scale 800% out2.png

![out2](https://github.com/swarm-game/swarm/assets/261693/51794b63-7d78-4738-b20a-8b4f4352f006)

    stack run -- map data/scenarios/Challenges/bridge-building.yaml --png && convert output.png -scale 800% out2.png

![image](https://github.com/swarm-game/swarm/assets/261693/b04895a2-eb61-4499-a122-ae8444f7e4fb)
2023-11-20 04:37:49 +00:00
Karl Ostmo
4e886e0c3c
Autogenerate scenario schema doc (#1441)
Closes #1436.

The schema `.json` files are now the authoritative source of truth for documentation.

Wrote a very simple parser for JsonSchema to extract the documentation from JSON.

Split the README.md into [static](c314cc50a1/data/scenarios/README.md) and [auto-generated](c314cc50a1/data/scenarios/doc-fragments/SCHEMA.md) parts.

Added a custom `"footers"` key to schema files to support inclusion of other markdown files for each object description.

# Schema doc regeneration

    ./scripts/regenerate-schema-docs.sh
2023-10-09 02:11:30 +00:00
Ondřej Šebek
24ef7c21dc
Web API docs improvements (#1529)
* generate Web API endpoint docs in CLI - `swarm generate endpoints`
* use default port in API docs using `renderCurlBasePath`
* fix code rendering in Web API so that the tree nodes try to fit one line
* try adding some API samples
* hand craft `ToJSON Robot` instance to match `FromJSONE` more closely
  * default values are skipped
  * inventory and devices are shortened to names and counts
2023-09-28 11:04:40 +00:00
Karl Ostmo
a9ded587eb
Render map preview on scenario selection screen (#1515)
Closes #353

Also adds a new top-level command to render a scenario map to the console.

Most of the work for this feature entailed identifying the subset of `GameState` that is actually needed for rendering the world, so that the required information can be retrieved from just the `Scenario` rather than having to instantiate an entire `GameState`.

# Potential follow-ups

- [ ] There is some noticeable lag when using the up/down arrow to navigate to any of the largely "procedurally generated" scenarios, e.g. `classic` or `creative`.  May want to do caching of some kind.  The other "challenge scenarios" render without perceptible delay.
- [ ] The heuristic for choosing the view center could be improved, possibly by defining new "hints" as part of the scenario schema.
- [ ] Rendering to the console could be augmented with color.
- [ ] Could render to other image formats like PNG or SVG
- [ ] account for a user-selected seed in the scenario launch parameters dialog

# Demos
## Scenario selection preview
![image](https://github.com/swarm-game/swarm/assets/261693/7c54c6bb-fb02-461f-98a1-06eccbbfc450)

## Command-line map rendering
```
~/github/swarm$ scripts/play.sh map data/scenarios/Challenges/ice-cream.yaml
              
              
              
              
           OO 
▒▒▒ ▒▒▒▒  OOOO
┌─┐▒┌──┐  MMMM
│B   V6│  \ZZ/
└──────┘   \/ 
```

and
```
stack run -- map data/scenarios/Challenges/hackman.yaml
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒••••••••••▒••••••••••▒
▒o▒▒▒•▒▒▒▒•▒•▒▒▒▒•▒▒▒o▒
▒•▒▒▒•▒▒▒▒•▒•▒▒▒▒•▒▒▒•▒
▒•••••••••••••••••••••▒
▒•▒▒▒•▒•▒▒▒▒▒▒▒•▒•▒▒▒•▒
▒•••••▒••••▒••••▒•••••▒
▒▒▒▒▒•▒▒▒▒ ▒ ▒▒▒▒•▒▒▒▒▒
    ▒•▒         ▒•▒    
▒▒▒▒▒•▒ ┌──=──┐ ▒•▒▒▒▒▒
     •  │     │  •     
▒▒▒▒▒•▒ └─────┘ ▒•▒▒▒▒▒
    ▒•▒         ▒•▒    
▒▒▒▒▒•▒ ▒▒▒▒▒▒▒ ▒•▒▒▒▒▒
▒••••••••••▒••••••••••▒
▒•▒▒▒•▒▒▒▒•▒•▒▒▒▒•▒▒▒•▒
▒o••▒•••••••••••••▒••o▒
▒▒▒•▒•▒•▒▒▒▒▒▒▒•▒•▒•▒▒▒
▒•••••▒••••▒••••▒•••••▒
▒•▒▒▒▒▒▒▒▒•▒•▒▒▒▒▒▒▒▒•▒
▒•••••••••••••••••••••▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

```
2023-09-15 06:11:47 +00:00
Ondřej Šebek
2fe7181fc4
Allow specific format width (#1476)
* add option `--width` to `format` CLI
* if width is not specified use terminal width
* if terminal width is unknown, use default (100)

This should help with testing (not so) long layouts like in #1473.
2023-08-28 19:11:26 +00:00
Ondřej Šebek
09f8aee9fc
Make CLI format format (#1459)
- closes #1185
2023-08-26 17:47:17 +00:00
Karl Ostmo
03a5f14694
CLI option to set initial speed (#1255)
When supplying initial code with `--run` or `--autoplay`, a lot can happen in the first few moments of play such that it can be a tricky feat to smash CTRL+z fast enough to slow down the game to observe.

Now, one can pass e.g. `--speed 0` to begin the game at 1 tick per second:

    scripts/play.sh --scenario data/scenarios/Challenges/maypole.yaml --autoplay --speed 0
2023-05-14 04:00:14 +00:00
Brent Yorgey
599225f4d6
Key input handler (#1214)
Ability to code your own input handler routines.  Closes #102 .  Fixes #1210 .

* Adds a new type `key` to represent keypresses
* Adds a primitive function `key : text -> key` which can handle usual letters, numbers, etc. as well as special keys like `"Down"` etc, as well as modifier key prefixes like `key "A-C-Del"`.  `swarm generate keys` generates a list of all recognized special key names.
* New command `installKeyHandler : text -> (key -> cmd unit) -> cmd unit` which sets the "current key handler".  The `text` value is a hint line to display in the secondary key hints menu while the handler is running.  The global shortcut `M-k` toggles the currently installed handler.
* Add a `keyboard` device to provide these commands, as well as a `key` entity (the recipe for a `keyboard` is 16 `key`s + 1 `board`).
* Add a few examples in the `examples` folder.
* Add an installed `keyboard` to the `building-bridges` challenge.
2023-04-25 16:39:59 +00:00
Karl Ostmo
65e3f2b4fa
Dump a list of tutorials and commands they first introduce (#1186)
May be able to reduce likelihood of #1086 by having a autogenerated table of the commands and the tutorials they are introduced in.

This work is related to #1106 in that robot commands should be given distinct markup (backticks).

## Demo

    scripts/play.sh generate pedagogy

**Updated:** See [rendered output](https://gist.github.com/kostmo/d4af3a6814e65fc6d455fd34b41552d3).

## New tests

    scripts/run-tests.sh --test-arguments '--pattern "Pedagogical soundness"'

Note that the test for `crash.yaml` is currently failing because the `Give` command (and some others) are utilized in this tutorial without having been mentioned in the description or in earlier tutorials.

Additionally, the "bug" described in [this comment](https://github.com/swarm-game/swarm/issues/1089#issuecomment-1418497686) **should** be caught by these tests (i.e. fail the tests) since the embedded `solution` code in the YAML file utilizes the `give` command.  That is, if it currently weren't for [this issue](https://github.com/swarm-game/swarm/pull/1186/files#r1152789153).
2023-04-03 14:49:45 +00:00
Karl Ostmo
affc8668b7
remove copyright boilerplate (#1134)
closes #1120
2023-02-27 18:18:46 +00:00
Ondřej Šebek
0f98116088
Add full color mode option (#851)
- closes #815
2022-11-11 23:44:05 +00:00
Ondřej Šebek
451e2ed7f2
Generate other wikis (#769)
- generate wiki for:
  - entities
  - recipes (table and added recipe graph image)
  - capabilities (only table)
- properly parse command line argument for `generate cheatsheet`
- closes #344
2022-10-31 17:03:56 +00:00
Karl Ostmo
5165b576ae
Introduce autoplay flag (#792)
This PR introduces an `--autoplay` flag that causes the solution stored in the `solutions` field of a scenario file (which was selected on the command line via the `--scenario` option) to be automatically run when the game starts, identically to the `--run` option.

The purpose is to:
1. more easily showcase scenarios to the community
2. facilitate a quick a sanity check that the solution text in the yaml file is correct

# Test procedure

    stack run -- --scenario data/scenarios/Tutorials/conditionals.yaml --autoplay

This has the same effect as manually copying the solution stored in `conditionals.yaml` to `myfile.sw`, and then running:

    stack run -- --scenario data/scenarios/Tutorials/conditionals.yaml --run myfile.sw

<a href="https://asciinema.org/a/mGB5VDKhsLLPdrItZWi3qsHUV" target="_blank"><img src="https://asciinema.org/a/mGB5VDKhsLLPdrItZWi3qsHUV.svg" width="640" /></a>
2022-10-28 04:47:18 +00:00
Karl Ostmo
99028f5b64
Elaborate help text for --cheat flag (#791) 2022-10-25 18:31:28 +00:00
Ondřej Šebek
b8956689d9
Move TH GitInfo back to Main (#749)
It is probably safer to have Template Haskell GitInfo in Main and not depend on it in Swarm modules.

Depending on how the build system and TH interact we were either recompiling too often or not often enough.
- if the git info was evaluated once and not again after making a commit, then it was not up to date
- if the git info was reevaluated on every commit then we would needlessly recompile dependent modules

I believe it was only the former, but this helps even in that case (any code change recompiles Main).
2022-10-16 22:17:34 +00:00
Ondřej Šebek
e13dced169
Fallback to XDG data directory (#678)
- when `datadir` is not available, try using the XDG data directory

This way the game can be installed as an executable and data files unpacked to  `~/.local/share/swarm/data`.
Notice that the XDG data folder is  `~/.local/share/swarm`; inside it is the unpacked `data`.

The alternative approach is to use the environment variable `swarm_datadir` and set that to the unpacked data folder.
That works (even after this change) but is not very beginner friendly.

Ideally, we would like to set this in Cabal when building executable, for example to `/usr/share/swarm/<version>`.
Reading through haskell/cabal#5997, it looks like that is not supported.
2022-10-01 20:40:56 +00:00
Brent Yorgey
f003c6773e
A few updates related to speedrunning (#695)
I've updated the Swarm speedrunning wiki page at https://github.com/swarm-game/swarm/wiki/Speedrunning .  Here are a few related cleanups/links.  I'm also planning to fix #694 as part of this PR.
2022-09-25 19:30:18 +00:00
Ondřej Šebek
8366135ae1
Notify user about newer version (#652)
- query GitHub Releases for a new version
- add `swarm version` command
- show the version notification in the main menu
- add a new app-wide logging queue
- show the app-wide logs in the main menu as Messages
- catch and show the web API failure in the Messages
- closes #66
- closes #627
2022-09-06 07:32:24 +00:00
Tristan de Cacqueray
e9fb04691a
Add debug web service (#623)
This change introduce a new web API for the game.
The initial goal is to expose the internal state using the
`/robots` and `/robot/$id` endpoint to query the json representation
of the robots.

A new command line argument is added:
- When `--port 0` is set, the web service is disabled.
- When `--web port` is set, the game won't start if the web service fail to bind the port.
- Otherwise, when `--web` is not set, the service may start on 5357 if the port is available.

Example usage:

```
 swarm --web 5357
 curl localhost:5357/robots | jq
```

Future improvement may include:

- Ability to load program to the base (to send command from external text editor)
- Serve a html interface for alternative visualization
2022-08-06 19:34:23 +00:00
Ondřej Šebek
f2ad1322c9
Generate command table (#531)
Generate table for [Commands Cheat Sheet](https://github.com/swarm-game/swarm/wiki/Commands-Cheat-Sheet) Wiki.

- part of #344
2022-07-04 08:47:55 +00:00
Ondřej Šebek
3872c11509
Generate editor keywords (#526)
- part of #344
2022-07-01 18:44:09 +00:00
Ondřej Šebek
8652440607
Make GHC2021 extensions default (#520)
- closes #419
2022-07-01 09:07:41 +00:00
Ondřej Šebek
9b6eaef37b
Add generator for recipe dependencies (#476)
- add `generate` subparser to the executable
- create a generator for a Graphviz entity dependencies graph
- part of #344 

You can interactively test this with:
```bash
$ cabal run swarm:swarm -- generate recipes \
 | sed -n '/^digraph/,$p' > docs/recipes.dot
$ xdot docs/recipes.dot
```
2022-06-24 21:50:32 +00:00
Brent Yorgey
597d1c6853
require --cheat flag to allow toggling creative mode with m key (#368)
Closes #360.
2022-06-10 00:38:00 +00:00
Brent Yorgey
8961d03a1a
Generalize challenges + classic/creative modes to scenarios (#337)
Generalize challenges + various modes to all be "scenarios" which are described by `.yaml` files in `data/scenarios`.  

- Both challenges and classic/creative modes are now subsumed under the more general notion of "scenarios".
- A scenario describes how to set up the world etc. when starting a game; all scenarios are stored in a `.yaml` file in `data/scenarios`.
- "New game" menu item now lets the user choose a scenario.
- Some small improvements to the way seeds are handled.

See #296.  This will enable #35 and #25 .
2022-06-04 13:20:49 +00:00
Brent Yorgey
d36a89af18
deal gracefully with absence of git repo (#329) 2022-04-29 05:19:04 -05:00
Brent Yorgey
667f001c8b print git branch and hash in --help menu
Not super useful on its own.  This is mostly just to figure out the
`githash` library (which wasn't hard) in initial preparation for #66.
2022-04-27 08:01:45 -05:00
Brent Yorgey
008d4000a5
Add a --run flag to run the contents of a program on startup (#312)
Fixes #82.

Right now it only works in classic mode.  It wouldn't be too hard to
make it work with challenge mode as well, but that would require some
more careful thinking about whether every challenge is required to
have a 'base' and how we identify which robot that is, so that we run
the given file on the right robot.
2022-03-07 05:56:15 -06:00
Brent Yorgey
b1f0e316fd
Challenge mode (#285)
Add a "challenge mode" where the player tries to achieve some specified goal from specific starting conditions.
2022-01-27 17:00:00 -06: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