Live data from Hacker News

How to build a chess engine

chessengines.org

41–50 of 58 posts

Re: How to build a chess engine

#41

horrible website, scrolling doesn’t work

Yes it does.

It works but it completely breaks standard behavior.

Arrow keys can work normally, or select paragraph, or do nothing, or behave erratically.

Page-up/down make work or may not work, and may have some weird interaction with the arrow keys.

The scrollbar is nonstandard on Chrome. It is not completely broken but the mouse pointer is wrong.

Mouse-based scrolling works, it is the only thing that seems to work as expected.

Reader mode doesn't work.

I don't understand why websites go out of their way to reimplement perfectly good browser behavior. I am sure it is a lot of hard work, and it is almost always done poorly, in fact, I am not sure there is a way of doing it correctly.

Re: How to build a chess engine

#42
This is a wonderful article and I really enjoyed the graphs and the clear explanations.

I wrote a simple chess engine in C and then ported it to C++ [1]. It doesn't use transposition tables or quiescence search. Instead of that, I simply search only to depth=1 and then even depths (2, 4, 6...) after that, which tends to limit the horizon effect. It's not that sophisticated, but I usually lose against it. Even so, it's fun when I pull off a win.

I even tried porting it to web assembly [2]. It mostly works, but the display code still has a bug where the interface disappears sometimes, and I'm still trying to figure out why. Also it doesn't work on mobile browsers I've tried.

[1] https://github.com/dmeybohm/wisdom-chess

[2] https://wisdom-chess.netlify.app/

Re: How to build a chess engine

#43

Earlier quoted context omitted.

Exactly, that's why I noted "Unless in the Chess industry ...", the details of which I don't know. I only know a bit about general game making (I've tried Godot and GameMaker, some friends make games and we talk) so this was my opinion from a more general game point of view. But still, from that Wikipedia description "a chess engine is a computer program that analyzes chess or chess variant positions, and generates a…

Chess Engine - is a well established term in the field. Position estimation and move generation is the hardest and most important aspect of a chess engine. In this sense chess.js may do many useful things, except the thing that would make it an "engine". > Maybe "How to build a Chess Automaton/AI Player" would be a better title? Unless in the Chess industry the "chess engine" refers to the machine player, which I do…

Yes, I said it because if it got me by surprise, I guessed it'd get a lot of people by surprise in HN as well. Agreed with that country analogy, but I believe this being a "Hacker News forum" and not "Chess news" the analogy would be more like if a foreigner came to my country and used a word, that has a meaning in their own country, but has a different meaning in my language. I would suggest them to adapt it to the local language, or explain to my friends what he's trying to say so there's no misunderstanding.

As another commenter said "FWIW I think that without having encountered the term ('chess engine') before, connecting chess ~ game and so chess engine ~> chess game engine is a pretty reasonable path to take in interpreting unfamiliar jargon."

Re: How to build a chess engine

#45
post #28
post #21

Earlier quoted context omitted.

I don't agree with the reasoning in either of the other two answers you've been given, but Shannon (1950) gave the number of chess positions as somewhere around 10^43, so 150+ bits. The position accounts for almost all of the state. You could do better with variable-length encodings and perhaps represent all "interesting" "plausible" positions in 64 bits, but as others said, compactness is really not a top priority i…

Shannon's estimate was based on very primitive methods; by generating random positions and using fairly advanced methods to see whether they are legal or not (ie., can you construct a proof game for it, or prove that it could never happen), you will get much closer. A group of people have been working on this, and their current best estimate is (4.822 +- 0.028) * 10^44, or a bit over 148 bits. (Amazingly enough, Shan…

> a bit over 148 bits

That would be 149 bits!

Re: How to build a chess engine

#46
post #35

One day I'd like to write a rubbish Chess Engine purely for personal use, so that I can play chess against the computer and actually have a good probability of winning, instead of getting thrashed even on the 'easy' setting. The way my brain works, the act of writing the engine would probably also level up my chess playing skills as a side benefit.

Writing an engine you can beat is easy.

The hard part is writing an engine that you can barely beat, which is what would give most people the most enjoyable experience.

Usually what ends up happening is that you either get an engine you can easily trounce, or you get an engine that thoroughly outplays you on most moves but occasionally throws in a massive blunder.

Re: How to build a chess engine

#47
Can highly recommend this article. I wrote a small chess engine for fun, mostly during a long plane flight back in 2018 when I had no internet access.

My process for writing the engine followed almost exactly the series of steps laid out in this article. The key improvement that I made was to add quiescence search with null move pruning. After I added that, it became quite tricky to beat (for my ~1450 lichess rated self). It definitely results in an engine that is extremely greedy, and almost anti-positional, but very tricky to prove wrong.

You can check it out at https://github.com/jeremysalwen/grubchess.

Re: How to build a chess engine

#48
post #45
post #28

Earlier quoted context omitted.

Shannon's estimate was based on very primitive methods; by generating random positions and using fairly advanced methods to see whether they are legal or not (ie., can you construct a proof game for it, or prove that it could never happen), you will get much closer. A group of people have been working on this, and their current best estimate is (4.822 +- 0.028) * 10^44, or a bit over 148 bits. (Amazingly enough, Shan…

> a bit over 148 bits That would be 149 bits!

Did you double check the math?

Re: How to build a chess engine

#50

Earlier quoted context omitted.

Chess Engine - is a well established term in the field. Position estimation and move generation is the hardest and most important aspect of a chess engine. In this sense chess.js may do many useful things, except the thing that would make it an "engine". > Maybe "How to build a Chess Automaton/AI Player" would be a better title? Unless in the Chess industry the "chess engine" refers to the machine player, which I do…

Yes, I said it because if it got me by surprise, I guessed it'd get a lot of people by surprise in HN as well. Agreed with that country analogy, but I believe this being a "Hacker News forum" and not "Chess news" the analogy would be more like if a foreigner came to my country and used a word, that has a meaning in their own country, but has a different meaning in my language. I would suggest them to adapt it to the…

I think your personal experience with games and game development may predispose you to believe that the majority of HN users share your experience and cultural vocabulary. But judging by the variety of topics discussed here weekly, I think the HN community is much more diverse in its interests than you are aware of. I think we all tend to be unaware of possibilities other than the ones we're accustomed to. (I couldn't have imagined that someone would think "Game Engine" when encountering the term "Chess Engine". For me it's clearly something much closer to the concept of a "Search Engine".)

As you can also see from several replies, there are many people who are familiar with the term. Extending the previous analogy of the foreign country, it's not immediately obvious who here is the native and who is the foreigner.

> As another commenter said "FWIW I think that without having encountered the term ('chess engine') before, connecting chess ~ game and so chess engine ~> chess game engine is a pretty reasonable path to take in interpreting unfamiliar jargon."

I see the following scenario on HN very often: There is some topic, in a less mainstream field, that reaches the front page, and inevitably one of the commenters is annoyed that some term in the headline, a term that happens to be well established in the field, doesn't correspond to their expectations. It's fine to try and interpret unfamiliar jargon, but when the result doesn't match your expectations, why not inform yourself and thus expand your domain of knowledge, instead of proposing an alternative syntax, which will only cause confusion: it will confuse field experts (arguably the target audience), it will confuse newcomers to the field, and it probably won't help the general audience, since we know that naming things is hard, and what may seem clear to you won't be clear to the next person.

Post reply on HN