* * *

Author Topic: Porting TChessBrd from Delphi  (Read 18822 times)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Porting TChessBrd from Delphi
« Reply #15 on: July 20, 2013, 12:53:40 pm »
Some random guesses:
1. Buffering
Perhaps the output to houdini is buffered and you need to explicitly clear the buffer?
see
http://www.open-aurec.com/wbforum/WinBoard/engine-intf.html#6

2. Hmmm, you're using direct win API calls it seems. Perhaps you'll have more success with TProcess?
http://wiki.lazarus.freepascal.org/Executing_External_Programs

3. You start with a go command - perhaps you need to set up houdini first (e.g. choose a side, perhaps type of game (timed, normal etc) and start the game, e.g using the new command)
http://www.open-aurec.com/wbforum/WinBoard/engine-intf.html#8
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Leledumbo

  • Hero Member
  • *****
  • Posts: 7953
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Porting TChessBrd from Delphi
« Reply #16 on: July 20, 2013, 01:31:04 pm »
Quote
I didn't post it, because my code is no use, it doesn't work.
Then how we do know what's wrong and what to fix?

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Porting TChessBrd from Delphi
« Reply #17 on: July 20, 2013, 02:45:42 pm »
Thanks for suggestions.

1. I don't think code uses buffering. Command appears to console.
2. Changed to use TProcess, but same problem remains.
3. I have tried other commands. "go" should work, because it works when typed manually.

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Porting TChessBrd from Delphi
« Reply #18 on: July 20, 2013, 05:22:22 pm »
Attached working one, if anyone interrested. (atleast seems to work in WinXP)

Now when send/receive works, it's possible to merge..

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Porting TChessBrd from Delphi
« Reply #19 on: July 22, 2013, 12:44:20 pm »
The board itself works very well.
Do you have any plans to improve component?

It seems DragObject is leaked every move

DragObject := TChessDragObject.Create(Self, Bmp);

Quick check, something like this stops it (heaptrc)

if assigned(MyDragObject) then MyDragObject.Free;
MyDragObject := TChessDragObject.Create(Self, Bmp);
DragObject := MyDragObject;

But it's still leaked once. Ideas how to fix it properly? (Free MyDragObject on exit crashes)

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Porting TChessBrd from Delphi
« Reply #20 on: July 28, 2013, 02:58:08 pm »
Attached demo. It uses 3seconds/move. Houdini_15a_w32.exe needs to be in project dir. http://www.houdinichess.com/ Component doesn't have to be installed.

Few changes to chessbrd component:

- Restored original drag/drop, also animation related code.
- Added promotion functionality, property promotepiece cblAuto (Queen), cblAsk.
- Various smaller changes.

Windows only. Briefly tested component itself in Linux. It compiles, but doesn't work, because it uses thread resume/suspend. (I have no idea how to remove them)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Porting TChessBrd from Delphi
« Reply #21 on: July 28, 2013, 05:30:45 pm »
Great job. Now this is my favorite chessboard.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Porting TChessBrd from Delphi
« Reply #22 on: July 30, 2013, 08:56:12 pm »
Please put your name and license in some place of the code. If I use this code for a program, I would like to cite the author. Should I cite Timewarp? Should I assume the license is LGPL?
« Last Edit: July 30, 2013, 08:59:28 pm by typo »

jarto

  • Full Member
  • ***
  • Posts: 106
Re: Porting TChessBrd from Delphi
« Reply #23 on: July 30, 2013, 09:29:18 pm »
Windows only. Briefly tested component itself in Linux. It compiles, but doesn't work, because it uses thread resume/suspend. (I have no idea how to remove them)
My curiosity peaked, so I had a look. It shouldn't be to difficult to let the TChessThread run continuously and to just use sleep or a TSimpleEvent inside TChessThread.Execute to wait. That would eliminate the need to suspend threads.

I tried to compile the demo program in Linux, but there the biggest problem are the pipes and the CreateProcess in Load_Engine. Can you tell me what's the idea behind using those?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Porting TChessBrd from Delphi
« Reply #24 on: July 30, 2013, 10:13:32 pm »
AFAIK Houdini runs under Wine on Linux.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Porting TChessBrd from Delphi
« Reply #25 on: July 31, 2013, 08:03:39 am »
I tried to compile the demo program in Linux, but there the biggest problem are the pipes and the CreateProcess in Load_Engine. Can you tell me what's the idea behind using those?

Probably replace CreateProcess by TProcess so you can start the houdini engine (having this code in the Windows version may not be a bad idea - keeps it nice and crossplatform). The pipes are then used to communicate with the houdini engine (to pass the moves and receive the opponent's moves from the AI etc).
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Porting TChessBrd from Delphi
« Reply #26 on: July 31, 2013, 08:42:14 am »
Should I cite Timewarp? Should I assume the license is LGPL?

I don't care, I guess same as original.

I tried to compile the demo program in Linux, but there the biggest problem are the pipes and the CreateProcess in Load_Engine. Can you tell me what's the idea behind using those?

I mean I tested component chessbrd.pas. Afterwards I did not even try to make demo run in Linux.

If you like to test, take that and res-file and try demo from reply #3. It should easily compile in Linux, but not work.

Using pipes was first thing that worked for me.. Like mentioned above, maybe TProcess can be used, similar thread http://forum.lazarus.freepascal.org/index.php/topic,21631.0.html

AFAIK Houdini runs under Wine on Linux.

There are engines for Linux also. I tested Stockfish (in Windows). This engine requires whole position (all moves) to be sent on every move, that's ofcourse very easy to change.

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Porting TChessBrd from Delphi
« Reply #27 on: September 02, 2013, 02:29:23 pm »
Just posting latest changes.

Demo1 uses the original engine
Demo2 uses&needs Houdini (or Stockfish)

Some of the changes, algebraic notation / basic load&save pgn. Thread suspend gone. Many bugs fixed (hopefully not created new)

Demo1 should run in Linux also, but there are bugs in Lazarus gtk2.

I'm planning to use this to watch&analyse live games. Some smaller / national tournaments, when games can't be followed in ICC/Playchess/chessbomb.com.. only on website.

vferia

  • Newbie
  • Posts: 4
Re: Porting TChessBrd from Delphi
« Reply #28 on: June 23, 2018, 08:17:17 pm »
I would like to add functionality to this application, e.g. highlighting the source and destination squares of the computer move. Also, instead of drag and drop i would like to do a click option.

venus444

  • Newbie
  • Posts: 1
Re: Porting TChessBrd from Delphi
« Reply #29 on: August 04, 2018, 08:59:14 am »
I can have your email address because there is a serious bug or upload of ambiguous moves.
Thank you
venus444@alice.it

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus