Skip to content

Generate command table #531

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

Merged
merged 11 commits into from
Jul 4, 2022
Merged

Generate command table #531

merged 11 commits into from
Jul 4, 2022

Conversation

xsebek
Copy link
Member

@xsebek xsebek commented Jul 1, 2022

@xsebek
Copy link
Member Author

xsebek commented Jul 1, 2022

I just had to make it well-aligned. 😅

| Syntax          | Type                                          | Capability   | Description |
|-----------------|-----------------------------------------------|--------------|-------------|
| `noop`          | `cmd ()`                                      |              |             |
| `wait`          | `int -> cmd ()`                               |              |             |
| `selfdestruct`  | `cmd ()`                                      | selfdestruct |             |
                                      ...

| `case`          | `∀ a b c. a + b -> (a -> c) -> (b -> c) -> c` |              |             |

But I am not sure how to best get the description.
Ideally, I would like to get the haddock comments, so we would not have to duplicate them.

Do you have any tips or suggestions, @byorgey or @TristanCacqueray?

@byorgey
Copy link
Member

byorgey commented Jul 1, 2022

Getting Haddock comments is a good idea, but I don't know off the top of my head how to extract them in a nice way...

@byorgey
Copy link
Member

byorgey commented Jul 2, 2022

@xsebek
Copy link
Member Author

xsebek commented Jul 2, 2022

Even TH could do it, but only on newer GHC - https://discourse.haskell.org/t/ghc-9-2-1-released/3527.

If there was an easy way with TH/Generics/some package I would use docstrings, but I do not think it is viable <9.2.

Writing documentation for players separately is not so bad and will be simpler Haskell. ✍️

@xsebek
Copy link
Member Author

xsebek commented Jul 2, 2022

I wrote it manually, could you please take a look @byorgey?

Here is the gist of the resulting markdown table: https://gist.github.com/xsebek/3e8b679f4dad68a7fdf1021abdd95872

@xsebek
Copy link
Member Author

xsebek commented Jul 2, 2022

Another idea: maybe we could split the table into

  • builtins (not operator and not isCmd)
  • commands
  • operators

And below that have a section per each command/function with a longer description like we have for Entities.

Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! We should somehow make these descriptions available in the Commands (F4) pop-up as well (in another PR).

@byorgey
Copy link
Member

byorgey commented Jul 2, 2022

Another idea: maybe we could split the table into

* builtins (not operator and not `isCmd`)

* commands

* operators

And below that have a section per each command/function with a longer description like we have for Entities.

Sounds good, I have no particular opinions on how the table should be formatted.

@noahyor
Copy link
Member

noahyor commented Jul 2, 2022

I just checked and it seems that all 4 cheat sheets are either unfinished or outdated, so maybe we could automatically generate documentation for all of them.

@xsebek
Copy link
Member Author

xsebek commented Jul 2, 2022

@noahyor I known, that is the plan 😎

We could even update the wiki in CI, but I do not plan to automate that anytime soon.

Copy link
Member

@noahyor noahyor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few little things.

]
Move -> commandLow 0 "Move forward one step."
Turn -> commandLow 1 "Turn in some direction."
Grab -> commandLow 0 "Grab an item from the current location."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Grab -> commandLow 0 "Grab an item from the current location."
Grab -> commandLow 0 "Grab an item from the current cell."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I do not think a player will find the "cell" understandable. My understanding is that "cell" is more of a game developer term than gamer slang.

Turn -> commandLow 1 "Turn in some direction."
Grab -> commandLow 0 "Grab an item from the current location."
Harvest ->
commandLow 0 . doc "Harvest an item from the current location." $
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
commandLow 0 . doc "Harvest an item from the current location." $
commandLow 0 . doc "Harvest an item from the current cell." $

, "Otherwise it works exactly like 'grab'"
]
Place ->
commandLow 1 . doc "Place an item at the current location." $
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
commandLow 1 . doc "Place an item at the current location." $
commandLow 1 . doc "Place an item in the current cell." $

commandLow 1 . doc "Place an item at the current location." $
["The current location has to be empty for this to work."]
Give -> commandLow 2 "Give an item to another robot closeby."
Install -> commandLow 2 "Install a device from inventory on a robot."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Install -> commandLow 2 "Install a device from inventory on a robot."
Install -> commandLow 2 "Install a device from inventory on given robot reference."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think installing stuff on references makes sense.

commandLow 2 . doc "Reprogram another robot with new command." $
["The other robot has to be closeby and idle."]
Drill ->
commandLow 1 . doc "Drill through an entity." $
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
commandLow 1 . doc "Drill through an entity." $
commandLow 1 . doc "Drill through a drillable entity." $

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I am content leaving that discovery to the player. 😄

Anyway, if you wanted to include some specifics, I would suggest doing it in the longer description.

Appear ->
commandLow 1 . doc "Set how the robot is displayed." $
[ "You can either specify one character or five (for each direction)."
, "The default is \"X^>v<\"."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the 'X' ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the robot is looking down. So it looks like four robots meet.

Anyway, I would like to make that customizable one day, so that powerline font users can choose prettier versions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, but how would the player ever be able to see that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean build {move; turn down}?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*gape* Wow, I never knew that a robot cold turn downwards!

Random ->
commandLow 1 . doc "Get a uniformly random integer." $
["The random integer will be from the range 0 to END inclusive of your choice."]
Run -> commandLow 1 "Run a program loaded from a file."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Run -> commandLow 1 "Run a program loaded from a file."
Run -> commandLow 1 "Run a program from a file."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not too clear on the semantics here, but loading the program from a file sounds like English to me. 🤨

Co-authored-by: Brent Yorgey <[email protected]>
Co-authored-by: Noah Yorgey <[email protected]>
@xsebek
Copy link
Member Author

xsebek commented Jul 2, 2022

Writing documentation for players separately is not so bad and will be simpler Haskell. ✍️

So he said, as he went to write instance IsString ConstDoc... 😆

xsebek added 3 commits July 2, 2022 23:06
I think I now get what Emacs referred to as builtins.
Instead of having their list hardcoded, I can simply
add a few predicates to split consts rougly into
functions, operators and commands.

Technically operators are also functions, but for
documentation purposes we keep them separate.
@xsebek xsebek marked this pull request as ready for review July 2, 2022 21:12
@xsebek
Copy link
Member Author

xsebek commented Jul 2, 2022

Behold!

The ultimate command wiki is here!

It has hyperlinks:

image

Separate sections for functions and operators:

Screenshot from 2022-07-02 23-14-23

And finally, detailed descriptions, which we can expand in the future:

image

@byorgey
Copy link
Member

byorgey commented Jul 3, 2022

Looks great!

@byorgey
Copy link
Member

byorgey commented Jul 3, 2022

We should link to the wiki page in the Commands dialog.

@TristanCacqueray
Copy link
Collaborator

Well done @xsebek!

@xsebek
Copy link
Member Author

xsebek commented Jul 4, 2022

@byorgey I would prefer to include the info in the game.

It would be nice to have the commands expandable, so when you select it and hit Enter it would show similar info as the wiki. Or we could have a separate view for the currently selected command similar to how we have inventory and info panel.

But for the moment a link must suffice:

image

This might be my first commit changing the UI! 😆

constSig = case processParsedTerm (noLoc $ TConst c) of
Right (ProcessedTerm (TConst _) (Module pt _) _ _) -> " : " <> prettyText pt
_ -> "??"
constSig = " : " <> prettyText (inferConst c)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TristanCacqueray Hah, I see you had fun drawing the Const type too! 😀

@xsebek xsebek added the merge me Trigger the merge process of the Pull request. label Jul 4, 2022
@mergify mergify bot merged commit f2ad132 into main Jul 4, 2022
@mergify mergify bot deleted the generate-tables branch July 4, 2022 08:47
@byorgey
Copy link
Member

byorgey commented Jul 4, 2022

@xsebek yes, including this info in the game would be great, but this is way better then nothing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants