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

Challenge mode #285

Merged
merged 39 commits into from
Jan 27, 2022
Merged

Challenge mode #285

merged 39 commits into from
Jan 27, 2022

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Nov 11, 2021

Add a "challenge mode" where the player tries to achieve some specified goal from specific starting conditions.

This is very much a work in progress, but feedback could be useful already. Still to do:

  • Add inventory parsing for robots
  • Allow defining custom entities?
  • Add parsing for worlds
  • Make a way for the user to choose a challenge (perhaps just via command-line flag until we implement Menu screen #4 ).
  • Add some actual challenges!

Closes #15 .

@xsebek
Copy link
Member

xsebek commented Nov 17, 2021

This is shaping up great! 🤩

Some thoughts:

  • I really like that I can continue playing past the win
  • when Won is first set, it should be displayed somewhere, maybe reuse the Error window?
  • every base should have a logger otherwise it is really confusing
  • there should be a challenge description sent to either a logger (easy) or a separate F2 window with checkmarks (cool), IMHO both would be best 🙂
  • the challenge file should be searched with literal path too (and later maybe relative to some XDG directory)
  • the blank file could be nice for mazes, maybe add a Filled file too? 👀
  • the God capability and as is pretty cool 😇
    • could robots "get" a God item and lose it when switching modes? It could show which God commands are available
  • could you make the current Creative and Classic modes Challenges too?
    • we could specify name for challenge ("Creative mode"/"Move tutorial"/...)
    • that way Saving and loading games #50 would be half done by reusing challenge files 😮 (just save them in XDG instead)
  • once you finish this, we could start versioning and releasing the game, as challenges are pretty cool 🤔

I hope this is not too much, thanks for working on this @byorgey 👍

@xsebek
Copy link
Member

xsebek commented Nov 17, 2021

Btw. could the as command run in another thread? Long computation freeze the UI and can not be stopped. 😕

I guess the situation is not super likely so I am fine leaving it to another PR (and I would be happy to try async) 😉

@byorgey
Copy link
Member Author

byorgey commented Nov 17, 2021

Thanks for the feedback @xsebek !

I really like that I can continue playing past the win

Yep, that's definitely intentional.

when Won is first set, it should be displayed somewhere, maybe reuse the Error window?

Right now for testing I just had it change the display of the mode from Challenge to Challenge! but having a window pop up is definitely the plan. I'll probably do that soon.

every base should have a logger otherwise it is really confusing

Good idea, though I think this is something we should just leave up to challenge writers (we could even have some documentation on best practices for creating challenges) rather than having it specially built in.

there should be a challenge description sent to either a logger (easy) or a separate F2 window with checkmarks (cool), IMHO both would be best

Yeah, I was thinking of having some kind of special item whose description tells you about the challenge. Having a built-in key like F2 for making it pop up sounds like a good idea too. I'm not sure what you mean by checkmarks?

the challenge file should be searched with literal path too (and later maybe relative to some XDG directory)

Sure, good idea.

the blank file could be nice for mazes, maybe add a Filled file too?

You can already specify the default terrain and entity to be used for any cells that aren't explicitly specified. So e.g. you could have a water world or whatever. Blank is just what you get if you don't specify a default (i.e. it's the "default default" 😉 ). I also intend to have a mode where you specify a seed, and any cells not explicitly specified in the map will be filled in using the seed just like they would be in classic mode.

could robots "get" a God item and lose it when switching modes? It could show which God commands are available

I was mostly intending the God commands to be used for authoring challenges, but I suppose they could be useful in creative mode as well. I'm not sure I like the idea of items appearing and disappearing from the inventory; also, the ability to switch between modes is really only for testing and will probably go away at some point. But maybe when you start a game in Creative mode you start with a special item like a "wand of power" or something like that which tells you about available commands?

could you make the current Creative and Classic modes Challenges too?

Ah, hmm, I see... so instead of just "challenges" they would be something a bit more general, just describing how to initialize a game. I think that sounds like a good idea!

that way Saving/loading games #50 would be half done by reusing challenge files open_mouth (just save them in XDG instead)

Hmm, maybe, but there's a lot more information you need in a save file than in a challenge description...

@byorgey
Copy link
Member Author

byorgey commented Nov 17, 2021

Btw. could the as command run in another thread? Long computation freeze the UI and can not be stopped.

Yes, that's definitely a danger. This is a consequence of the need to have win condition checking run to completion every tick, without the usual constraints on the number of CESK machine steps. I don't think we can really run it in another thread because we need to know right away whether you have completed a challenge or not. The code for checking the win condition is supposed to run every tick; running it asynchronously isn't a good idea since it could just get farther and farther behind the main game loop.

Again, if the as command is only used in designing challenges then I'm not too worried; this is just something you have to think about carefully when designing and testing your challenge. If it is also available in creative mode then it would be possible to freeze your game accidentally, which would be unfortunate. Perhaps this is an argument in favor of having certain "dangerous" commands only available to "system" robots, and not available to players in creative mode.

@byorgey byorgey mentioned this pull request Nov 17, 2021
@xsebek
Copy link
Member

xsebek commented Nov 18, 2021

"dangerous" commands only available to "system" robots, and not available to players in creative mode.

I would not worry about it, if some Player/God is testing a challenge in creative mode it would be annoying if we made it harder.

I'm not sure what you mean by checkmarks?

I was thinking ahead (so no need to do it here) about a multistage challenge like the tutorial - find tree, bring it back, make a log,...

like a "wand of power" or something like that which tells you about available commands?

My idea was that you would not need to have the item in inventory, it would be shown in the list of robot with the game mode set to Creative. It would only look like it is on inventory. Similar trick could be used to add the challenge description.

For entities that should always be drawn as if the robot knows what
they are.  Mostly useful in creating challenge scenarios.
@byorgey
Copy link
Member Author

byorgey commented Nov 19, 2021

there should be a challenge description sent to either a logger (easy) or a separate F2 window with checkmarks (cool), IMHO both would be best

For now I just put a special custom "challenge" entity in the inventory. We could certainly add some code to look for this and handle it in some special way, I am not sure exactly how.

@byorgey byorgey marked this pull request as ready for review November 19, 2021 15:40
@byorgey
Copy link
Member Author

byorgey commented Nov 19, 2021

I am pretty happy with this so far. I think it is certainly ready to have people play with it and try building their own challenges. There are a bunch more things I can think of to improve it; I am wondering what else is critical to do as part of this PR, and what we can leave to future improvement. Off the top of my head:

  • Improve the challenge file search mechanism (cf @xsebek 's comment "the challenge file should be searched with literal path too (and later maybe relative to some XDG directory)")
  • Provide a mechanism for a sequence of challenges, e.g. a tutorial where after doing one challenge you can progress to the next. Perhaps put a bunch of challenges in a list in a single file, and provide a way for the user to signal when they are ready to progress to the next challenge.
  • Perhaps some improvements to the way challenge descriptions/goals are shown, winning is flagged, etc.
  • Ability to specify a world seed instead of a default cell content, so we can have challenges that take place in random worlds a la classic mode
  • Possibly generalize challenges to just descriptions of how to initialize a game --- so classic and creative modes can be "just" generated by descriptions of how to initialize the game rather than special built-in modes.
  • Write up some documentation on how to author a challenge

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.

The challenge has a "codex" in robot inventory, but once I change that, it works nicely. 🙂

There are two things I would like to be done in this PR:

  • a unit test for parsing the files in data/challenges
  • writing a relative or absolute file path on command line should look in that path
    • we do not give hints which challenges are available, so it makes sense to use shell Tab to find the path
    • as a matter of principle I do not like requiring the challenges to be in one specific path when there is no technical reason for it

I hope my last point does not come across too strongly, but I imagine challenges will be written by players for players too and forking a repo seems unnecessary. 😅

data/challenges/move.yaml Outdated Show resolved Hide resolved
src/Swarm/Language/Pipeline.hs Outdated Show resolved Hide resolved
src/Swarm/Game/State.hs Show resolved Hide resolved
src/Swarm/TUI/View.hs Outdated Show resolved Hide resolved
byorgey and others added 9 commits November 20, 2021 15:17
We don't actually need an enumeration type for different game types.
There are really several orthogonal things going on:

1. How the world, robots, inventory, etc. are initialized.
2. Whether there is a winning condition.
3. Whether we are in "creative mode", allowing the player to do
   anything they want.
@byorgey byorgey requested a review from xsebek November 24, 2021 03:31
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.

LGTM! 👍 I checked it out and it all just works 🙂

@xsebek xsebek mentioned this pull request Nov 25, 2021
@byorgey byorgey merged commit b1f0e31 into main Jan 27, 2022
@byorgey byorgey deleted the challenge-mode branch January 27, 2022 23:00
@byorgey byorgey mentioned this pull request Jan 27, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Challenge mode
2 participants