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.
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
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
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
I'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.
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 ;)
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.
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?
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)
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.)
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!
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..
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.
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.
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.
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 Óscar will add more features/intelligence one day)
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.
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.
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.
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
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)
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.
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.
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.
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).
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.
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.
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.
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.
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
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?)
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.
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.
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.
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!
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.
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
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.
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.
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.
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...
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).
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].
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.
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.
157 comments
[ 3.7 ms ] story [ 200 ms ] threadBut that’s the problem with solved games: You compete on the familiarity with and memorization of established patterns.
https://nanochess.org/chess3.html
https://github.com/nanochess/bootOS
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.
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?
https://www.lulu.com/shop/oscar-toledo-gutierrez/toledo-nano...
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 .
"NB: if puzzled by a pawn move, please check for en passant before reporting a bug"
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..
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.
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.
really cool
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!
Regardless, this is so cool.
Still looks a bit weird on my iPad (huge black pawns), but easier to beat because it’s easier to see the board.
Loved the pixel art and all too, lulls you in. It is a little hard to tell from the pieces alone which they are.
Because it doesn't have depth it can be tricked with tactics setups (forks, discoveries etc).
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.
The "How it works" link says it looks ahead 4 moves, that's probably 2 ply.
Can you say what the lookahead is like? Is it a version of minimax?
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
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.
It seems like there's broad agreement on skill level.
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!
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)
Your comment reminded me of one of my favorite scenes from the great movie, Big Daddy.
https://youtu.be/KnbL56_S9rQ
The truth is you've been crushed by 1kb javascript code :)
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.
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).
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
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.