Recent

Author Topic: Anyone interested in helping test a Draughts/Checkers playing program?  (Read 2925 times)

BSaidus

  • Hero Member
  • *****
  • Posts: 633
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #30 on: November 02, 2025, 07:38:15 pm »
Do this:
add cmem in uses clause.

Code: Pascal  [Select][+][-]
  1.     // draughts.lpr
  2.     uses
  3.       {$IFDEF UNIX}
  4.      cmem,
  5.       cthreads,
  6.       {$ENDIF}
  7.       sysutils
  8.  
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

Fred vS

  • Hero Member
  • *****
  • Posts: 3714
    • StrumPract is the musicians best friend
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #31 on: November 02, 2025, 09:44:59 pm »
Do this:
add cmem in uses clause.
Or even better, use the excellent mORMot memory manager;)

Code: Pascal  [Select][+][-]
  1.     // draughts.lpr
  2.     uses
  3.       mormot.core.fpcx64mm,
  4.       {$IFDEF UNIX}
  5.       cthreads,
  6.       {$ENDIF}
  7.       sysutils, ...
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

ad1mt

  • Sr. Member
  • ****
  • Posts: 452
    • Mark Taylor's Home Page
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #32 on: November 03, 2025, 07:24:45 pm »
Made a quick test under Linux. 1° I had to remove (unused) reference to Windows unit. 2° CThreads must be the first unit called, otherwise:

$ ./Draughts
Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $000000000047635D
  $000000000047635D
  $0000000000440FBC


After that I can compile and start the program. Maybe I will come back later in the discussion.
Thanks for that tip... I don't have access to Linux with GUI, and I'm not getting that error.
I now remember how that unused/dangling "uses" got there... it was a failed attempt to detect the [escape] key, and I forgot to tidy it up.
« Last Edit: November 03, 2025, 07:31:17 pm by ad1mt »

ad1mt

  • Sr. Member
  • ****
  • Posts: 452
    • Mark Taylor's Home Page
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #33 on: November 03, 2025, 07:46:06 pm »
I had to remove (unused) reference to Windows unit.
After that I can compile and start the program. Maybe I will come back later in the discussion.

Version 7.3F fixes this.

ad1mt

  • Sr. Member
  • ****
  • Posts: 452
    • Mark Taylor's Home Page
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #34 on: November 06, 2025, 08:49:03 am »
Version 7.4D
This has board editing, UI improvements, and big bug fixes (& big fixes too  :D).
I would be interested to know the program compiles & works correctly on Linux.

I have greyed-out the database, learning and autoplay options, until the algorithms have been debugged.
« Last Edit: November 06, 2025, 01:26:58 pm by ad1mt »

Roland57

  • Hero Member
  • *****
  • Posts: 527
    • msegui.net
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #35 on: November 06, 2025, 07:02:19 pm »
I would be interested to know the program compiles & works correctly on Linux.

The runtime error 211 is still here.

[roland@localhost v7_4D]$ ./Draughts
Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $000000000047635D
  $000000000047635D
  $0000000000440FBC


You didn't make the modification that I suggested.  ;D

P.-S. After that, it compiles and runs. I found that I could open the Settings form by pressing on the Escape key. I like the idea.  :)

My other (small) observations, after a quick test.

Not very important maybe: the animation could be optimized. I feel that the board is redrawn too often (or maybe it is redrawn entirely without necessity).

I see some code for creating a log file, but by me the log file isn't created, I don't know why. Oh, I see. Probably this condition

Code: Pascal  [Select][+][-]
  1. // unit_globals.pas
  2. if      (LOGE > 0) then

is never true, for now, because the array is empty. (By the way, not sure that it be a good idea, to create the file when the user closes the program. If there is a crash, you won't have a log file.)

And I am not sure that using Halt be the correct way to close the application:

Code: Pascal  [Select][+][-]
  1. // unit_settings.pas
  2. procedure TForm2.Quit_Button_Click(Sender: TObject);
  3. begin
  4. SAVEDBASE;
  5. // ...
  6. write_logfile;
  7. halt;
  8. end;

Not yet had time to take a look in the checkers engine.
« Last Edit: November 06, 2025, 07:50:27 pm by Roland57 »
My projects are on Codeberg.

ad1mt

  • Sr. Member
  • ****
  • Posts: 452
    • Mark Taylor's Home Page
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #36 on: November 06, 2025, 08:02:39 pm »
The runtime error 211 is still here.

[roland@localhost v7_4D]$ ./Draughts
Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $000000000047635D
  $000000000047635D
  $0000000000440FBC


You didn't make the modification that I suggested.  ;D
I don't think I understod what change you were suggesting; I thought it was the redundant "uses Windows".
I've made the changes suggested by @BSaidus
add cmem in uses clause.
Code: Pascal  [Select][+][-]
  1.     // draughts.lpr
  2.     uses
  3.       {$IFDEF UNIX}
  4.      cmem,
  5.       cthreads,
  6.       {$ENDIF}
  7.       sysutils
  8.  
Please let me know if that fixes the problem... I don't have access to a working Linux with GUI, just a raspberry Pi.

PS - I forgot to attach the zip file   :o
« Last Edit: Today at 11:48:25 am by ad1mt »

ad1mt

  • Sr. Member
  • ****
  • Posts: 452
    • Mark Taylor's Home Page
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #37 on: November 06, 2025, 08:12:59 pm »
I found that I could open the Settings form by pressing on the Escape key. I like the idea.  :)
Thanks... I'm trying to make UI as minimal as possible, like having a real checkers board on the table in front of you.

My other (small) observations, after a quick test.
Not very important maybe: the animation could be optimized. I feel that the board is redrawn too often (or maybe it is redrawn entirely without necessity).

I see some code for creating a log file, but by me the log file isn't created, I don't know why. Oh, I see. Probably this condition

Code: Pascal  [Select][+][-]
  1. // unit_globals.pas
  2. if      (LOGE > 0) then

is never true, for now, because the array is empty. (By the way, not sure that it be a good idea, to create the file when the user closes the program. If there is a crash, you won't have a log file.)

And I am not sure that using Halt be the correct way to close the application:

Code: Pascal  [Select][+][-]
  1. // unit_settings.pas
  2. procedure TForm2.Quit_Button_Click(Sender: TObject);
  3. begin
  4. SAVEDBASE;
  5. // ...
  6. write_logfile;
  7. halt;
  8. end;

Not yet had time to take a look in the checkers engine.

This is my first large/complex GUI program, and the code is first draft. Once it is 100% working, I intend going through the code to tidy it up, remove redundancy and remove temporary debugging code (like the log file).
Why do think halt is bad idea?
Please continue to make suggestions... you might spot something I am not aware of.

Roland57

  • Hero Member
  • *****
  • Posts: 527
    • msegui.net
Re: Anyone interested in helping test a Draughts/Checkers playing program?
« Reply #38 on: November 06, 2025, 11:49:36 pm »
I'm trying to make UI as minimal as possible, like having a real checkers board on the table in front of you.

Yes, that's what I understood. I had the same idea when I made my chess GUI.

Why do think halt is bad idea?

If you activate Heaptrc unit (Project options, Debugging), and start the program from a console (what I always do), you will see that the application has memory leaks.
My projects are on Codeberg.

 

TinyPortal © 2005-2018