Commit Graph

768 Commits

Author SHA1 Message Date
Ondřej Šebek
14c5bdbd04 Move HLint to GHC 8.10.7 in CI
The version check only cares about 8/9
and HLint has some trouble installing
in 9.2, so this avoids it for now.
2022-06-09 01:29:05 +02:00
Ondřej Šebek
dabcb21608 Update stack resolver 2022-06-09 01:29:05 +02:00
Ondřej Šebek
ff9ec66711 Add ci flag to CI
- set -Werror in CI
- fix GHC 9.2 warning about TH looking syntax ($e)
2022-06-09 01:29:05 +02:00
Ondřej Šebek
94c876a01a Add GHC 9.2.3 to CI 2022-06-09 01:29:05 +02:00
Brent Yorgey
69929f1b61 Bump dependency bounds
- bump upper bounds on dependencies
- remove special th-extras and depedent-sum deps
- fix problems with new opaque types in Aeson
2022-06-09 01:29:05 +02:00
Ondřej Šebek
b67a0f3ef4
Enable HLint in CI (#371)
- uncomment HLint configuration in Haskell-CI config
- remove unused pragmas
- remove some unnecessary parens
2022-06-08 22:40:29 +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
128a15ebe8
skip menu and default to classic mode if --run or --seed is given (#364)
Closes #363.  Also addresses the issue discussed in #359 .
2022-06-06 12:23:34 +00:00
Brent Yorgey
7b4ffccb9d
add sand, glass, and calculator (#362)
- Sand is now found near water.  Sand regenerates immediately (like water).
- Sand can be used in a furnace to make glass.
- Glass + copper wires + 3D printer can be used to make solar panels.
    - Note that with #361 I intend to start the base with a small number of 3D printers, so other robots could carry this out.  But also, the base will start with a bunch of solar panels too.
- Solar panel + counter can be used to make a calculator.
2022-06-06 12:17:46 +00:00
Brent Yorgey
ee857a5d21
upgrade to brick-0.69 (#365)
Closes #340.
2022-06-04 22:59:18 -05:00
Ondřej Šebek
161f510f15
Find robots (#339)
* add robotNamed : string -> cmd robot
* add chess knight challenge

In challenges, it's impossible to access the robot
by its assigned number. We do however name it.
Seems reasonable to add a way to get robot by its name.
2022-06-05 00:29:06 +02:00
Ondřej Šebek
7ad65ad00a
Update Github Actions and fix Doctest (#352)
* Fix doctests

* Regenerate haskell-ci with config

- use latest haskell-ci
- configure haskell-ci to use doctest

* Update tested with compiler

- update cabal tested-with field
- update .mergify.yaml to new compiler
  - restore note about mergify in haskell-ci
2022-06-04 15:04:26 -05:00
Brent Yorgey
8578a5675a update tutorial to match changes to the way game is started 2022-06-04 13:56:01 -05:00
Brent Yorgey
3ab402a810 link to the web tutorial from the Tutorial menu 2022-06-04 13:40:01 -05:00
Brent Yorgey
b381bf8272 update README to reflect latest changes 2022-06-04 13:36:45 -05: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
Ondřej Šebek
a6715e4bbd
Make only base display as Omega (#338)
- make robots look down as 'X'

With base not having any direction
specific characters this just finishes
the job and makes it fully distinct.
2022-05-24 13:48:36 -05:00
Brent Yorgey
42f99435c8 move get closer to where it is used 2022-05-21 15:50:59 -05:00
Brent Yorgey
985a433ed3
Pop up entity description on Enter (#335)
Hitting `Enter` on an inventory item pops up a dialog box with its description.  For items with longer descriptions this is a convenient way to be able to see the whole description without having to scroll the info box in the lower left.

`Enter` used to try to `make` the focused item; that is now accomplished with `m`.
2022-05-21 15:48:54 -05:00
Brent Yorgey
518e5bae1c clear confirmation when quitting
The confirmation modal dialog for quitting used to still be there
after quitting then starting a new game.
2022-05-05 13:18:11 -05: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
bc137386a8
ignore non-top-level VResults (#330)
Fixes #327.
2022-04-30 15:29:21 -05:00
Brent Yorgey
a6e2edbeba
Make the salvage command take one tick to transfer each item (#317)
I initially thought this would be tricky, but it's not: all we need to
do is reprogram the salvaged robot to give the salvaging robot one
item at a time.

Closes #202.
2022-04-29 15:18:37 -05: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
68d19c1ec2 Don't reset store when executing run command
Fixes #299.
2022-04-16 09:12:17 -05:00
Brent Yorgey
d4aed91997
Add a dialog box to confirm quit (#320)
Closes #77 .  When hitting Ctrl-Q, now a dialog box opens up allowing you to confirm you want to quit or cancel.  The machinery for dealing with pop-up windows is somewhat generalized as well, which should make it easy to add other similar pop-up windows as needed in the future.
2022-03-30 06:39:37 +00:00
Alexander Block
7d2339fdb0
make it impossible to destroy base (#318)
It is now impossible to destroy `base`. In `Step.hs` we now always check whether the current robot is `base` (by checking whether its `robotID` is 0) before the `selfDestruct` flag is set. If it is `base` a `CmdFailed` exception is thrown instead.

This resolves #297 .
2022-03-22 14:59:54 +00:00
Brent Yorgey
b1e2c59b85 create feedback.yaml file
For use with https://github.com/NorfairKing/feedback .
2022-03-19 11:08:35 -05:00
Brent Yorgey
f80c689e5b check in logo image 2022-03-19 09:51:12 -05:00
Brent Yorgey
dbe1574ed9
add built-in 'error' and 'undefined' (#315)
Closes #161.
2022-03-18 17:07:47 +00:00
Brent Yorgey
841db9bac1 update description of modes in README 2022-03-15 21:00:35 -05:00
Brent Yorgey
4a600fa788 update URL repo references from byorgey/swarm to swarm-game/swarm 2022-03-14 14:09:47 -05:00
noahyor
1cf4abd7d3
Add boolean operations like && and || (#307)
Closes #189.
2022-03-11 19:32:54 +00: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
a78369d7e6
Track whether robots have an ID number or not at the type level (#311)
See the discussion at
https://github.com/byorgey/swarm/pull/303#discussion_r817471340 .
This seems like an unqualified success: no more hacky (-1)'s, and
doing the refactoring actually uncovered a bug!  Previously, we were
not actually assigning ID's to the robots that were read as part of a
challenge.  This means that in a challenge with multiple robots, all
but one of them would instantly disappear since they all shared the
same ID number.
2022-03-06 16:06:51 -06:00
Brent Yorgey
242376d294 Fix Mergify config
Convert deprecated `commit_message` attribute to
`commit_message_template`.  See https://docs.mergify.com/actions/merge/#defining-the-commit-message
2022-03-01 21:02:58 -06: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
noahyor
47e1e7d074
Hide zero inventory (#301)
Add a `0` key that toggles whether entities with count 0 are shown in the inventory.  Closes #282.
2022-02-19 07:40:28 -06:00
noahyor
ceaa949455
Make seed robots self-destruct when an exception is raised (#298)
I have added a try statement on line 551 of Step.hs to self-destruct even if place command is obstructed.
2022-01-29 21:21:35 +00: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
Brent Yorgey
b267441403 Merge branch 'main' of github.com:byorgey/swarm 2022-01-24 21:43:30 -06:00
Brent Yorgey
74ea395c83
homomorphic hashing for inventories (#294)
The hash for an inventory is now the sum of the hashes of its contents. As discussed in #229 , the point of this is that inventory hashes can now be maintained incrementally, which could be a big win if there are robots with big inventories. It is less "secure" but we don't really care about that.

Closes #229.
2022-01-24 17:43:34 -06:00
Brent Yorgey
875da9674f ignore some files 2022-01-22 15:46:52 -06:00
Brent Yorgey
f6a1931b23 parse and pretty-print tuples properly
Tuples are now parsed as parens containing terms separated by commas,
instead of just treating the comma as a binary infix operator.  This
fixes #225 --- we now properly parse tuples containing lambdas.
Tuples bigger than pairs are treated as syntax sugar for right-nested
pairs, e.g. (1,2,3) is (1,(2,3)) (and also pretty-prints as the former).
2021-12-15 17:06:59 -06:00
Brent Yorgey
b1366b7c2a
add format function and string concatenation operator ++ (#293)
Adds a new function `format : a -> string` and an operator `++ : string -> string -> string`.

Closes #248.
2021-12-04 23:19:19 +00:00
Brent Yorgey
64819cc3bb bit of refactoring in TUI.Controller 2021-12-03 11:44:08 -06:00
Brent Yorgey
bb53a9fc71 clean up some error messages 2021-12-03 11:43:59 -06:00
Alexander Block
b066b3eb45
Wrap errors shown in game (#274)
Closes #241 .

This PR implements two changes:
- The error message window uses as much horizontal space as necessary now, wrapping lines when no further horizontal expansion is possible. 
- The parser groups "built-in user functions" and "direction constants" under labels of the same names. This leads to more concise parse error messages.
2021-12-03 17:05:38 +00:00
Brent Yorgey
cbad51911c
allow only whitespace when reading a term (#291)
- The user can now enter only whitespace (including comments) at the
  REPL.
- A new file which is blank / only comments is no longer invalid from
  the perspective of LSP.

Closes #275.
2021-12-02 22:07:09 +00:00