Commit Graph

37 Commits

Author SHA1 Message Date
Brent Yorgey
a1bab6d16c
Dependency updates (#1765)
Some dependency updates, to allow:
- `vty-6.2`
- `brick-2.3`
- `warp-3.4`
- `bytestring-0.12`
- `text-2.1`
2024-02-12 20:04:28 +00:00
Brent Yorgey
c4a6e273c1
Update to depend on lsp-2.4.0.0 (#1762)
Update to use the `lsp-2.4` API.  Closes #1350.

Initially I hoped that any `lsp-2.x` would work.  However, the `SeverDefinition` record changed in `2.2` so I initially set that as a lower bound.  But then it turns out that `2.4` changed which module it is importing `Rope` from; since we work with ropes in the `Hover` module it matters since we have to import the matching module.  Updating to the new `Rope` type also required some changes as the API provided by the new `Rope.Mixed` module is a bit different than the old module, so we would not even be able to easily put in CPP to conditionally depend on the right rope module depending on the `lsp` version.  Finally, this means dropping support for GHC 9.0 since `lsp-2.4` does not support it.

Along the way I also fixed a minor issue related to showing type information returned by the LSP server, so that it uses `prettyTypeLine` to display the type on a single line (in my editor, when the type does not use a single line it gets cut off).  For comparison see also #1610. 

This refactoring was a big pain because a lot of things (names of types and constructors, locations of exports, etc...) changed from 1.x to 2.x, but there was not much in the way of documenting what had changed. =(   I am pretty sure that all functionality has been preserved but I would appreciate independent confirmation.

This is also a prerequisite for updating other dependencies such as the `base` version (I will open a follow-up PR soon) since the old `lsp-1.x` versions do not allow many newer versions of various dependencies.
2024-02-12 11:05:39 -06: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
Brent Yorgey
e350ab8ae7
update to LTS-21.25 (#1708)
21.25 uses GHC 9.4.8 instead of 9.4.7; the latest HLS release supports 9.4.8 but not 9.4.7.
2024-01-04 22:12:36 +00:00
Brent Yorgey
8f52e53a22
Fix the stack build (#1627)
Closes #1624.

Note, however, that currently (until #1623) this will not work on Windows, since I explicitly added `vty-unix` as an `extra-dep` in the `stack.yaml` file.  However, I expect we will get #1623 soon and then we can remove it.
2023-11-15 03:23:23 +00:00
Brent Yorgey
96d3062550
update to megaparsec-9.6.1 (#1609)
* Update to `megaparsec-9.6.1`.  This allows us to remove any annoying workaround. 
* Bump stack resolver to LTS-21.19.
* Drop support for GHC 8.10.
2023-11-08 12:26:23 -06:00
Karl Ostmo
d63e7d81ef
Structure browser and recognizer (#1579)
Closes #1575

Implements structure recognition.

## Features

* Structure browsing dialog (`F6`) that becomes available if a scenario declares any recognizable structures
* Automatically recognizes statically-placed structures upon scenario initialization, accounting for occlusion by other entity/structure placement
* New `structure` command for querying location of recognized structures (primarily intended for system robots and goal checking)
* Efficiently recognizes structures immediately upon completion
* Accounts for removal of structures
* Several new integration tests
* Structured web-interface log to help understand/debug the recognition process
* Re-uses much of the functionality built previously for defining structures (#1332)

Other changes:
* Improved validation for static structure placement (ensure valid structure names instead of failing silently)
* Moved a few functions (`getNeighborLocs`, `zoomWorld`, `entityAt`, `robotWithID`, `robotWithName`) out of `Step.Util` and into `State` so that recognizer initialization, which becomes a field in `GameState`, could use them
* split `scenarioToGameState` into pure and non-pure functions

## Optimizations

Scenarios that do not make use of structure recognition are entirely unaffected, performance-wise.

Some optimizations include:

* Structure definitions must "opt-in" to participate in automatic recognition
* Aho-Corasick automatons optimized by:
    * only initiate structure search if a placed entity exists on a participating structure template
    * initializing different automatons for each type of "placed entity"
    * pruning inapplicable row candidates for 2-D search

The row-level structure recognition cache described in #1575 was not implemented; it's probably not worth the complexity cost.

# UI Demo

    scripts/play.sh -i scenarios/Testing/1575-structure-recognizer/1575-browse-structures.yaml --autoplay

1. Press `F6` for Structure Browser dialog
2. View http://localhost:5357/recognize/log and http://localhost:5357/recognize/found

![image](https://github.com/swarm-game/swarm/assets/261693/e32d3572-7e53-42d6-84cd-393c57a8aeac)

# Future improvements

* Refactor `State.hs` so that the new helper functions can live elsewhere
* Support non-rectangular recognizable structures
* Allow flip/rotate of recognizable structures
* Structure ownership by robots
* Consolidate code between the Goals and Structures modal dialogs, and the Achievements browser
* Enforce minimum/maximum dimensions for structure definitions
2023-11-08 06:44:27 +00:00
Karl Ostmo
e06e04f622
Pathfinding command (#1523)
Closes #836

# Tests
    scripts/run-tests.sh  --test-arguments '--pattern "Pathfinding"'

# Demo

    scripts/play.sh -i data/scenarios/Testing/836-pathfinding/836-automatic-waypoint-navigation.yaml --autoplay
2023-09-19 06:21:03 +00:00
Brent Yorgey
15dd824c6a
Improvements to scrolling (#1481)
- Add scrollbars on both the inventory and info panels
- Get rid of `. . .` at top and bottom of info panel, since we now have scrollbar as a visual indicator when there is more content
- Allow scrolling the REPL history (closes #60)
    - PgUp/PgDown can be used to scroll (Shift+PgUp/Dn were not recognized on my system)
    - Hitting any other key causes the view to jump back to the very bottom
    - A computation finishing + printing an output also causes the view to jump to the bottom
    - The REPL history is cached so that it only gets re-rendered whenever a new history entry (i.e. input or output) is added; this is needed since the history could get quite large.
- Also, fix the height of the key hint menus to 2 lines, even when the panel-specific menu (second line) is blank, so the world panel does not keep resizing as we move the focus between panels.

Thanks to @jtdaugherty for releasing `brick-1.10` with a new ability to specify blank space to the side of scrollbars; see https://github.com/jtdaugherty/brick/discussions/484 .

Also towards #1461 .
2023-09-03 04:51:01 +00:00
Brent Yorgey
6a7063bec0
Update to LTS-21, GHC 9.4.5, brick-1.9 (#1351)
[Stackage LTS 21](https://www.stackage.org/blog/2023/06/announce-lts-21-nightly-ghc9.6) was just released, which is great news for us because it includes GHC 9.4.5 (GHC 9.4.4 was no longer supported by HLS) and we no longer have to rely on a specific "nightly" version.  This PR updates a few things to build with LTS-21.

The biggest thing I *didn't* update was our `lsp` dependency: LTS-21 comes with `lsp-2.0` and `lsp-types-2.0`, but those apparently introduce some breaking changes and it wasn't immediately apparent to me what would need to change.  I filed https://github.com/swarm-game/swarm/issues/1350 to track that issue.
2023-06-26 17:51:52 +00:00
Brent Yorgey
079ca0574f
Fix brick-list-skip versions (#1213)
* less restrictive upper bound on `brick-list-skip`

* switch to `brick-list-skip-0.1.1.2` in `stack.yaml`
2023-04-16 13:19:22 -05:00
Karl Ostmo
ffbb303b94
use brick-list-skip package (#1211)
Closes #1127
2023-04-13 16:51:06 +00:00
Karl Ostmo
9e0e6fa666
Autogenerate web api docs (#825)
The docs are viewable from URL path that isn't already defined, e.g.:

    http://localhost:5357/

As an minor update to #821, the CLI invocation to dump REPL commands is now:

    curl http://localhost:5357/repl/history/full | jq .[].in -r

Implemented by following [this tutorial](https://docs.servant.dev/en/stable/tutorial/Docs.html).

![Screenshot from 2023-04-02 12-40-38](https://user-images.githubusercontent.com/261693/229375261-9845f410-2e0b-4fb2-ad89-4367c8f62ca8.png)
2023-04-03 22:35:35 +00:00
Karl Ostmo
6702a8b50d
introduce boolexpr package to replace vendored module (#1188)
Closes #934.
2023-04-01 17:46:27 +00:00
Karl Ostmo
61a3d43de5
Update to GHC 9.4 and brick 1.5 (#1001)
A couple upgrades:

- Upgrade to Brick 1.5, which has a new nicer dialog API, with names to identify buttons instead of positional indices: https://hackage.haskell.org/package/brick-1.5/changelog
- Update stack resolver to a nightly one, with GHC 9.4.  This fixes? mitigates? #1000, at least, no one has yet observed the issue under GHC 9.4 that we know of.
2023-01-30 23:33:38 +00:00
Karl Ostmo
308702164d
Fix IDE by bumping stack LTS version to GHC 9.2: (#975)
Closes #969
2023-01-07 18:16:14 +00:00
Brent Yorgey
a4d0d230cd
allow latest versions of dependencies + GHC 9.4 (#752)
Update dependencies + add GHC 9.4 to CI.  Closes #748 .
2022-10-31 02:51:43 +00:00
Brent Yorgey
58ff215480
upgrade to hsnoise-0.0.3 (#746)
Closes #745.
2022-10-13 20:48:56 +00:00
Brent Yorgey
5a01658883
rename unit type to unit (#697)
Closes #696.
2022-09-26 20:10:12 +00:00
Brent Yorgey
e6defd44b1
update to brick-1.0 (#641)
* Update to `brick-1.0`
* Test with GHC 9.2.4
2022-08-17 12:35:10 -05:00
Brent Yorgey
1c41a0e19e
update stack build for new EventM API (#583) (#599) 2022-07-27 17:15:09 -05:00
Brent Yorgey
b0ad993a3f trigger deadpendency run 2022-07-27 23:40:31 +02:00
Ondřej Šebek
dabcb21608 Update stack resolver 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
Brent Yorgey
ee857a5d21
upgrade to brick-0.69 (#365)
Closes #340.
2022-06-04 22:59:18 -05:00
Brent Yorgey
cdd3aff892 remove https://github.com/jtdaugherty/brick/issues/337 workaround
This issue is fixed in `brick-0.64.2`.
2021-10-22 11:55:32 -05:00
Paul Brauner
b72e09edb1
Use fused-effects for the game logic (#256)
Resolves #228.

I've redefined the missing lens operators in `Utils.hs` in order to keep the diff of the function bodies minimal. Hopefully that will make merges and rebases less painful. Most of the type signatures are modified though, we can't avoid this.
2021-10-21 22:44:56 +00:00
Jens Petersen
6adc150530
stack: update to hashable-1.3.4.1 which builds (#168)
hashable-1.3.4.0 looks broken at least on lts18
2021-10-04 10:59:51 +00:00
Daniel Díaz Carrete
4d3f3aa12a
Compatibility with hashable-1.3.4 (#142)
The code has an orphan instance `Hashable (Map k v)` but, starting from [hashable-1.3.4.0](https://hackage.haskell.org/package/hashable-1.3.4.0/docs/Data-Hashable.html#t:Hashable), that instance already exists in hashable itself, making compilation fail.

I disabled it for that case using a CPP directive.
2021-10-02 15:34:38 +00:00
Tristan de Cacqueray
c7baf13efe
Add basic editor integration with LSP (#108)
This change improves the user experience when editing swarm code outside of the REPL with:

- CLI for a `format` command to quickly parse and type check a file.
- Basic LSP server to provide IDE feedback on save, e.g. visual squiggly for errors.
- Initial emacs mode.

Fixes #82 #110
2021-10-01 20:11:08 +00:00
Jens Petersen
fc855e7fc1
stack: update to latest lts-18.12 for ghc-8.10.7 (#107) 2021-09-29 11:11:09 +00:00
Brent Yorgey
a2aa581ca5 indent wrapped recipes by two spaces
Closes #48.
2021-09-25 16:49:15 -05:00
Brent Yorgey
38a0bbe063 tweaks to world, shift to spawn base at a tree 2021-09-04 07:19:22 -05:00
Brent Yorgey
f8a3f077cc play with hsnoise for world generation 2021-08-25 21:12:58 -05:00
Brent Yorgey
c299ae1783 downgrade to LTS-18.6
18.7 has GHC 8.10.6, but hls doesn't suport it yet.
2021-08-25 13:02:32 -05:00
Brent Yorgey
842688eef1 fix stack.yaml 2021-08-25 09:21:38 -05:00
Brent Yorgey
a1885536d2 set up stack 2021-08-24 21:59:03 -05:00