-
Notifications
You must be signed in to change notification settings - Fork 388
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
feat(examples): add r/demo/games/tictactoe 1P-VS-CPU #2554
base: master
Are you sure you want to change the base?
Conversation
- add p/demo/tictactoe (basically @moul's model gnolang#613) - add p/demo/tictactoe1p (human VS cpu logic, extending the above) - add p/demo/ternary (to cope w/ not having C `a ? b : c` ternary operator) - add r/demo/games (start addressing gnolang#611) - add r/demo/games/tictactoe This last realm is a playable demo against a parrot which, somehow learned how to play Tic-tac-toe. This is a stateless realm which uses gnoweb as a webserver and uses css to offer a game-like experience without javascript. this depends on gnolang#2553 (improved ufmt)
To test, launch |
Set as draft, as it needs #2553 |
By the way, with Since this realm is stateless and number generator seed is initialized against the chain's height, randomness is reset to the same seed each request. It's playable still, but experience slightly worse. If OTOH you use |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2554 +/- ##
=======================================
Coverage 60.19% 60.20%
=======================================
Files 562 562
Lines 75007 75057 +50
=======================================
+ Hits 45154 45190 +36
- Misses 26476 26491 +15
+ Partials 3377 3376 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Ready for review, updated the original text. |
Cap'n Cluck was successfully deployed on test4 so you may play it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All checks pass. Ready for core devs to decide where this code should live.
Removed the |
I'm a bot that assists the Gno Core team in maintaining this repository. My role is to ensure that contributors understand and follow our guidelines, helping to streamline the development process. The following requirements must be fulfilled before a pull request can be merged. These requirements are defined in this configuration file. Automated Checks🟢 Maintainers must be able to edit this pull request Manual Checks
Debug
|
Note: in this end of August 2024, as we are talking about Twitter Bootstrap-like component in the weekly meeting, there was a discussion about whether to keep HTML/CSS in our current markdown flavour. I'm definitely down with the fact of keeping it.
This is another tictactoe variation!
Cap'n Cluck was permissionlesslly deployed on test4. Try it here if you dare.
Built on top of Manfred's #613, it's a human VS CPU tic-tac-toe.
Addresses #611 (there is also gnochess, but we don't really have games. I am also thinking a simple winmine clone would be good),
Closes #613 (@moul's original model is in its own package).
some screenshot
principle
Since the realm is stateless, randomness had to be implemented using block's height.
About the
state
of the game, my first idea was to use something like to easily transmit the state in the url (type=hidden is convenient for that):With each button having a name="move" and a coordinate for the value.
Since realms seem unable to access the querystring at the moment, links like
<a href=r/demo/games/tictactoe:state=:current_state:&move=XY></a>
are used for each of the 9 squares. Those links are styled within a<style type=text/css>...</style>
, in the markdown itself.So this is a realm full of tricks.
Full of controversy :) (of questions in fact)
path and query (remark)
In gno.land we currently have to use paths such as
r/foo/foo:abcdef
, with a colon:
.Gnoweb cuts off the querystrings at the moment1, i.e.
r/demo/echo:abc?bar
will have a pathfoo
inRender()
, notfoo?bar
. @moul I have seen #2585 but I am not sure if it means querystring could become supported.According to the RFC 3986 by Sir Tim Berners-Lee, it technically means our realm's path are indeed part of the URI path, and not of the query, consider for instance
https://gno.land/r/demo/art/gnoface:1337
against this:path
would be/r/demo/art/gnoface:1337
R
inURI
). Affecting potentially caching, routing, search engine databases, maybe web archivers.A
?query
normally makes sense when it's a random parameter, and things liker/foo:1337
can make sense (even though it's rarely seen) when the 1137 is an id or e.g. a crypto address.This is why #2585 could be interesting.
packages
Maybe too much packages. Hard balance to find.
This last realm is the actual game.
feats
Footnotes
see https://gno.land/r/demo/echo:abc?def ↩