10 ms·
The Kilobyte’s Gambit
- crazypython 6y agoI loved the visuals.
- WalterGR 6y agoIf you’re into retro CGA-like graphics, you should check the link even if you’re not into chess. It’s really quite well done.
- flatiron 6y agoThe pieces could be a little dissimilar but I agree. Amazon throw back.
- Laforet 6y agoWell this is certainly very cool. It reacts well enough to my moves but I get the feeling that it does not know any of the established openings so each game starts a bit weird. Will keep going and try to beat it though.
- Swizec 6y agoIf it keeps winning, maybe the established openings aren’t that useful :P But that’s the problem with solved games: You compete on the familiarity with and memorization of established patterns.
- YawningAngel 6y agoChess isn't a solved game and the established openings are good enough that playing without prior analysis is extremely difficult for even the best human players
- thom 6y agoIf anyone’s interested in the guts of this, you can get Oscar Toledo’s annotated source of the C version of Nanochess at: https://nanochess.org/chess3.html https://nanochess.org/chess3.html
- istjohn 6y agoHe also wrote bootOS, "a monolithic operating system in 512 bytes of x86 machine code." https://github.com/nanochess/bootOS https://github.com/nanochess/bootOS
- andrelaszlo 6y agoI'm a novice player but I reached a stalemate in my first game. I am not a big fan of the graphics, they're really really cool but I made at least two big mistakes because I misread the pieces - and now I have a headache :D
- h0l0cube 6y agoYeah, the pieces are a bit illegible. I accidentally moved my Queen instead of castling, which is when I quit. Otherwise pretty impressive
- deleted 6y ago[deleted]
- bonzini 6y agoThe pieces were meant to be displayed on a composite (NTSC) display rather than with 4-color CGA graphics. Check out the Twitter thread at https://mobile.twitter.com/pinot/status/1330544777847332879 https://mobile.twitter.com/pinot/status/1330544777847332879.
- h0l0cube 6y agoDon't get me wrong, I dig the retro art style, but at that resolution, dithering gets in the way of legibility. I think for the chess pieces themselves it makes more sense to trade off some of the realism (i.e., shading, specular) to better communicate the shapes, particularly as it's so important to game play
- alisonkisk 6y agoThe point of composite is they the dithering isn't visible on a proper monitor, because compositing creates an antialiasing effect.
- h0l0cube 6y agoI'm aware of that composite signals tended to bleed pixels horizontally. I used to draw my own pixel art when I owned an Amiga (though to be fair, the monitors were often sharper, and I wasn't always using composite). I grant perhaps it's more legible on a composite display, though I think that's a hard thing to appreciate when delivered on the modern web.
- alkonaut 6y agoWow it took me 40 or so attempts to beat it. I’m a chess novice but you’d think a human novice should be able to beat a small chunk of JavaScript. This code must be pretty compact even if expanded to readable form? Is there a repo anywhere with this type of chess engine explained and expanded to human readable commented code?
- burkaman 6y agohttps://nanochess.org/ https://nanochess.org/ https://www.lulu.com/shop/oscar-toledo-gutierrez/toledo-nanochess-the-commented-source-code/hardcover/product-21429040.html https://www.lulu.com/shop/oscar-toledo-gutierrez/toledo-nano...
- SatvikBeri 6y agoThe javascript engine: https://nanochess.org/chess4.html#sour https://nanochess.org/chess4.html#sour The slightly older C version: https://nanochess.org/chess1.html https://nanochess.org/chess1.html The author wrote a book commenting and explaining the C version, it's 170 pages long! https://nanochess.org/chess3.html#book https://nanochess.org/chess3.html#book Edit: MicroMax is a close competitor that also has very good explanations on their website https://home.hccnet.nl/h.g.muller/max-src2.html https://home.hccnet.nl/h.g.muller/max-src2.html .
- bluedino 6y agoYou’d be impressed by the old 8 bit chess computers, you should check them out!
- gnarcoregrizz 6y agoI can't distinguish the pieces well enough to play a good game. Anyone have this plugged into lichess?
- ziml77 6y agoGlad I'm not the only one. My vision isn't bad but the way the black pieces are shaded and shaped makes me have to put conscious effort into identifying them. (Not that I'd be able to beat this thing anyway)
- LorenPechtel 6y agoYup, my first try I made two major blunders due to confusing knights and bishops. Beat it easily on my second try. (When my allergies aren't acting up I'm 1600 on Gameknot.)
- user_error 6y agoIt was great to play against the AI this weekend, rekindled some of the love I have for chess. I know the rules but I'm a very novice player. Took me 6 tries to checkmate. I cheered loudly. The style is very neat as well!
- bschne 6y agoI loved this footnote: "NB: if puzzled by a pawn move, please check for en passant before reporting a bug"
- deleted 6y ago[deleted]
- mattround 6y agoI added it out of desperation after around 100 people on reddit claimed the black pawns are "cheating".
- dwohnitmok 6y agoDid it help? Or do people still complain about it?
- ehsankia 6y agoIn my experience having small webapps, it hardly helps. I literally added a huge modal popup on my feedback button specifically saying "DO NOT MESSAGE ME ABOUT X" before continuing and I still get dozens a week. Even on reddit, when you get a high ranked comment, you will often get the same reply over and over again, even though a similar response is already the highest ranked reply to yours. There are people who just want to blurt out their opinion regardless of whether it's original or not..
- netflixandkill 6y agoReddit sadly went the way of mostly write-only microblogging a long time ago now. I'm not sure what the solution is between invite only subs or heavy and time consuming moderation, and random comments that are just people thinking out loud, as using any sort of karma metrics would be useless when you can get 20-30k off a no effort post in a popular sub, but I also doubt that reddit the company spends much time worrying about it. I can't remember who I stole "the internet is write only" but it's felt very true as audience size exploded. Perhaps the worst part is that it's self reinforcing in either direction, and few people ever leave the agora unless they delve into niche subjects, so they bring the agora mentality with them.
- iamevn 6y agoit went with a non-standard response to a queen's pawn opening and lost most of the pawns on the kingside falling into checkmate after getting baited into a trade that was good for it on material but devestating on position really cool
- CamelCaseName 6y agoThat was a blast! I'll echo the sentiment that the pieces were hard to differentiate, but the aesthetic was awesome. Seems like it only really looks out one move ahead, taking whatever has the most value, otherwise protecting. Thanks for sharing! ...now imagine what you could do with 2048 bytes!
- mattround 6y agoIt looks 4 steps ahead with a points system for pieces & positions, but has no sense of broader strategy. (The original code looked ahead 3 moves, but browsers & devices have improved a lot in the last 11 years)
- adflux 6y agoLove it, hard to discern pieces though. Would guess this thing has an elo of 400-800, coming from someone who is 1800 so take it with a grain of salt
- z5h 6y agoBeautiful work. I've been doing a lot of chess puzzles this last year and apparently it's paid off quite well. An easy mate. Though I've been inspired to make a (less beautiful) chess game.
- himanshujaju 6y agoThe pieces weren't well distinguishable, but I managed to win at first go :)
- pdar4123 6y agoThe interface makes this impossible - it’s pretty but unplayable. Please post a simple 2d interface
- mattround 6y agoOriginal engine's here (only looks ahead 3 steps instead of 4) https://nanochess.org/archive/tiny_chess_2.html https://nanochess.org/archive/tiny_chess_2.html
- Waterluvian 6y agoIf the engine is well separated from the UI it would be neat to have a simple version using the Unicode chess set. Regardless, this is so cool.
- mlyle 6y agoYes, I'm not a fan of the CGA graphics at all. I blundered in my first game because I misinterpreted the piece graphics.
- Someone 6y agoI think https://nanochess.org/archive/tiny_chess_1.html https://nanochess.org/archive/tiny_chess_1.html is that, possibly for an older/newer version of the engine (found via https://nanochess.org/chess4.html#sour https://nanochess.org/chess4.html#sour, which SatvikBeri mentioned in a different message) Still looks a bit weird on my iPad (huge black pawns), but easier to beat because it’s easier to see the board.
- mattround 6y agoThis is the same engine but doesn't look quite as far ahead https://nanochess.org/archive/tiny_chess_2.html https://nanochess.org/archive/tiny_chess_2.html
- winter_squirrel 6y agoI think that 90% of the difficulty of beating this engine is avoiding moving the wrong pieces haha
- rcgorton 6y agoInvoking a chess engine via '1024 bytes of javascript' is drivel.
- beaconstudios 6y agoNice, it's impressive that it can make some coherent move sequences in such short code. I beat it pretty quickly on the first try (it doesn't stand up well to tactics) but the degree of game sense it does have is impressive.
- pbhjpbhj 6y agoI lost the first game, it goes hard (charges forward acquiring material seemingly without any strategy). I'm a relative noob, but that's the first time I've been able to just adjust my style and easily win on the follow up. Impressive feat, thankfully I wasn't too 'humiliated' by it. Personally didn't spot any sequences in its play. Loved the pixel art and all too, lulls you in. It is a little hard to tell from the pieces alone which they are.
- beaconstudios 6y agoThere's some very basic move sequences I saw (moving into position for an attack and then executing, for example) but I also saw some odd moves such as opening with 1. ...a5 Because it doesn't have depth it can be tricked with tactics setups (forks, discoveries etc).
- GCA10 6y agoNice work! I'm about 1850 in Lichess blitz, and it played at the level of an earnest 12 year old, which is actually meant as a compliment. It got crazy with its kingside pawns in the opening (no book knowledge), lost material pretty steadily and was checkmated down a queen, bishop and two pawns by move 25. But it developed some pieces sensibly, made obvious recaptures and was not reckless about king safety. It avoided pointless toggling moves and suicidal piece jettisoning. You've earned the right to be a proud papa on this one.
- chki 6y agoI agree. I'm at a similar chess rating level, I would add that it is very weak in the endgame. I guess if it only looks four moves into the future it's difficult to see pawn promotions.
- SubiculumCode 6y agoI'm of similar rating on Lichess, and agree with the above comments. To be honest, any difficulties I encountered were due to unfamiliarity with the look of the pieces. Still, it was fun.
- register 6y agoIt looks one-two semi-moves ahead at maximum.
- YeGoblynQueenne 6y ago"ply" :) The "How it works" link says it looks ahead 4 moves, that's probably 2 ply.
- mattround 6y agoI was a bit lax using 'moves', it's 4 ply, so that's 2 full moves.
- 6y ago
- pretendscholar 6y agoKnowing an opening helps a lot. I beat it on my first attempt with a london system opening. I've also been playing for about a year and a half and I'm at a 1600 rating on lichess in blitz.
- MarcellusDrum 6y agoI'm a "meh" chess player, but I do know proper openings and endgames, and I was bested by this engine. But for some reason, when I was only left with a King and a rook, it started blundering all its pieces: Bishop, a rook, 3 pawns, and a knight. It was left with only a king and knight. And by blundered, I don't mean "made a bad move that I was able to take advantage of", I mean literally placed their rook infront of my pawn kind of blunder.
- adrianmonk 6y agoYeah, I managed to trap it into giving up its queen. I was pretty happy. Then I moved my queen to a spot where I did not realize its bishop could just scoot straight through the forest and take my queen. Oops.
- d1str0 6y agoYup. Bishops and pawns are sneaky with these graphics. I also Botez gambited
- sdenton4 6y agoI think I've seen it start blundering more when the prospects are otherwise very bleak - if the best available move (with a depth-4 search) leads to a mate, who cares if you sacrifice a rook? I wonder if there was a quicker route to a mate you'd missed...
- TMWNN 6y agoHighly relevant: 1K ZX Chess (1982 - https://en.wikipedia.org/wiki/1K_ZX_Chess https://en.wikipedia.org/wiki/1K_ZX_Chess ), a full chess AI + graphical UI for ZX81 in 672 bytes.
- joshuamorton 6y agoI'm about 1600 lichess, and this was a pretty easy conversion for me. It started by moving the a and h pawns in response to 1e4, which let me get center control and some advantageous pawn pickups. Second game I got threefold while down a rook in a completely lost position (which I'll blame in part on the graphics, but was mostly me blundering).
- jules 6y agoIt lets me move all of the 4 center pawns two squares forward :) Nonetheless, it's very impressive how well it plays with such a small amount of code!
- The_rationalist 6y agoIf I remember correctly the size of DNA is ~100MB
- ejolto 6y agoThis statement doesn't make much sense to me. Is there a theoretical limit to the length of DNA, or do you mean that human DNA is ~100MB? The human genome is about 6.4 billion base pairs, where each base pair is represented by the letters: Adenine (A), Thymine (T), Cytosine (C), and Guanine (G), i.e. 2-bits. 6,4 billion is then 6.4E9*2 = 1.28E10 bits = 1.28E10/8 bytes = 1600 MB. Or 800 MB if you count the bases as pairs of two. Polychaos dubium's DNA is over 200 times as long as human DNA[0]. [0]: https://en.wikipedia.org/wiki/Polychaos_dubium https://en.wikipedia.org/wiki/Polychaos_dubium
- The_rationalist 6y agoI obviously meant human DNA. Thanks for doing the calculus however given that less than 1% of DNA actually has a coding role then it means that a human can be usefully encoded in 8MB.
- jamesgreenleaf 6y agoThis was surprisingly hard for such a small program. I haven't played chess in a long time, but was able to beat it on the first try, after dancing around the computer's very irritating queen for a while.
- taftster 6y agoMy problem with this is that the colors make it hard to see the board. I get caught off by missing a long attack vector or a simple exchange. But this is overall an amazing accomplishment. I've played several good games with it so far.
- mjthompson 6y agoI can't speak for OP, but I doubt this is intended to replace LiChess. It's a uniquely designed proof of concept and a great one. We can give it a creative licence.
- TylerE 6y agoReally the piece design is actively user hostile for any of us with less than perfect vision. In particular the pawns and bishops are way too similar, especially black.
- bluedino 6y agoIt’s a CGA palette
- SMFloris 6y agoLoved it! It gets crazy with the pawns, I was so surprised. The visuals of the game are so and so, but they are really cool nonetheless. Two thumbs up from me!
- Andrew_nenakhov 6y agoWell, I did beat on the first try, but it's really impressive for such a small program! It didn't make really silly moves and was confused only by rather complex attacks with double threats. Graphics are horrible though, very easy to confuse bishops and knights.
- d1str0 6y agoLost one, won one, I'm a 1350 rapid player on lichess. Of course I would say I lost the first game because of graphics and being hard to tell pawns from bishops, but it definitely wrecked me on the first try. Second try it blundered much more.
- gibybo 6y agoIt took me 4 tries to beat it, and I have a rating of 1300 on lichess.org and 1100 on chess.com. In an effort to guestimate its strength a little more accurately, I had it play the first 4 levels of bots on lichess.org. It comfortably beat the level 3 (1400) bot and got crushed by the level 4 (1700) bot. Combined with beating me 3-1, I would estimate its lichess equivalent Elo rating to be somewhere in the 1400-1500 range.
- anonymousiam 6y agoNo idea what my rating might be. I haven't played in years. I creamed it on the first try. It seems pretty aggressive, but doesn't seem to "think" things through. Pinned his king and forced him to block with his queen after a dozen or so moves, which only delayed the mate by one move. He should have resigned.
- harshanalluru 6y agoI'm around 1050 on chess.com, I could beat it in the very first attempt. It missed pinned checks and lost Queen and almost all of its material. I may say its chess.com rating might be around 600-700.
- harryh 6y agoLooks like it's rated around 1225: https://ccrl.chessdom.com/ccrl/404/cgi/engine_details.cgi?print=Details&each_game=1&eng=Toledo%20Nanochess%20Jan%2F11%2F2010 https://ccrl.chessdom.com/ccrl/404/cgi/engine_details.cgi?pr...
- fjeifisjf 6y agoOn CCRL, which is a separate rating pool/scale. Also, it played too few games to get a reliable rating, as you can see from the erratic performance.
- fjeifisjf 6y agoLichess stockfish bot ratings are completely fake and performance dependent on your local device.
- __s 6y agoDoesn't properly implement pawn promotion, assumes Queen
- d1str0 6y agoIt specifically says this beforehand
- kayson 6y agoI'm curious why it's not deterministic. If I move E4, it seems to respond with one of three openings at random
- cortesoft 6y agoYou can see the Math.random call in the source code: https://nanochess.org/chess4.html#sour https://nanochess.org/chess4.html#sour
- kayson 6y agoThat doesn't answer the question. Yes, it's random, but why? Is it just to avoid repeating move sequences so you can't replay the same game multiple times?
- ghayes 6y agoI assume it's making a value-weighted move. To keep things interesting, you might choose from several moves that have similar EVs, esp. since the system only looks 4 moves deep, so there's uncertainty around how much better a given move actually is.
- cortesoft 6y agoAh, then yes, likely for two reasons.. to prevent the exact same game from happening if you play the same moves, and also as a way to choose between equally weighted (in terms of expected value) moves
- deleted 6y ago[deleted]
- hardlianotion 6y agoThat’s easy. No.
- Fiahil 6y agoI’m 700 or so at chess.com. It took me a few tries but I managed to beat it by exploiting its “appetite” for free pieces! nice !
- gutino 6y agoI beat it! (there has been several years since i played last time)
- thebigman433 6y agoPretty cool game, nice job. It would be significantly better with just a little bit of opening knowledge, but obviously that isnt the point of this anyway. Im 1050 on chess.com and beat it first try, but the program sorta blundered the opening. I played the Queen's Gambit (very fitting)
- shubik22 6y agoThis is awesome. Really impressed at the level of play given the size of the program. Somewhat amusingly, in the game I played, it went all in pushing the flank pawns, also a tendency favored by top Chess engines :)
- MilnerRoute 6y agoI've played that a bunch of times this afternoon -- and succeeded in beating it in a few games. I've been able to grab a few of its pawns early in the game. (I think its weakness is it assigns a low priority to protecting pawns. Or maybe it isn't able to look ahead far enough to see that I've got two attacks on the pawns instead of one.) It also didn't seem to be able to anticipate a "discovered check." It's good at setting up forks -- although at least once it forked me and then when I'd moved my King, didn't take the other piece!
- stefanmichael 6y agoI'm 1200 rating on chess.com and I lost the first game and won the second, the estimated rating of 1225 I've seen on other comments felt about accurate to me as well
- schoen 6y agoSharing other people's amazement that such a tiny amount of code plays so well (I'm an inexperienced, infrequent player and it beat me once and drew once), I was pondering that there's no absolute reason to think that small programs inherently must play games poorly. For many abstract strategy games, you could write an explicit game tree search in a relatively small amount of code and it would, in principle, play perfectly if you somehow gave it enough time to search the whole game tree. (That wouldn't be feasible for most abstract strategy games that human beings like to play, but would for small games like Tic-Tac-Toe, Hexapawn or Octapawn, Nine Men's Morris, maybe Hex on a small board.) In GOFAI (https://en.wikipedia.org/wiki/Symbolic_artificial_intelligence https://en.wikipedia.org/wiki/Symbolic_artificial_intelligen...) there's a clear pattern where "intelligence" in abstract strategy games represents, in part, being able to prune game trees well without having to search them exhaustively. In some cases that means having a good evaluation function for positions, and in other cases having a cleverer search strategy in another way. Thinking about this made me realize that it's not just impressive that this program plays decently while being tiny, but especially that it plays decently and quickly while being tiny.
- SilasX 6y ago>Thinking about this made me realize that it's not just impressive that this program plays decently while being tiny, but especially that it plays decently and quickly while being tiny. Yeah I wonder if there are subfields of chess programing that optimize for that, something like "quality of engine per unit code size".
- kuroguro 6y agoSomewhat related: I was blown away when I first heard the argument that intelligence is basically compression. http://prize.hutter1.net/hfaq.htm#compai http://prize.hutter1.net/hfaq.htm#compai Haven't done any more digging into this but it did give me something to ponder about.
- schoen 6y agoI've heard of the Kolmogorov complexity connection, but I'm not sure I've seen it spelled out as explicitly as this before. Definitely very interesting!
- zdiscov 6y agoI consider myself at a ~beginner+ level. Beat it on my second attempt. IMO this is the right amount of difficulty without being overwhelming for a beginner(or novice), which TBH is the majority the world. This is a great program that I could use as a litmus test for checking if my newbie friends of chess has made satisfactory progress without me playing with a handicap or artificially lowering my gameplay. This program appears to be in the delightful zone for the casual player. Bravo!
- tejasgarde 6y agoWow Really Nice work , Graphics are cool too.
- register 6y agoAt it was expected the program is very very weak. The elo should be around 1100-1200. Based on my game it doesn't see more than 1-2 semimoves ahead and doesn't have an opening repertoire. The evaluation function is weak because the program starts the opening by moving lateral pawns and neglecting good piece development and central control
- deleted 6y ago[deleted]
- jaredtn 6y agoGraphics on this need some serious work. Can't tell the difference between a bishop and a pawn. Would love to play it otherwise.
- vldmrs 6y agoYes, I can beat it. Nice play though.
- drdaeman 6y agoThanks, I hate it. I'm losing every single game (I think I tried like about 30-ish times). If that's how 12-years old are playing them I should probably apply for disability benefits. My naive approach by trying to define safe squares to move pieces to and naive capture goals by exchanging figures of lesser value is not working against this algorithm, I guess I'll probably have better chance if I'd just run the same logic on paper.
- Closi 6y agoYou are using something like the same logic as the algorithm itself and describing how a newcomer to the game would play chess. I think this is what they mean by "12 year old". In fact the algorithm probably beats this strategy as your approach probably doesn't identify 2 move 'tactics'. If you fancy learning more about the game take a look at tactics, and maybe try a tactics trainer. The next level of play is about understanding things like forks and discovered attacks where you aren't assuming that the other player is just going to make huge blunders that give you pieces.
- vletal 6y agoI like the algo, yet the graphics made it hard to read the board for me. The black pieces are a bit hard to distinguish. Cost me two pieces.
- yCloser 6y agoI play at 1400 on lichess, got 3 draws very very impressive
- timonoko 6y agoIncomprehensible scheiße code. I looked around and I like this one because it has "meta-level" definition of movements and liitle bit of strategy. You could implement context-free chess games with varying rules for us congenitally lazy and dull-witted. https://github.com/thomasahle/sunfish/blob/master/sunfish.py https://github.com/thomasahle/sunfish/blob/master/sunfish.py
- ArchieMaclean 6y agoSee also nanochess https://nanochess.org/chess4.html https://nanochess.org/chess4.html
- mfbx9da4 6y agoI can't really tell the difference between bishops and pawns unfortunately.
- deleted 6y ago[deleted]
- EnockNitti 6y agoA very interesting piece if code. But I hate the graphic, lost several games due to me confusing pieces. I used to play some when I was as kid, and some more when the kids were small. Has no idea of my rating. If I remove the games I lost due to me confusing pieces I am up 5-1 and 1 draw. I think I have found out its weaknesses. 1. In situation with pending exchange of several piece the 4 ply algorithm can't check the exchange-chain to its end and therefore makes mistakes. 2. Don't care very much for its pawns, in 2 endgames I was up 2 pawns that I was enabled to promote. 3 As other has pointed out, weak at defending the king in the beginning. 2 wins to what I call "extended" fools mate.
- Sesse__ 6y agoFor a 2 kB challenge, try Micro-Max: https://home.hccnet.nl/h.g.muller/max-src2.html https://home.hccnet.nl/h.g.muller/max-src2.html Beware, it plays at grandmaster strength!
- ChrisArchitect 6y agoIf you liked the retro art vibe -- don't miss the rest of the artwork that inspired this and the physical box mockup! https://www.printmag.com/post/if-the-queen-s-gambit-were-an-80s-ms-dos-chess-game https://www.printmag.com/post/if-the-queen-s-gambit-were-an-... https://twitter.com/pinot/status/1368983829256560648 https://twitter.com/pinot/status/1368983829256560648
- tromp 6y agoThe engine is prone to falling to the following mate in 11: 1 e4 e5 2 Nf3 f6 3 Nxe5 fxe5 4 Qh5+ Ke7 5 Qxe5+ Kf7 6 Bc4+ Kg6 7 Qf5+ Kh6 8 h4 d6 9 d4+ g5 10 hxg5+ Kg7 11 Qf7#