Log In  


Cart #54038 | 2018-07-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
241

A simple, cute retro version of classic Chess made in Pico-8. Full implementation of almost all of the Chess rules with a juicy interface and some basic AI to play against. Created as part of the Chess Jam 2018. Here is the game's entry on itch.io.

Jucy animations were very important to me. My Chess AI will never be competetive. So I focused on the game being pretty, readable and fun to play. I wanted to add even more functions but sadly, I ran out of tokens. I tried to squeeze in as many as I could.

That being said, the Chess AI is kicking my butt. Let me know if you've beaten it. Not sure how smart it really is - my Chess is rusty. Also, let me know if you find any bugs.

Note: Game will not recognize draw by Threefold repetition.

241


Found a bug with the the Queen putting me into check without LOS, behaving more like a Knight move in fact.

Beautiful board and piece rendition though...:)


OMG how embarrassing! Bug fixed. Thanks! <3


Very well put!
As for saving tokens, did not see any obvious wins (you are already decoding string to data).

minor comments:

  • couple of places where you could declare multiple variables using:
local a,b,c=1,2,3
  • use pico API:
flr(sub(s,lastpos,#s)+0)

can be replaced with:

tonum(sub(s,lastpos,#s))
  • save tokens
explode("-21,-19,-12,-8,8,12,19,21")

can be replaced by:

explode"-21,-19,-12,-8,8,12,19,21"

explode"-21,-19,-12,-8,8,12,19,21"

gasp What? What function calls does this work on?


From the Lua manual:

> A call of the form f{fields} is syntactic sugar for f({fields}); that is, the argument list is a single new table. A call of the form f'string' (or f"string" or f[[string]]) is syntactic sugar for f('string'); that is, the argument list is a single literal string.


1

Tip: If you leave off the third argument to sub(), it's automatically assumed you want everything up to the end of the string.

So sub("Felice",3) gives you "lice".

Ew.


Hey Krystman, this is a really cool chess game. The game has a lot of polish. I like all the animations and presentation of the game. The AI is challenging, maybe 1200 ELO? I could not finish my first game, I was preparing to promote and the game crashed. Unfortunately I don't have a screen grab of the board when this happened, only a screen grab of the error.

Error:
http://snpy.in/8dUg6f


1

Also, if you have a valid number in a string, you don't have to convert it to a number for flr(). The code inside flr() will do it for you.

> print(flr("1.5"))
1

Most math functions are willing to take numeric strings, including any format that lua supports, like hex.

> print( cos(".125") )
0.7071

> print( abs("-12.34") )
12.34

> print( band("0xfff0", "0x0fff") )
4080    -- 0x0ff0

> print( bor("0b11110000", "0b00001111") )
255

@bbsamurai Oof. That's a serious bug. When did it happen? On your turn or on the computer's? Did it happen when you moved the pawn to promote or at some other time?


1

Update: Uploaded Version 3. Fixed this nasty bug:

Also, I tried to reproduce @bbsamurai's issue but couldn't. I will try a few more things. But in the meantime, this new version will continue displaying the board state in case of a crash. So should the game crash on you please take a screenshot and post it here!


@Krystman: It happened on the AI's turn. The promotion was unavoidable. This error has not happened again, especially since the last update.

I really like the game feel. I think this would be great on mobile.

Here's me getting a victory after a few tries.


Oh man! You did it! Congrats! I did some testing and the AI's ELO seems to be around 1500. It will beat a Level 3 Stockfish.

I'm pretty sure your bug is still in there. I had another tester report they had a crash. But sadly, they didn't take a screenshot either.

But because the bug is so rare, I have some ideas what the issue could be. Still investigating...


1

Seems like the AI is just above 1500 ELO


Hi Krystman, I wanted to include this game on playpico.com, but it appears to be domain locked to prevent piracy. If you don't want me to include it on PlayPico, that's totally cool, but if you're okay with it being added, would you be kind enough to add that domain to the exclusions list?

If you're not familiar with the site, here's a rundown:

PlayPico was started by me in 2016, and has been around for almost 2 years. All games on there have their code completely untouched, authors fully credited and linked, and BBS descriptions left intact; it's not a site for pirating, hacking, or otherwise, just a list of only games, with various features for helping visitors discover new ones that may otherwise get lost or buried on other sites (such as 24 random games featured every week, and various searching/sorting/filtering features). The site is completely free and ad-free as well, and is just a labor of love.


your youtube tutorials are helping a bunch man cheers


With some help from Alex Huang on Twitter I was finally able to fix a nasty bug that would occasionally cause the game to crash. It turns out the bug would occur if the AI had to evaluate a position where the a king was in the upper left corner of the board. Understandably, it was a pretty rare bug so I'm quite relieved I was finally able to track it down.

With this specific bug fixed I'm also publishing the game more widely. I've uploaded it to Kongregate and Newgrounds. If you'd like, you could help me out by giving the game an upvote on those platforms!

https://www.kongregate.com/games/Krystman/pico-checkmate

https://www.newgrounds.com/portal/view/713669

Also @Scathe: I whitelisted the game for playpico.com! Go ahead and publish it there too!


3

Update: With the game being out on other platforms I've gotten more feedback. One player on Newgrounds noticed that in some circumstances, you could castle with the opposing player's piece. Ooops!

That bug was now fixed!


I decided to write a little about how I made this game. This is the first article on the design:

https://krystman.itch.io/pico-checkmate/devlog/32738/making-chess-in-pico-8-1-design



Okay, this is NICE ! Seems to be smarter than your average bear and speedy too. Surprising in independent interpretive programming languages.

You DEFINITELY need an option to SAVE GAME. I'm working on some ways of dicing up that infernal 256-bytes, but you are in luck !

You can save neatly 64-numbers, just the board size, quite easily to standard storage.


So cool! Thanks!


In playing this more, I'm noticing something. It seems right after you make your move, your opponent knows IMMEDIATELY what piece to move of theirs by highlighting it - but then takes time "..." to determine where it should go.

If you can apply its way of immediately knowing which piece to move during turns, could that somehow be a way of speeding up the intelligence of where that same piece wants to move to ?


@Krystman explains this in the second article above:

> It takes some time to move the cursor to the desired piece. I decided to exploit this to mask some of the "thinking" the AI is doing. The AI will start moving the cursor while it's still calculating their move. Even before the calculations are done, the AI will already have a preliminary candidate for the possible best move. I let the AI move the cursor to that candidate. If the candidate turns out to be the best move, it will look as if the AI took less time to calculate the move than it actually did. If the AI abandons its first candidate for a better move, it will look as if the AI "changed its mind". It makes the AI look more human. On a more technical level, it also gives me some insights into the AIs "thought process".


Well, with that in mind, I suppose you could slow the computer cursor down a bit, not too much, to give the illusion of deep thought. :)

Still, a marvel of a cart. Were the PICO a true console of yesteryear, back with the Atari 2600 and Sinclair 1000, I would definitely buy this game to add to my library.


This is very nice! First try, it kicked my butt. The animations and art are amazing. I'll definitely be revisiting this one frequently!


There should perhaps be a very slight amount of randomization in the computer's choices - it's literally impossible for the computer to play itself as the game fails to end in exactly the same way every single time =)


I was thinking of a way to speed up the computer tremendously. Now we have two functions that operate independently of each other.

That of _DRAW() and _UPDATE().

Would it be possible to limit the actions of _DRAW().

In other code, every time you use FLIP() you give time away from your code to the computer to draw the screen and update the input status (keyboard and mouse). In loops absent of this command and also absent of functions _UPDATE() and _DRAW() the computer runs maximum speed.

I don't know if you can limit the actions of _UPDATE() or _DRAW(), but if you can, it should speed up the computer's thinking of a valid move considerably.


@dw817 there's always the obvious method of surrounding the entire _DRAW() event code in an

 "if(AI_COMPUTING==FALSE)"

check.


Well I'm not sure, CableDragon. Even by bypassing the entire _DRAW() function, doesn't it still get time to do an internal FLIP() automatically every 30- or 60-frames per second ?

This is one of the reasons I haven't adopted _UPDATE() and DRAW() as you get to choose when and where the screen is updated, solely through the command of FLIP(). Only then would the screen be updated and input status be read and no other time.

GFA was the same way. That language ran FAST, so fast that if you did actually forget a PEEKEVENT in your code periodically (same as FLIP()) that you could hang the whole executed program and require task manager to remove it.


Great little chess game! So juicy and fun!

Only thing I'd love is Easy, Medium, Hard levels to change how many ply it looks ahead. Oh, and chess notation shown on the top line as you or the AI are selecting/moving.

Awesome job, dude!


Ayy I beat it first try :v

Great AI, definitely around stockfish 3 strength.
Just something to note, you mentioned it doesn't recognise draw by threefold repetition but the AI still tries to preform a draw by repetition in losing positions


I play chess as well as a toaster but this is nice.


Beat it! Fantastic Chess game. Gives over-the-board chess some serious competition ;)


Another great game to add for me and my friends to play in study hall with nothing to do!


As a chess fan, this is amazing!


Awesome work/game. I go to a chess club so i'm going to play a lot of times to practice. Thank you.


Great game and write-up! Really enojoyed seeing your process, the concept of juiciness explains why many puzzle games here are so enjoyable.


Great game and absolutely awesome computer! I really like that the computer is able to look ahead and prepare for what might come. However, I noticed one problem. I was screwing around in human vs. human mode and reduced the board to just the kings. Now, I am well aware that the chances of this happening in a real game are highly unlikely, but because of the "safety" precautions, there is no way to win the game and you would be forced to quit.


Love the game,good graphics and I love chess I'm not good enough to beat the AI.(It would be cool if intelligence levels for the AI could be changed,but I don't know if there's space to add that)


Wow. Reading the articles. Amazing stuff, ever thought about writing a book or something? Where do I learn, apart from the LazyDevs vids?


omg that took 5 years, the ai is way too good for me lol


Really great aesthetic and very fun. Kicked my butt the first game I played.


Very fun and very juicy, the polish is perfect. Even though the game is now 3 years old, so you have probably stopped updating it, controls for P2 when playing in human VS human mode would be nice? :) It would make playing with my sister easier


don't know why but watching the AI play against another AI is funny. they are evenly matched.
let it sit, then came back and they were still fighting. :l


YOOO this game has En Passant, thats so awesome


this is so fun! the animations are cute and nice too :)



[Please log in to post a comment]