Log In  


Cart #matein2vol3-0 | 2024-07-31 | Code ▽ | Embed ▽ | No License
1

Mate in 2 -- Vol. 3

About

  • 25 Mate-in-2 puzzles.
  • Mouse required.

Controls

  • left mouse button : select / deselect pieces, squares or buttons.
  • right mouse button: show hint-square during puzzle. hide modal after puzzle.

Upgrades from previous volumes

  • mouse makes for much better user experience.
  • progress saved. start at last puzzle completed.
  • white/black to move instead of just one color.
  • improved wrong-move animation.
  • expanded color palette.
  • music (with easy on/off option at end of each puzzle).

Known bugs

  • if cart is left idle during a puzzle for a long time (like hours and hours), the wrong-move sprite animation gets messed up and instead of jiggling, the piece just drifts off to the side until returning to it's square. This is because t() is used with cos() to create the shake effect. When t() gets too big, it causes problems. It is within my tolerance level and so I don't mind. It never happens unless I forget that it is running all afternoon. Because this cart saves progress, it is no big deal to restart the cart. Or even play as-is since gameplay is not affected. In short, its a non-issue.
1


Hello! I am interested in making a puzzle game using Lichess API to provide an infinite number of puzzles.


@toadofsky
can you be more specific? there are already millions of puzzles out there... most of this carts' puzzles are from the Polgar book Chess. One thing that can definitely be done is add more puzzles to each mate-in-2 cart... there is plenty of room if the code is optimized.

To write these puzzle carts I've made little bash and javascript scripts so I can plug in the info and it prints the code so that it isn't so tedious. What would be amazing is if you could link the lichess API to something similar that would automatically spit out hundreds of puzzles, formatted for pico 8. It could do it in one second and then just copy/paste into the base code and then you'd have all those puzzles in PICO.

I hope you do something like this. I'm currently busy trying to write my first full chess engine and am struggling and it takes time. But I want to revisit the puzzles again and re-write them all with better code and movegen and other features now that I know more.


@camp39 I am contacting my fellow Lichess developers to see what we can do! I saw this is your "vol. 3" puzzle pack and it dawned on me, it would be nice if Lichess could simply provide the data you need for an unlimited puzzle pack.
https://github.com/lichess-org/lila/issues/16465

I'll be elated to assist in any way possible, since PICO-8 is capable of supporting gamepad input.


1

@camp39 ,adding gamepad input is not that hard. I can do it next week-end if you want. If you want an example and do it yourself, there is dungeons and diagrams that does it pretty cleanly.


1

@RealShadowCaster
this cart was basically me experimenting with the mouse. Since purchasing a gamepad myself, I'll stick to gamepads in the future and am making something new right now that only uses them.

As to adding it yourself, go for it! Anyone is free to improve or use my code any way they want.

My puzzle games were learning experiences and I'm going to rewrite them before releasing new volumes. But rn I'm slogging through learning how to make a functioning engine (released one last week but it crashed on people with impossible bugs. So, back to the drawing board)



1

Lichess will be releasing a "get next puzzle" API endpoint! https://github.com/lichess-org/lila/issues/16465


@toadofsky
nice. I have a lichess api key from a previous project. If I remember right, they already had puzzle requests. But you can't 'get next puzzle' from pico-8 because it wont be hooked up to the API. You'll have to hardcode in any puzzle info, so the puzzles will be static... unless you know something different.

You could set up a bash script with sed, get the json, parse it with js, then flip it into the .p8 file and have new puzzles every time you reload the game. But that would just be locally and every user would need their own API key. More of a personal project.


@camp39 I haven't checked whether the API endpoint requires authentication or can be called anonymously. After the new API code deploys either of us can check https://lichess.org/api documentation to figure out how it works.



[Please log in to post a comment]