Freestyle Chess == Chess960 == Fischer Random
NICE: Nice Is Camp39's Engine
The Good
- pass n play and board flip option
- clean interface & themes
- play against computer
- opening book for standard chess
- endless openings with Freestyle Chess (press up while on chess960 to view positions)
- all rules, including 50 move and 3-fold repetition
The Bad
- my first engine ever... its a little slow
- my first engine ever... its a little dumb
- maybe 2.0 will be better!
About NICE
[hidden]
This was a real accomplishment for me and is my first engine. The move generation follows the tutorial of Bluefever Software video series on Youtube: Programming a Chess Engine in Pure Javascript.
When it came to the search functions I learned a ton by following the book: Chess Algorithms by Noah Caplinger.
The limitations of Pico-8 though make for a challenging adaptation of these types of tutorials. (translating from zero-based arrays can give some crazy nasty bugs). The speed limitations make some variation strategies useless e.g. "killer moves" only make sense with a depth of at least 4. It was a really cool experience and gave me more insight into the game.
I liked the board layout from cart #quickchessyness-4 by @Adam_Howell so much that I copied it :)
This cart will need some updates however. I was unable to get quiesence to work without a move taking FOREVER. Maybe due to my move ordering, maybe due to the evaluation function, maybe due to lots of things. Its all very complicated and hurts my brain since it is recursive at iterative depths. Hard to pinpoint problems like that. If any kind soul wants to offer tips, I'm all ears!
@Krystman of course released the fabulous Pico Checkmate, cart #54038 6 years ago. I definitely looked through his code for clues but couldn't manage to find a way to cut off a search if time got too long. But I did follow his lead and purge illegal moves right off the bat instead of making and taking them. Without a full quiesence search though, I don't think NICE will stand a chance against Pico Checkmate.
This cart, while not having the best engine still has some nice features. Chess960 is chess but with almost random starting positions. Its just like standard chess with the exception that castling can be a little weird. Just remember that king and rook end up in the same ending positions as in regular chess, regardless of where they started. Otherwise, same rules apply. This eliminates the same opening every time you play against the computer. Also, to prevent that from happening in standard chess, I coded in a small opening book with response options being chosen randomly so that you can get different responses even if you play the same.
I hope this cart is popular with hand-held users (I don't personally own one). The pass n play is not something I've seen on other chess carts and I imagine a game of chess on a long flight or bus ride would be cool, but playing upside down is a bit awkward.
Crazy idea: what if there was a cart with the move generation and graphics already on it (and optimized to the max) and then two different users could put in a tiny engine each and let them battle. Maybe more realistic on picotron?
how do i test for big numbers that print different than their true value?
function _init() srand(39) a=rnd(-1) --prints -20954.2428 b=-20954.2428 end function draw() if b==a then ?"true" else ?"false" end --prints false end |
I have some big numbers that would be nice to know their true value.
thanks and merry Christmas!
When the AI plays itself in my game, it is too much for the _update() so PICO-8 drops _draw() frames. The moves are correct, but its awkward because both pieces move at once.
How do I remedy this? Is it a coroutine I need? I've been playing with them and have gotten some crazy results, not really knowing what I am trying to accomplish. But is that even the right approach?
Or can I make some kind of delay between moves to give the cpu time to catch up? I tested by making it only run the engine after a button press and it works fine.
I also tried calling flip() explicitly after the resource-heavy function but no dice.
any pointers are appreciated.
@toadofsky
I moved the conversation to chat so as not to clog up the cartridge section.
in response to your last post;
how are you going to hook up PICO-8 to the internet though? Can you do that?
I'd like to make some associative tables e.g. table={x=7,y=90,z=40}
but I want to save tokens by using a string because I'm going to have a lot of them, and make a function that returns a table based on whatever is in the string.
So something like:
string1="x=7,y=90,z=40" string2="empty=100, dinner=casserole, transport=horse, weight=150" table1=assoc_table(string1) table2=assoc_table(string2) ?table1.z -- 40 ?table2.transport -- horse |
how do I go about this? split
wont work. what does my function assoc_table(str)
look like?
v0.2.6b
The hide_mouse_cursor feature is very buggy. That is the option that makes the mouse cursor disappear while typing in the PICO-8 editor. Length in seconds can be configured in config.txt but the problem is there even with the default of 5 sec.
On startup it works but after a while of coding it stops working at all. I posted this before but deleted my post because the steps I gave to reproduce didn't always make it happen. So it's hard for me to say exactly when it stops working. But I think that everyone here will notice if they pay attention, that after a some time working on a game, the mouse cursor will remain in the way while typing.
If you ctrl-r
ctrl-r
it will start working again. But if you type something at the command prompt and say, get a syntax error, or even just ls
to show whats in the directory, or cls()
, most of the time (but not always!) when you esc back to the editor it will be broken and the mouse will show even while you are typing. This will persist for the rest of the session. ctrl-r
TWICE seems to reset it, but once is not enough.
I bought a couple of bluetooth gamepads off Amazon:
KIWITATA 2.4G Wireless NES USB Controller
Which are imitation NES classic, 2-button, D-pad, select start controllers.
It gets recognized right away by my latest Linux Mint OS and works in Pico-8
EXCEPT that both buttons do the same thing (I think they are both X).
I ran this code:
function _draw() cls() ?btn() end --both B and A output 32 |
and sure enough I get different values for all the buttons except both B1 and B2 print 32.
I've found this thread https://www.lexaloffle.com/bbs/?tid=3623 where one poster talks about the same problem. But its from 2016 and was for pocketCHIP and they solved it by getting a different controller.
I've also installed the SDL2 gamepad-tool for Linux but had issues. It sort of works EXCEPT that it wont recognize left/right on the dpad. I tried a million times and also tried skipping and mapping it to the little joysticks instead but it didn't work.
Solitaire Chess
About
68 solitaire chess puzzles. Drag and drop. Mouse only. Every move must be a capture, no check, king can be captured. Win by leaving only one piece. Lose if no remaining moves and more than one piece.
There are two modes: puzzle rush and relax mode. Relax mode is recommended, but if you get to the end you don't get the winner screen and no points. In relax mode you can navigate to any puzzle by using the selector at top left and clicking "GO". There is no clock or points and progress is not saved.
In puzzle rush mode, points are based on how much time is left when a puzzle is completed. Each failure or reset of puzzle is minus 50 points. You can go negative and progress is saved. Clicking "start fresh" will delete all progress.
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 withcos()
to create the shake effect. Whent()
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.
little help?
A sprite shakes if a certain condition is met and function called. I'd like to play a sound effect while it shakes. But I cant seem to make it play the whole sound effect because it starts over with each update and buzzes rather than plays. I can get the sound effect, or I can get the animation, but cant seem to make them both happen at the same time.
I've tried many different variations and schemes, but here is one example:
function _init() correct = nil tics = 30 end function _update() if (correct == false) shake() end function _draw() draw_stuff() end function shake() sfx(0) tics -= 1 if tics > 0 then mysprite.x = mysprite.x + cos(t()/.1) --makes it shake back and forth else correct = nil tics = 30 end end |
I can see why it doesn't work; because it is calling the sfx(0)
again and starting over every time shake()
is called. But what is the right way of thinking about playing the sound along with an animation? I read about coroutines, but am not sure if that is actually needed for something this basic. I'd also like to just be able to call the function whenever I want and not bother checking in _update()
every frame.
Variations: The Stafford Gambit
Credits
-
These variations come from the Eric Rosen youtube channel.
(watch the link while practicing with this cart for maximum understanding) - Big thank you to @Heracleum for kindly going through one of my previous variation carts and teaching me how to properly make a data table. Its made more variations possible.
About
The Stafford Gambit is an objectively bad opening for black. But white has to play accurately which is very hard to do, giving lots of attacking chances, pins, traps, and nasty mates. Natural moves for white lead to certain doom. If you learn these 20 variations inside and out you will confuse many opponents and have a blast doing it. If your opponent really knows what they are doing, you may be in serious trouble!
Variations: The Vienna
Description
16 variations of the Vienna opening played as white. These lines are chosen to be fun, for their attacking chances and dynamic play. They include common mistakes by black and how to punish them as well as how to respond to good play from your opponent. Practicing with this cartridge will give any player a good start to creating big problems for black with the Vienna!
Features
While none of white's moves are dubious, they are not necessarily the top engine recommendations. Because there is no 'right' move, a hint can be requested (see Controls). After completing a variation, the Stockfish evaluation is given. The player then has the options to either repeat the completed variation, move on to the next, or have the computer select a variation at random. The pause menu gives similar options but can be accessed at any time allowing the player to navigate to a specific variation or move to a new, random variation.
a = {x=10, y=25} b = a b.x = 99 print(a.x) |
This prints 99
but I assumed it would print 10
.
I wrote code with a start table. Then I set a position table equal to the start table. I was hoping to update the position table but reset the position back to the start point at any time I wanted. I tested this out in php to make sure I wasn't crazy and it worked like I expected. I tried it out in strict Lua but it gave the result above. Why does Lua change the a
table when I only changed the b
? How do I deal with this?