[HN Gopher] The Kilobyte's Gambit
       ___________________________________________________________________
        
       The Kilobyte's Gambit
        
       Author : msszczep2
       Score  : 488 points
       Date   : 2021-03-07 21:49 UTC (1 days ago)
        
 (HTM) web link (vole.wtf)
 (TXT) w3m dump (vole.wtf)
        
       | jaredtn wrote:
       | Graphics on this need some serious work. Can't tell the
       | difference between a bishop and a pawn. Would love to play it
       | otherwise.
        
       | gnarcoregrizz wrote:
       | I can't distinguish the pieces well enough to play a good game.
       | Anyone have this plugged into lichess?
        
         | LorenPechtel wrote:
         | Yup, 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.)
        
         | ziml77 wrote:
         | Glad 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)
        
       | schoen wrote:
       | Sharing 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_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 wrote:
         | >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 wrote:
         | Somewhat related: I was blown away when I first heard the
         | argument that intelligence is basically compression.
         | 
         | 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 wrote:
           | I'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!
        
         | Someone wrote:
         | _"but would for small games like [...] Nine Men 's Morris"_
         | 
         | http://library.msri.org/books/Book29/files/gasser.pdf:
         | 
         |  _"We describe the combination of two search methods used to
         | solve Nine Men's Morris. An improved retrograde analysis
         | algorithm computed endgame databases comprising about 1010
         | states. An 18-ply alpha-beta search then used these databases
         | to prove that the value of the initial position is a draw"_
         | 
         | So they built a database containing all all 7,673,759,269
         | possible positions in the endgame phase (i.e. after all stones
         | are on the board), and then did a full-depth search for the
         | "place stones" phase.
         | 
         | Paper is from 1996, so one might think current hardware could
         | do a full search, but they show (page 10/110) a position with
         | "White to move and win. Mill closure in 187 plies."
         | 
         | So, I don't think this game is small enough to search the full
         | tree. They made it small by first creating an endgame database
         | with 7,673,759,269 endgames, but that database requires over a
         | gigabyte of data ("The hash function we decided to use maps the
         | 7,673,759,269 states into a range of 9,074,932,579 indices.")
        
           | schoen wrote:
           | Thanks for the information! That game is definitely bigger
           | than I thought. (I knew it was solved, but I'd wrongly
           | imagined it was solved by complete game tree search.)
        
       | gibybo wrote:
       | It 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.
        
         | fjeifisjf wrote:
         | Lichess stockfish bot ratings are completely fake and
         | performance dependent on your local device.
        
           | gibybo wrote:
           | Oh I didn't realize they depended on the device they were
           | running on, that's too bad :(
           | 
           | I can reliably beat the 1100 bot and lose to the 1400 bot so
           | they at least seem to be in the ballpark of matching my
           | rating on the site for my hardware though.
        
         | anonymousiam wrote:
         | No 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 wrote:
         | I'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 wrote:
         | Looks like it's rated around 1225:
         | 
         | https://ccrl.chessdom.com/ccrl/404/cgi/engine_details.cgi?pr...
        
           | fjeifisjf wrote:
           | On 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.
        
       | __s wrote:
       | Doesn't properly implement pawn promotion, assumes Queen
        
         | d1str0 wrote:
         | It specifically says this beforehand
        
       | user_error wrote:
       | It 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!
        
       | gutino wrote:
       | I beat it! (there has been several years since i played last
       | time)
        
       | pretendscholar wrote:
       | Knowing 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.
        
       | kayson wrote:
       | I'm curious why it's not deterministic. If I move E4, it seems to
       | respond with one of three openings at random
        
         | [deleted]
        
         | cortesoft wrote:
         | You can see the Math.random call in the source code:
         | https://nanochess.org/chess4.html#sour
        
           | kayson wrote:
           | That 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 wrote:
             | I 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 wrote:
             | Ah, 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
        
       | bschne wrote:
       | I loved this footnote:
       | 
       | "NB: if puzzled by a pawn move, please check for en passant
       | before reporting a bug"
        
         | SilasX wrote:
         | lol I remember when I was little in the 80s, pre-internet, and
         | I played Chessmaster 2000, and I was like, wtf, what just
         | happened? when I first encountered the en passant rule.
        
         | 27182818284 wrote:
         | I noticed chess.com started adding a little pop-up notification
         | about en passant when you use it. I imagine with the huge chess
         | surge going on right now they were getting quite a lot of
         | complaints. Stalemates also prompt the little pop-up
         | notification.
        
           | ZephyrBlu wrote:
           | The first time I got "draw due to repeated move" on Chess.com
           | I was very confused and frustrated.
        
         | mattround wrote:
         | I added it out of desperation after around 100 people on reddit
         | claimed the black pawns are "cheating".
        
           | dwohnitmok wrote:
           | Did it help? Or do people still complain about it?
        
             | ehsankia wrote:
             | In 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 wrote:
               | Reddit 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.
        
               | ehsankia wrote:
               | > it's felt very true as audience size exploded
               | 
               | I think this is the key point. As with most issues on the
               | internet, it's mostly an issue of scale. I assume these
               | problematic users are actually only a very small fraction
               | overall, but as the overall size grows, so does the
               | number of people who belong at the very edge of the bell
               | curve in terms of "normal" behavior.
               | 
               | With scale, any rare issue becomes common enough to be
               | annoying.
        
           | forty wrote:
           | Speaking of rules : I noticed the AI was able to castle even
           | though one of the square in the path was attacked by one of
           | my piece. I'm not a chess expert at all (this AI seems much
           | better than me ^^) but I thought it shouldn't be possible.
        
             | mattround wrote:
             | I wouldn't be surprised if it doesn't cover that, I can
             | imagine it'd be tricky to include without adding tens of
             | bytes (10-20 bytes could be freed up by using slightly
             | hackier function calls to/from the display, so perhaps
             | Oscar will add more features/intelligence one day)
        
             | arnsholt wrote:
             | Was it a long castle? In that case, the squares the rook
             | moves through don't block the move, it's only the squares
             | the king moves through that block the castling move, so f8
             | and g8 for short castle and d8 and c8 for long castle.
        
               | forty wrote:
               | Ah! It might have been that situation indeed, but I don't
               | remember which square was attacked exactly. Good to know
               | :)
        
         | syncsynchalt wrote:
         | For anyone confused, see
         | https://www.reddit.com/r/AnarchyChess/comments/l2d0b7/google...
         | for context.
        
         | [deleted]
        
         | [deleted]
        
         | [deleted]
        
         | mahathu wrote:
         | holy hell.
        
       | thebigman433 wrote:
       | Pretty 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)
        
       | yCloser wrote:
       | I play at 1400 on lichess, got 3 draws
       | 
       | very very impressive
        
       | iamevn wrote:
       | it 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
        
       | vldmrs wrote:
       | Yes, I can beat it. Nice play though.
        
       | MarcellusDrum wrote:
       | I'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 wrote:
         | Yeah, 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 wrote:
           | Yup. Bishops and pawns are sneaky with these graphics. I also
           | Botez gambited
        
         | sdenton4 wrote:
         | I 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...
        
       | CamelCaseName wrote:
       | That 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 wrote:
         | It 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)
        
       | mfbx9da4 wrote:
       | I can't really tell the difference between bishops and pawns
       | unfortunately.
        
       | adflux wrote:
       | Love 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
        
       | Sesse__ wrote:
       | For a 2 kB challenge, try Micro-Max:
       | https://home.hccnet.nl/h.g.muller/max-src2.html
       | 
       | Beware, it plays at grandmaster strength!
        
       | TMWNN wrote:
       | Highly relevant: 1K ZX Chess (1982 -
       | https://en.wikipedia.org/wiki/1K_ZX_Chess ), a full chess AI +
       | graphical UI for ZX81 in 672 bytes.
        
       | joshuamorton wrote:
       | I'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 wrote:
         | It 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 wrote:
       | If I remember correctly the size of DNA is ~100MB
        
         | ejolto wrote:
         | This 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
        
       | hardlianotion wrote:
       | That's easy. No.
        
       | shubik22 wrote:
       | This 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 :)
        
       | z5h wrote:
       | Beautiful 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.
        
       | drdaeman wrote:
       | Thanks, 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 wrote:
         | You 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.
        
       | himanshujaju wrote:
       | The pieces weren't well distinguishable, but I managed to win at
       | first go :)
        
       | jamesgreenleaf wrote:
       | This 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.
        
       | pdar4123 wrote:
       | The interface makes this impossible - it's pretty but unplayable.
       | Please post a simple 2d interface
        
         | mattround wrote:
         | Original engine's here (only looks ahead 3 steps instead of 4)
         | https://nanochess.org/archive/tiny_chess_2.html
        
       | taftster wrote:
       | My 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 wrote:
         | I 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 wrote:
           | Really 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 wrote:
         | It's a CGA palette
        
       | [deleted]
        
       | Waterluvian wrote:
       | If 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.
        
         | winter_squirrel wrote:
         | I think that 90% of the difficulty of beating this engine is
         | avoiding moving the wrong pieces haha
        
         | mlyle wrote:
         | Yes, I'm not a fan of the CGA graphics at all. I blundered in
         | my first game because I misinterpreted the piece graphics.
        
         | Someone wrote:
         | I think 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, 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 wrote:
         | This is the same engine but doesn't look quite as far ahead
         | https://nanochess.org/archive/tiny_chess_2.html
        
       | stefanmichael wrote:
       | I'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
        
       | EnockNitti wrote:
       | A 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.
        
       | SMFloris wrote:
       | Loved 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!
        
       | tejasgarde wrote:
       | Wow Really Nice work , Graphics are cool too.
        
       | vletal wrote:
       | I 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.
        
       | crazypython wrote:
       | I loved the visuals.
        
         | Laforet wrote:
         | Maybe it's just me but enemy pawn and bishop are sometimes very
         | hard to distinguish.
        
           | phkahler wrote:
           | Yeah, I made a trade and then noticed the mistake...
        
       | rcgorton wrote:
       | Invoking a chess engine via '1024 bytes of javascript' is drivel.
        
       | timonoko wrote:
       | Incomprehensible scheisse 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
        
       | beaconstudios wrote:
       | Nice, 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 wrote:
         | I 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 wrote:
           | There'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).
        
       | ArchieMaclean wrote:
       | See also nanochess https://nanochess.org/chess4.html
        
       | WalterGR wrote:
       | If 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 wrote:
         | The pieces could be a little dissimilar but I agree. Amazon
         | throw back.
        
       | Laforet wrote:
       | Well 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 wrote:
         | If 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 wrote:
           | Chess 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
        
       | MilnerRoute wrote:
       | I'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!
        
       | Andrew_nenakhov wrote:
       | Well, 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.
        
       | zdiscov wrote:
       | I 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!
        
       | Fiahil wrote:
       | I'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 !
        
       | ChrisArchitect wrote:
       | If 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-...
       | 
       | https://twitter.com/pinot/status/1368983829256560648
        
       | register wrote:
       | At 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
        
       | GCA10 wrote:
       | Nice 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.
        
         | haskal wrote:
         | If you play a defensive setup like push D, E pawns one step
         | ahead, fianchetto both the bishops, try to castle early, the
         | computer just flings all the pawns forward, even from the king
         | side: https://imgur.com/a/Nt4x7TP
         | 
         | Anti-computer tactics in chess:
         | https://en.wikipedia.org/wiki/Anti-computer_tactics
         | 
         | EDIT: GothamChess used a similar system to defeat a bot:
         | https://www.youtube.com/watch?v=l5MD6hn5PgI (from 1:59)
        
           | sickygnar wrote:
           | the almighty hippopotomus. love playing it against humans too
           | (with limited success)
        
             | jkonline wrote:
             | "Hip... Hip hop... Hip hop Anonymous?"
             | 
             | Your comment reminded me of one of my favorite scenes from
             | the great movie, Big Daddy.
             | 
             | https://youtu.be/KnbL56_S9rQ
        
         | chki wrote:
         | I 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 wrote:
           | I'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 wrote:
           | It looks one-two semi-moves ahead at maximum.
        
             | YeGoblynQueenne wrote:
             | "ply" :)
             | 
             | The "How it works" link says it looks ahead 4 moves, that's
             | probably 2 ply.
        
               | mattround wrote:
               | I was a bit lax using 'moves', it's 4 ply, so that's 2
               | full moves.
        
               | YeGoblynQueenne wrote:
               | Oh, hey, you're the developer, right? Thanks for
               | clarifying :)
               | 
               | Can you say what the lookahead is like? Is it a version
               | of minimax?
        
         | strken wrote:
         | For those of us who have no idea how to play chess, what level
         | does an earnest 12 year old play at?
        
           | [deleted]
        
           | lucb1e wrote:
           | I joined my girlfriend to a chess tournament of the local
           | club once. Old vs. young. They were an adult short, and I
           | know the rules, so I volunteered to play - otherwise there
           | would be a kid without an opponent every round (my plan had
           | been to write some code in a corner, but entertaining the
           | kids, why not right?).
           | 
           | I lost every game. The kids were something like 10 years old.
           | Admittedly, I know little more than the rules, but I expected
           | to at least give one or two of them trouble by playing
           | logical. Not so...
           | 
           | They had the best time, seeing in how many moves they could
           | beat me. In my last game I tried an unusual (okay, stupid)
           | opening hoping to at least break any pattern they have, but
           | that just made me lose even faster. Be weary of 12-year-olds
           | if they're playing in a chess club!
        
             | galkk wrote:
             | Sergei Karjakin became grossmeister at age 12
        
           | nullserver wrote:
           | Was extremely good at 12. But my dad who thought himself good
           | stopped playing after I won a game by taking everything and
           | losing none. I recall seeking so many possibilities, now I
           | stink at it.
        
           | BlackLotus89 wrote:
           | What op probably meant was that the engine knows no theory,
           | but can See when something can be taken and can think a few
           | steps ahead.
           | 
           | Not sure if I agree completly, but since you can win in under
           | 10 moves simply focusing on an attack in the king I know what
           | he means (wasn't quite a fools mate, but couldn't protect the
           | Kings side)
           | 
           | I think that a 12 year old would play Mord reckless and would
           | make more obvious mistakes. I think this is at the level oft
           | a self taught novice that only played against another self
           | taught novice (funny enough I was thinking of when I player
           | chess against my friends when I was 12...) good times
        
             | sdenton4 wrote:
             | Yeah, just tried a fool's mate! It didn't /quite/ work, but
             | pressing on still led to a very early mate, after dealing
             | with an inconvenient pawn. (I think about 15 moves total?)
        
               | cout wrote:
               | I settled for the second trick newcomers learn -- forking
               | the Queen and the Rook with the Knight. Easy win being up
               | a Rook and Pawn to a Knight, with the black's King
               | uncastled and in the open.
               | 
               | I expected it to play like Ed's Chess on DOS, which I
               | always had trouble beating. IIRC that engine looks 3-4
               | moves ahead usually, but 6-7 moves ahead when it needs
               | to. No idea how big the equivalent JS would be.
        
               | fjeifisjf wrote:
               | Looking ahead more moves requires zero more code -- depth
               | is a loop variable.
        
               | lgeorget wrote:
               | Well the deeper you look, the more clever you need to be
               | about pruning your branches and exploring the search
               | space, so I would guess it does require more code.
        
             | jrumbut wrote:
             | I'm getting a kick out of this thread because, having
             | hardly played chess since age 12, this game instantly
             | reminded me of games in the middle school library.
             | 
             | It seems like there's broad agreement on skill level.
        
         | Vaslo wrote:
         | I played like an earnest 3 year old I guess and lost.
        
           | lgeorget wrote:
           | There are some pretty good three-year-old players out
           | there... https://youtu.be/2N4t0EBSg1w
        
         | jbluepolarbear wrote:
         | It's a pretty decent model for the size. If I played like I've
         | never played before it beats me pretty well, if I play
         | defensive at all it gives me pieces until I checkmate.
        
         | angry_octet wrote:
         | What you're saying is I'm getting crushed by an earnest 12 year
         | old. Oh dear.
        
           | dandanua wrote:
           | There are 12 years old grandmasters in the history of chess.
           | 
           | The truth is you've been crushed by 1kb javascript code :)
        
         | radmuzom wrote:
         | I just checkmated in seven moves. e4 h5 Bc4 e5 Qf3 Qe7 Nh3 g5
         | Nxg5 QxG5 Qxf7+ Kd8 Qxf8+mate
        
       | d1str0 wrote:
       | Lost 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.
        
       | thom wrote:
       | If 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
        
         | istjohn wrote:
         | He also wrote bootOS, "a monolithic operating system in 512
         | bytes of x86 machine code."
         | 
         | https://github.com/nanochess/bootOS
        
       | [deleted]
        
       | andrelaszlo wrote:
       | I'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 wrote:
         | Yeah, the pieces are a bit illegible. I accidentally moved my
         | Queen instead of castling, which is when I quit. Otherwise
         | pretty impressive
        
           | [deleted]
        
           | bonzini wrote:
           | The 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.
        
             | h0l0cube wrote:
             | Don'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
        
         | haskal wrote:
         | Bishop looks similar to a pawn unless you look closely.
        
         | fjeifisjf wrote:
         | It's common to draw too, as it tends to do 3 move repetition,
         | perhaps to avoid losing material.
         | 
         | When I finally beat it, it seemed to let me fork it's pieces in
         | the corner, and then in endgame, it knows nothing about the
         | positional strategy to avoid forks or mating combinations,
         | since it only has 4 move lookahead. It let me material with
         | king and rook even though it had a knight that could have
         | interfered.
        
         | cout wrote:
         | I thought the graphics were brilliant. Reminded me of playing
         | Battle Chess on 4-color CGA.
        
           | rob74 wrote:
           | Ok, maybe if you have fond memories of playing CGA games...
           | for everyone else, those colors (especially the cyan/magenta
           | palette) are just a garish eyesore. But I guess the engine
           | needs every advantage it can get ;)
        
       | alkonaut wrote:
       | Wow 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 wrote:
         | https://nanochess.org/
         | 
         | https://www.lulu.com/shop/oscar-toledo-gutierrez/toledo-nano...
        
         | SatvikBeri wrote:
         | The javascript engine: https://nanochess.org/chess4.html#sour
         | 
         | The slightly older C version: 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
         | 
         | 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 .
        
         | bluedino wrote:
         | You'd be impressed by the old 8 bit chess computers, you should
         | check them out!
        
       ___________________________________________________________________
       (page generated 2021-03-08 23:02 UTC)