m8 Dev log and C# experiments

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

mathmoi
Posts: 290
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec

m8 Dev log and C# experiments

Post by mathmoi »

I was inspired to try and write a chess engine using C# in another thread and decided to give it a go.

I'm not sure how far I'll go, but I also wanted to start a dev log thread here a other have done and share my experience and some eperiments I might do along the way.

I just did a first performance experiment, I tried to test if it would be possible to make a struct wrapper around an integral type to make the code more type safe and more expressive. My very limited test seems to imply it will be possible.

I wrote a post about it on my blog. I will try and write about theses eperiments in blog form too as a way to try to become a better writer. As it's probably painfully obvious english is not my first language.

https://www.mathieupage.com/posts/sharper-chess-engine/

My next steps will be to write some bases types and a Board representation.
chessica
Posts: 672
Joined: Thu Aug 11, 2022 11:30 pm
Full name: Esmeralda Pinto

Re: m8 Dev log and C# experiments

Post by chessica »

mathmoi wrote: Tue Nov 14, 2023 4:58 am I was inspired to try and write a chess engine using C# in another thread and decided to give it a go.

I'm not sure how far I'll go, but I also wanted to start a dev log thread here a other have done and share my experience and some eperiments I might do along the way.

I just did a first performance experiment, I tried to test if it would be possible to make a struct wrapper around an integral type to make the code more type safe and more expressive. My very limited test seems to imply it will be possible.

I wrote a post about it on my blog. I will try and write about theses eperiments in blog form too as a way to try to become a better writer. As it's probably painfully obvious english is not my first language.

https://www.mathieupage.com/posts/sharper-chess-engine/

My next steps will be to write some bases types and a Board representation.
[pgn][Event "Test.at"] [Site "PRIVAT-PC"] [Date "2023.11.14"] [Round "1"] [White "Matmoi"] [Black "Adachess"] [Result "0-1"] [BlackElo "2200"] [ECO "D02"] [Opening "Damenbauernspiel"] [Time "09:43:07"] [Variation "2.Nf3 Nc6"] [WhiteElo "2000"] [TimeControl "300"] [Termination "normal"] [PlyCount "120"] [WhiteType "program"] [BlackType "program"] 1. d4 d5 {(2. .. d5 2. Bf4 Nf6 3. e3 Bf5 4. Nc3 e6 5. Nf3 Nc6 6. Bb5) -0.11/1 10} 2. Nf3 Nc6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+ 62. Re1 Qd3+ 63. Ne2 Qh3#) +M5/1 2} 60. Kg2 {(Kg2 Rd4+ Re4 Bxe4+ Kh3 Rd3 h5 Qxh5#) -M4/10 1} Rd3 {(61. .. Rd3+!! 61. Kf1 Rd1+ 62. Re1 Qd3+ 63. Ne2 Qh3#) +M4/1 1 Weiss gibt auf} 0-1 [/pgn]
eduherminio
Posts: 65
Joined: Mon Apr 05, 2021 12:00 am
Full name: Eduardo Caceres

Re: m8 Dev log and C# experiments

Post by eduherminio »

Following closely Mathieu, please keep posting your findings.

You may want to consider using readonly struct in your experiments, where relevant.

PS:
I ended using the following global aliases for some types to make the code clearer, but they don't prevent one from making the type errors you mention in your blog:

Code: Select all

  <ItemGroup>
    <Using Include="System.Int32" Alias="Move" />
    <Using Include="System.UInt64" Alias="BitBoard" />
  </ItemGroup >
  
Author of Lynx chess engine (GitHub, Lichess)
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: m8 Dev log and C# experiments

Post by lithander »

I look forward to following your devlog and already enjoyed the blog post.

I like how you tried to replace integers with custom types that are more typesafe. Personally I didn't go all the way as to make a Square type (because here I think using integer values is well justified and not a hack) but for example Move has always been a struct for me. Oftentimes there is another (lighter) alternative to using structs though: For a Piece-type and many other things I define an enum which is basically defines a set of constants that is stored as integer (or byte) behind the scenes.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
mathmoi
Posts: 290
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec

Re: m8 Dev log and C# experiments

Post by mathmoi »

lithander wrote: Wed Nov 15, 2023 12:02 am I like how you tried to replace integers with custom types that are more typesafe. Personally I didn't go all the way as to make a Square type (because here I think using integer values is well justified and not a hack)...
I agree that it might be somewhat excessive to create structs for File, Rank, and Square, as I plan to do, but there could be advantages. For example, I will override the ToString method for these types, so that while debugging, the debugger will display 'e2' instead of '12'. This approach could also enable something like looping over squares without going over the edge.

Code: Select all

Square sq = Square.a2;
while(sq.IsValid)
{
   // Do Something interesting with sq
   sq = sq.Right;
}
Chessqueen
Posts: 5679
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: m8 Dev log and C# experiments

Post by Chessqueen »

chessica wrote: Tue Nov 14, 2023 9:54 am
mathmoi wrote: Tue Nov 14, 2023 4:58 am I was inspired to try and write a chess engine using C# in another thread and decided to give it a go.

I'm not sure how far I'll go, but I also wanted to start a dev log thread here a other have done and share my experience and some eperiments I might do along the way.

I just did a first performance experiment, I tried to test if it would be possible to make a struct wrapper around an integral type to make the code more type safe and more expressive. My very limited test seems to imply it will be possible.

I wrote a post about it on my blog. I will try and write about theses experiments in blog form too as a way to try to become a better writer. As it's probably painfully obvious English is not my first language.

https://www.mathieupage.com/posts/sharper-chess-engine/

My next steps will be to write some bases types and a Board representation.
NOTE: Next match will be Monarch 1.7 Vs Mamoi both rated around 2050

BikJump Vs Matmoi

Rank Engine Score Bi Ma S-B
1 Bikjump 35.5/51 · ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· · 10=01011=11==111==111111111111110111100011011010=0 540.00
2 Matmoi 14.5/51 01=10100=00==000==000000000000001000011100100101=1 · ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·· · 540.00


50 of 50 games played

Tournament start: 2023.11.10, 06:28:46
Latest update: 2023.11.15, 16:24:07
Site/ Country: DESKTOP-4QNC0GS, United States
Level: 10 Seconds
Hardware: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz with 15.9 GB Memory
Operating system: Windows 10 Home Home Edition (Build 9200) 64 bit
PGN-File: Stockfish14 Vs Berserk12.pgn
Table created with: Arena 3
I am ready to swap brain with Stockfish chip. https://www.facebook.com/share/iHzQpSjc ... tid=oFDknk
Chessqueen
Posts: 5679
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: m8 Dev log and C# experiments

Post by Chessqueen »

These 2 engine will kill each other before they reach 50 games, there will be 2 funerals soon, but I am learning as I watch them destroy each other :mrgreen:

455‑456 Monarch 1.7 2124 +21 −21 50.1% +0.1 18.8% 836
51.7%
457 FrankyGo 1.0.2 64-bit 2123 +19 −19 51.5% −9.8 30.3% 990
53.2%
458 Bodo 0.2b 2122 +21 −22 50.5% −3.8 20.8% 808
54.5%
459 Uragano 3D 0.92 2120 +27 −27 43.7% +46.5 18.0% 533
57.4%
460 Cupcake 1.1c 64-bit 2116 +27 −27 52.6% −16.9 20.4% 529
53.6%
461 Alcibiades 0.3.0 64-bit 2115 +22 −22 47.8% +16.8 18.1% 802
51.7%
462 Honzovy Sachy 2 64-bit 2114 +17 −17 54.6% −34.3 16.7% 1326
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Monarch 1.7 Vs Matmoi

Rank Engine Score Mo Ma S-B
1 Monarch(v1.7) 2.0/4 · ·· ·· 1001? 3.75
2 Matmoi 2.0/4 0110? · ·· ·· 3.75


4 of 50 games played

Tournament start: 2023.11.15, 19:01:59
Latest update: 2023.11.15, 20:49:53
Site/ Country: DESKTOP-4QNC0GS, United States
Level: 10 Seconds
Hardware: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz with 15.9 GB Memory
Operating system: Windows 10 Home Home Edition (Build 9200) 64 bit
PGN-File: Monarch 1.7 Vs Matmoi.pgn
Table created with: Arena 3.5.
I am ready to swap brain with Stockfish chip. https://www.facebook.com/share/iHzQpSjc ... tid=oFDknk
User avatar
Steve Maughan
Posts: 1229
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: m8 Dev log and C# experiments

Post by Steve Maughan »

I'm pleased to see Monarch 1.7 getting some airtime after all these years! :D

— Steve
http://www.chessprogramming.net - Maverick Chess Engine
JoAnnP38
Posts: 250
Joined: Mon Aug 26, 2019 4:34 pm
Location: Clearwater, Florida USA
Full name: JoAnn Peeler

Re: m8 Dev log and C# experiments

Post by JoAnnP38 »

eduherminio wrote: Tue Nov 14, 2023 2:48 pm

Code: Select all

  <ItemGroup>
    <Using Include="System.Int32" Alias="Move" />
    <Using Include="System.UInt64" Alias="BitBoard" />
  </ItemGroup >
  
I've never seen aliases used like this in the project file. I am going to remember that for my future projects. Thanks for sharing!!
User avatar
emadsen
Posts: 438
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: m8 Dev log and C# experiments

Post by emadsen »

mathmoi wrote: Tue Nov 14, 2023 4:58 am I was inspired to try and write a chess engine using C# in another thread and decided to give it a go.
Welcome to the chess programming community. Good luck with your engine.
eduherminio wrote: Tue Nov 14, 2023 2:48 pm

Code: Select all

  <ItemGroup>
    <Using Include="System.Int32" Alias="Move" />
    <Using Include="System.UInt64" Alias="BitBoard" />
  </ItemGroup >
  
That doesn't provide type safety (contrasted with defining an enum or struct, which does). You can pass a Move alias to a method that requires a int parameter and the compiler won't complain.
My C# chess engine: https://www.madchess.net