Skip to content
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

Add a "driving mode" to the REPL #819

Merged
merged 1 commit into from
Nov 4, 2022
Merged

Add a "driving mode" to the REPL #819

merged 1 commit into from
Nov 4, 2022

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented Nov 3, 2022

Ctrl+d in the REPL will toggle into "driving mode". In this mode, the arrow keys simply submit predefined commands to the REPL:

Key REPL input
move;
turn back;
turn left;
turn right;

This yields a pretty natural driving experience:

@kostmo
Copy link
Member Author

kostmo commented Nov 3, 2022

Things to improve:

  • The keyboard shortcut list above the REPL pane is quite crowded. Should think of re-organizing it.
  • In driving mode, another row should be displayed below the keyboard shortcut list, explaining the arrow key meanings.
  • Maybe this control mechanism should only be accessible in Creative mode. In which case, to circumvent the Tutorial as I've done in the video, you would have to pass the --cheat flag on the command line.

Copy link
Member

@xsebek xsebek left a comment

Choose a reason for hiding this comment

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

Thanks @kostmo, it looks great and I will try it out soon! 👍

AFAIK we planned to add event handlers to the language that would be more general. Then you could use keys for grabbing etc.

But I like how your approach shows the commands, this system looks very user friendly and we could still do both. 🙂

src/Swarm/TUI/Controller.hs Outdated Show resolved Hide resolved
@byorgey
Copy link
Member

byorgey commented Nov 3, 2022

I love the idea of driving robots around, and I tried this out and it works well. It is a little annoying trying to use it in a Creative game though, because the base always looks like Ω no matter which way it is facing so you have to keep track of which way it is facing in your head. I see the appeal of having Left/Right arrow keys correspond to turn left/right and Up correspond to move, but for driving around something that always looks like Ω it might work better for e.g. Left to correspond to turn west; move and so on. I'm not necessarily advocating that particular solution, just pointing out that it probably needs to be addressed somehow for this to be usable beyond solving early tutorial challenges more easily.


In general, I do want to keep this game focused on programming; the relevant design principle is that instead of adding complex built-in features, we should strive instead to provide language constructs that allow players to program the cool features themselves. For example, see #102 for a previously discussed feature which would allow players to program their own driving mode. See also #558 for another discussion of this design principle. However, I am not against including this PR, especially if it is limited to creative mode. In fact I guess there could be something fun about seeing a feature like driving mode that's only available in cheat/creative mode, then much later realizing that you can actually program it yourself in classic mode!


There are some things I like about this that make me think of improvements to #102, or more general features we could provide in the spirit of the design principle I mentioned above. This is just me brainstorming and should probably eventually be moved into new issues etc.

  • I like having a key shortcut to toggle pilot mode off/on. Maybe we could have a dedicated key shortcut to toggle the most recently installed input handler on/off. Then you couldn't get stuck running an input handler where you forgot to program in a way to exit, and you could easily toggle it off temporarily to run some other commands etc., then toggle it back on without having to type in a whole command to run it again.
  • Maybe you should be able to programmatically choose what is shown in the key shortcut menu, so that when e.g. running an input handler you could show help to remind yourself (or anyone else who wants to use your input handler) of the available keys.
  • Heck, maybe the whole UI should be programmable!!? Like there would be some standard built-in commands corresponding to the usual content of the UI, but you could (1) program a different UI layout using those standard built-in commands, or even (2) program your own completely new UI widgets showing whatever info you want.

Copy link
Member

@xsebek xsebek left a comment

Choose a reason for hiding this comment

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

I tried it and it's great! 👍 I imagine it will at least make testing challenges easier. 🙂

I generally agree with @byorgey's comments here, but I think we can fix the mentioned issues separately. Meanwhile, this adds a lot of value to the --cheat mode. 😁

Feel free to merge @kostmo unless you want to improve anything still.

@xsebek
Copy link
Member

xsebek commented Nov 4, 2022

Btw. I do not think turn west; move is a good idea. Once you can move and turn the base with tank treads, the direction issue will come up, so making a hack for it here is unnecessary.

We used to have the base orientation map with normal characters for absolute directions. The trick was that the base was facing down by default which sometimes made other robots look like the base. We can now customize this through scenarios or allow players to set it themselves. 🤷

But let's not do that here, we should aspire to have small commits. 😄

src/Swarm/TUI/Controller.hs Outdated Show resolved Hide resolved
@kostmo kostmo marked this pull request as ready for review November 4, 2022 18:26
@kostmo kostmo added the merge me Trigger the merge process of the Pull request. label Nov 4, 2022
@mergify mergify bot merged commit b5b83fc into main Nov 4, 2022
@mergify mergify bot deleted the driving-mode branch November 4, 2022 18:38
@kostmo
Copy link
Member Author

kostmo commented Nov 9, 2022

Related: #683

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.

3 participants