Author Topic: chess engine  (Read 1237 times)

daydreamer

  • Member
  • ****
  • Posts: 926
  • watch Chebyshev on the backside of the Moon
chess engine
« on: July 10, 2019, 03:43:16 AM »
Hi
I read up on chess and bitboards benefit from run it 64bit because 64squares fit into register and benefit from 64bit muls
Anyone tried make a chess game with chess engine?

Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6715
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: chess engine
« Reply #1 on: July 11, 2019, 10:38:39 PM »
Its not the register size that is complex with a chess game, its the size of the library which has to be truly massive to be effective. Its usually done with super computers.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

daydreamer

  • Member
  • ****
  • Posts: 926
  • watch Chebyshev on the backside of the Moon
Re: chess engine
« Reply #2 on: July 12, 2019, 12:52:36 AM »
Its not the register size that is complex with a chess game, its the size of the library which has to be truly massive to be effective. Its usually done with super computers.
there exist chess games running at slow 32bit cpus,I have to satisfy with newbie-chessengine level to begin with

I will take one step at a time,first step adviced is a bugfree representation of the board,bugfree important in handling all chess rules before doing search/evaluation part
maybe best output the underlying datasets to console for easier debug
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

AW

  • Member
  • *****
  • Posts: 2388
  • Let's Make ASM Great Again!
Re: chess engine
« Reply #3 on: July 12, 2019, 08:02:54 PM »
You can download and inspect the stockfish source code (Elo 3438) and try to improve on it.  :icon_idea: Despite being the best chess engine, it is all made in "slow" C++  :sad: . May be translating some parts to Asm will improve it even further.

FORTRANS

  • Member
  • *****
  • Posts: 1056
Re: chess engine
« Reply #4 on: July 12, 2019, 10:29:45 PM »
Hi,

   For your amusement only:

"SARGON A COMPUTER CHESS PROGRAM", by Dan and
Kathe Spracklen, Hayden Book Company, Inc., 1978.
A well commented Z-80 assembly language program to
play chess.  With 114 pages of mostly code, some
commentary. a description of Z-80 opcodes, and so forth.

   Amazing what gets on your bookshelf.

Cheers,

Steve N.

daydreamer

  • Member
  • ****
  • Posts: 926
  • watch Chebyshev on the backside of the Moon
Re: chess engine
« Reply #5 on: July 12, 2019, 11:27:23 PM »
thanks AW,I check that source up
thanks steve,how big is the final z80 program?
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

FORTRANS

  • Member
  • *****
  • Posts: 1056
Re: chess engine
« Reply #6 on: July 13, 2019, 12:42:48 AM »
Hi,

thanks steve,how big is the final z80 program?

   A quote from the introduction; "The program occupies
8K of RAM, which includes 2K of data areas, 2K graphics
display and user interface, and 4K of move logic."  Hm,
Jochen might be pleased with the lack of code bloat?

Regards,

Steve

jj2007

  • Member
  • *****
  • Posts: 9744
  • Assembler is fun ;-)
    • MasmBasic
Re: chess engine
« Reply #7 on: July 13, 2019, 02:48:15 AM »
Jochen might be pleased with the lack of code bloat?

I am, I am, Steve, although my standards have shifted a little bit - I tolerate up to 40kB overhead nowadays. Still very little compared to the 8MB of a QT hello world proggie ;-)

AW

  • Member
  • *****
  • Posts: 2388
  • Let's Make ASM Great Again!
Re: chess engine
« Reply #8 on: July 13, 2019, 03:08:58 AM »
Interesting, there is already a Stockfish ASM port, called ASMFish. It was developed in Flat Assembler G.  First time i hear about Flat Assembler G and seems like a masturbation paradise for Macro Lovers.

TimoVJL

  • Member
  • ***
  • Posts: 475
Re: chess engine
« Reply #9 on: July 13, 2019, 03:10:55 AM »
I tolerate up to 40kB overhead nowadays. Still very little compared to the 8MB of a QT hello world proggie ;-)
C and C++ don't have that overhead, if programmers are gentle and have some sort of knowledge of CRT :winking:
May the source be with you

jj2007

  • Member
  • *****
  • Posts: 9744
  • Assembler is fun ;-)
    • MasmBasic
Re: chess engine
« Reply #10 on: July 13, 2019, 03:38:56 AM »
That's correct, Timo, but they also don't have commands like Recall ;-)
Code: [Select]
                    include \masm32\MasmBasic\MasmBasic.inc
                    Init                                    ; show a data set from the World Health Organisation
                    Recall "https://extranet.who.int/tme/generateCSV.asp?ds=mdr_estimates", who$(), csv
                    Print Str$("%i records downloaded", eax)
                    For_ ct=0 To who$(?)-1
                                Print CrLf$, who$(ct, 0)
                                Print At(33, Locate(y)) Spc2$, who$(ct, 4), Space$(40)
                                For_ ecx=8 To 14                ; columns 8...14 contain the data
                                                                Print At(ecx*8-25, Locate(y)) Spc2$, who$(ct, ecx)
                                Next
                    Next
                    EndOfCode

30kB is clearly too much, right? Show me the shorter C++ version ;-)

daydreamer

  • Member
  • ****
  • Posts: 926
  • watch Chebyshev on the backside of the Moon
Re: chess engine
« Reply #11 on: July 13, 2019, 09:35:34 PM »
That's correct, Timo, but they also don't have commands like Recall ;-)
Code: [Select]
                    include \masm32\MasmBasic\MasmBasic.inc
                    Init                                    ; show a data set from the World Health Organisation
                    Recall "https://extranet.who.int/tme/generateCSV.asp?ds=mdr_estimates", who$(), csv
                    Print Str$("%i records downloaded", eax)
                    For_ ct=0 To who$(?)-1
                                Print CrLf$, who$(ct, 0)
                                Print At(33, Locate(y)) Spc2$, who$(ct, 4), Space$(40)
                                For_ ecx=8 To 14                ; columns 8...14 contain the data
                                                                Print At(ecx*8-25, Locate(y)) Spc2$, who$(ct, ecx)
                                Next
                    Next
                    EndOfCode

30kB is clearly too much, right? Show me the shorter C++ version ;-)
cool :thumbsup:
 
great guys,smallest chessboard drawing a stretchblt and using a tiny checkered image?
8k chess.exe seem possible
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

AW

  • Member
  • *****
  • Posts: 2388
  • Let's Make ASM Great Again!
Re: chess engine
« Reply #12 on: July 14, 2019, 01:27:10 AM »
@JJ
It is easy to replace your MasmBasic with a 3 or 4KB equivalent in C/C++.
But is even easier to do all that with a simple Powershell script, which shows clearly that your code has a few bugs.

Code: [Select]
$desiredColumns = 'country','year', 'e_rr_pct_new','e_rr_pct_new_lo','e_rr_pct_new_hi','e_mdr_pct_rr_new','source_rr_ret','source_drs_coverage_ret'
$web = New-Object Net.WebClient
$web.DownloadString("https://extranet.who.int/tme/generateCSV.asp?ds=mdr_estimates") | ConvertFrom-Csv | Select $desiredColumns | Format-Table

Output:

Code: [Select]
country                                              year e_rr_pct_new e_rr_pct_new_lo e_rr_pct_new_hi e_mdr_pct_rr_new source_rr_ret source_drs_coverage_ret
-------                                              ---- ------------ --------------- --------------- ---------------- ------------- -----------------------
Afghanistan                                          2017 3.7          2               5.9             79               Model
Albania                                              2017 2.3          0.64            5.8             100              Surveillance  National
Algeria                                              2017 2.5          1.1             4.3             67               Model
American Samoa                                       2017 2.3          0.86            4.4             78               Model
Andorra                                              2017 0            0               98              100              Surveillance  National
................... Cut

Zimbabwe                                             2017 4.6          3               6.2             39               Survey        National

jj2007

  • Member
  • *****
  • Posts: 9744
  • Assembler is fun ;-)
    • MasmBasic
Re: chess engine
« Reply #13 on: July 14, 2019, 08:16:29 AM »
Which bugs?

AW

  • Member
  • *****
  • Posts: 2388
  • Let's Make ASM Great Again!
Re: chess engine
« Reply #14 on: July 14, 2019, 02:44:56 PM »
Which bugs?

You clip column names to the point of appearing as duplicates. You clip results to the point of being clueless.
So, you may need a function to calculate the needed columns widths before printing, it is risky to arbitrate some fixed value and shoot.
And you show a double quote at the start of each line, only God knows why.