laurent.orseau
2021-1-16 09:29:48

For speed you should also use bytes rather than vector to avoid the cost of indirection



pihentagy
2021-1-16 12:58:21

What could be the reason not to use the match feature?


sorawee
2021-1-16 15:04:58

The only situation I can think of is that you are modifying core Racket, and (require racket/match) would create a cyclic dependency.


badkins
2021-1-16 16:31:59

@laurent.orseau I did decide to use bytes, but I thought there was no indirection for vectors of immediate values.


badkins
2021-1-16 16:33:09

Thanks. I have come across that. The <https://www.chessprogramming.org/Main_Page|chess programming wiki> has been (a little) helpful also.


badkins
2021-1-16 16:33:39

I have modest goals - I simply want to create an engine good enough to beat me :) I’m probably ~ 1650, or so.


badkins
2021-1-16 16:34:40

So I’m taking an 80/20 approach - I’ll use alpha beta, and I think I’ll have to have at least a small opening book, and I’ll probably extend the depth of search for captures (or other significant moves), but I’m not going to do the fancy stuff initially.


laurent.orseau
2021-1-16 16:52:11

Transposition tables ate going to save you a lot though, i recommend


badkins
2021-1-16 16:55:01

I’ll look into them, but as far as storing positions I’ve searched, it seems like they will have always been searched at a lesser depth, so I’m unsure of the value. I do agree that being able to transpose between book openings might be useful.


badkins
2021-1-16 16:56:36

My first go years ago with Racket used a functional approach out of curiosity - I think that’s doomed to inferiority :) This time I’m mutating the heck out of things and allocating very little, I think it will beat me :)


laurent.orseau
2021-1-16 17:05:46

It’s also relatively easy to implement


laurent.orseau
2021-1-16 17:07:04

(afk) I’m not sure. I don’t think it’s documented, so I wouldn’t rely on it. If it’s documented then go for it i guess


anything
2021-1-16 17:20:29

@badkins By the way, 1650 is not bad at all!:chess_pawn: (In fact, it’s impressive.)


badkins
2021-1-16 17:25:37

It’s not impressive if you knew how long I’ve been playing, and how many hours I’ve spent :)


badkins
2021-1-16 17:26:56

A good friend of mine was only ~ 1,900, but he could beat me every time, and easily, w/o ever looking at the board!!


badkins
2021-1-16 17:27:14

Of course, he does have nearly total recall, so that’s not fair :)


anything
2021-1-16 19:07:39

What’s “recall”? Total recollection of the board? That’s very impressive too. Very curious. I’ve been playing (for fun) for many years too, though I kinda don’t play much anymore, but I never really found a way to understand strategies beyond the obvious ones — such as a good attention. So even though I easily beat everyone that doesn’t really play, I can never beat a player at your level, say. How do people eventually find their ways to such different levels of expertise? In chess, I have no idea. In programming, for example, I was really about to focus on math instead of computer science when I discovered sort of by accident the book HtDP and then I made a whole new career plan — which I have been happily following. So Lisp, Racket and the HtDP authors showed me a way to think that let me see beyond. In chess, I never found such thing. Though, true, I never really read a single book on chess. So maybe that explains. (I did read many books in computer science and programming and so it took really many years until I found something that I could really think it was powerful and beautiful and worth investing on.)


soegaard2
2021-1-16 20:02:51

Is the rating liches, http://chess.com\|chess.com or FIDE?


soegaard2
2021-1-16 20:22:09

The last couple of years, I have been quite fond of playing bullet on Lichess.


soegaard2
2021-1-16 20:23:20

But … er … with your rating - I think your goal is plenty ambitious :slightly_smiling_face:


badkins
2021-1-16 20:56:17

@anything “total recall” as in an extremely good memory - not forgetting things.


badkins
2021-1-16 20:57:08

@soegaard2 I think I got up to 1780 on http://chess.com\|chess.com when I was studying a lot. Now I just play 5 minute blitz games on lichess and have hit 1680, but settled around 1650 if I concentrate :)


badkins
2021-1-16 20:57:53

Engine is looking promising - assuming it’s working ok, it did a ply of 8 in 31 seconds w/ very little gc time. My functional approach never hit 6.


badkins
2021-1-16 20:58:06

With a few smarts, I think a ply of 8 will crush me :)


badkins
2021-1-16 20:58:26

I’ll put the code on github when it’s working.


soegaard2
2021-1-16 21:01:51

I very briefly hit 1663 on Lichess (bullet), but is usually around 1550–1600. The rating suffers, if I play when tired :slightly_smiling_face:


soegaard2
2021-1-16 21:02:24

I’ll look forward to playing your program.


soegaard2
2021-1-16 21:03:01

Have you by chance seen the listings of the old 1–2k bytes programs?


badkins
2021-1-16 21:06:14

No, but I once saw a tiny little Javascript program that was quite good :)


badkins
2021-1-16 21:08:17

lol - I don’t have the main loop yet, so I have to painfully enter moves in code, but I just played d4 and it responded with c5. At first I thought it was a stupid move, and that I have a lot of work to do, but it turns out to be “Benoni Defense” from MCO–13 :)


soegaard2
2021-1-16 21:08:41

Son of sorrows!


soegaard2
2021-1-16 21:15:53

Hmm. I can’t find the program I was thinking of. I’ll send you a link, if I stumble upon it again.


soegaard2
2021-1-16 21:25:16

It might have been this program ny Peter Jennings for the KIM–1 (the KIM–1 was made by Chuck Peddle, the main designer of ohe 6502 cpu, in 1976): http://www.benlo.com/microchess/index.html The manual contains both the algorithm for the evaluation of a board as well as the complete source listing! http://benlo.com/microchess/Kim-1Microchess.html


badkins
2021-1-16 22:03:14

Wow, I just got spanked at ply 7 :) I’m very pleased!


anything
2021-1-17 01:38:33

Lol. Awesome. I have the same dream, I gotta tell you — write a chess engine that beats me and I always knew this was going to be easy to do (I mean beat me, not write it), but I got a long way to go still before I can tackle something like that. Both of you have actually amazing ratings. Years ago I used to play on http://freechess.org\|freechess.org using xboard or winboard. These days I would just anonymously hop on http://lichess.com\|lichess.com and play. Over the years I kinda settled on playing 3 minute matches, but 5 minutes is also very interesting.

I watched a documentary on Claude Shannon some other day. The movie showed a chess machine that would move the real solid pieces in your front of you. I suppose he must have built something like that. Pretty cool.


badkins
2021-1-17 02:16:20

I think the 7 ply was a fluke. I just beat it pretty badly w/ 7 ply. I think it’s because I don’t have any extended search i.e. following captures.


badkins
2021-1-17 02:40:59

Woohoo - using a depth of 8, the program just mated me! I can’t wait to add a few optimizations.


badkins
2021-1-17 02:41:25

Here’s the game: 1. a3 d5 2. d4 Nc6 3. e3 Nf6 4. a4 e5 5. Bb5 Bd7 6. Bxc6 Bxc6 7. dxe5 Ne4 8. f4 Qh4+ 9. g3 Nxg3 10. Nf3 Qh5 11. Rg1 Ne4 12. b3 O-O-O 13. Ke2 f6 14. Bb2 Qe8 15. h4 Qf7 16. Qd4 fxe5 17. Qxa7 b6 18. Nxe5 Qe6 19. Bd4 Bd6 20. Nxc6 Kd7 21. Nxd8 Rxd8 22. Rxg7+ Be7 23. c4 Nc5 24. cxd5 Qh3 25. Bxc5 Qh2+ 26. Kf3 Qh1+ 27. Ke2 Qxd5 28. Rxe7+ Kc6 29. Qxc7#


badkins
2021-1-17 02:41:46

I did make a few questionable moves in a hurry, but it still played a decent game.


badkins
2021-1-17 02:44:14

Stockfish felt White’s 12 move was a blunder giving Black an advantage of about 6 points.


anything
2021-1-17 02:56:23

That is a very decent game. It’s definitely cool. Congrats! Regarding the 12th move, I have no idea why — Stockfish on Lichess does indeed prefer Qe2 on the 12th move.