Lazarus
Programming => Packages and Libraries => Ported from Delphi/Kylix => Topic started by: typo on October 14, 2011, 07:06:17 pm
-
I am porting TChessBrd component from Delphi. It was written on year 2000. It uses a TImageList to draw drag images, which fails completely in Lazarus. I was not able to understand what is going on with TImageList and simply canceled the corresponding code.
I have replaced the drag functionality and resources by Lazarus style ones and canceled the animation. Maybe someone could have a better idea.
Code attached.
-
Sorry, no suggestions, but can I hope you're helping Felipe with his ChessFPC program? :D
-
Well, I have improved the notation, maybe he can use on his program. Animation is better there.
-
Demo attached.
-
It's using deprecated .lrs resource file and hangs up on close. Has to be forced to stop by Lazarus. It's also not showing anything on form.
-
Bitmap attached.
-
Sorry, no suggestions, but can I hope you're helping Felipe with his ChessFPC program? :D
This seams to have no relation with fpchess. In fpchess there is a chess drawing component which supports animations.
-
My notation obeys the rules of FIDE and supports multi-language.
-
Fixed ChessBrd.pas attached.
-
Any ideas how to use chess engine, for example houdini with this?
I did also find critter engine http://sourceforge.net/projects/critterchess/
It's Delphi project, but works fine (just open dpr). Tested 1.1 & FPC2.71, Win32
-
It is necessary to adapt the code for an engine. I did not do it yet.
The board itself works very well.
If you are interested on working a bit on this, try to learn the engine protocols:
http://en.wikipedia.org/wiki/Chess_Engine_Communication_Protocol
Houdini 1.5 is freeware.
http://www.houdinichess.com/
I like to play against this chess board because it is the only I can win.
-
For a basic version it looks nice 8)
-
If you are interested on working a bit on this, try to learn the engine protocols:
Was hoping for code example.
I started houdini with createprocess. But when I send commands, nothing happens. Commands do appear in console, but not work.
However, if I manually type commands to this console, then it works.
-
@Timewarp: likewise, it's useless to discuss code without posting it. Perhaps attaching your code could help: project menu/publish project, zip up the resulting directory with source files and attach it to a post or upload it somewhere...
-
it's useless to discuss code without posting it.
I didn't post it, because my code is no use, it doesn't work.
But now attached what was my basic idea. You need "Houdini_15a_w32.exe" in same folder. (Link was posted previously)
Not sure this is even correct idea. I can find examples how to create an engine, but not a single GUI example.
-
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
-
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?
-
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.
-
Attached working one, if anyone interrested. (atleast seems to work in WinXP)
Now when send/receive works, it's possible to merge..
-
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)
-
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)
-
Great job. Now this is my favorite chessboard.
-
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?
-
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?
-
AFAIK Houdini runs under Wine on Linux.
-
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).
-
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.
-
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.
-
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.
-
I can have your email address because there is a serious bug or upload of ambiguous moves.
Thank you
venus444@alice.it
-
You may reach me at this forum. Can you help?
-
TimeWarp work on this project. I would like to modify it with the help of TimeWarp. How to get hold of him?
-
I believe I already ported it two years ago.
-
I know it has been ported. I have been trying to modify it to do "click and place" instead of "drag and drop". My familiarity with the tchessbrd unit is not that good. Maybe you can direct me where to start.
Thanks,
VF
-
This project is a good place to start. I have been making modifications. Now I have come to this problem. Using FEN notation, I would like to have the engine make analysis based on a starting position indicated by the FEN notation. Can anyone direct me on how to do this?
-
Using FEN notation, I would like to have the engine make analysis based on a starting position indicated by the FEN notation. Can anyone direct me on how to do this?
You need to make a FEN parser. If you want to do it on your own, then one of the ways is to make a grammar and create parser based on that grammar. I have found one BNF grammar here (https://github.com/tlehman/fenparser), which you can adapt and use. Here is our wiki page (http://wiki.freepascal.org/Make_your_own_compiler,_interpreter,_parser,_or_expression_analyzer) if you want to go that path. If you don't then your best bet is to adapt other people's parser. I have found only one for Lazarus here (https://github.com/alex65536/Chess256/blob/cc41120a544c721688b6dc58e41cd17609eecdbe/Sources/ChessRules.pas) in Chess256 application. You can find many more FEN parsers for other programming languages on the net.
-
Thanks for the reply. Actually, I have written a FEN parser and have tested it hhttp://analysis.cpuchess.com/ (http://analysis.cpuchess.com/)ere. What really needed to know is to how to input the FEN notation into TChessBrd so that the engine can be utilized to analyze the game.
-
Oh ! Nice port. I have tried to use it by the past. The inculded engine is very crappy and difficult to replace but the board is nice. I remember there was a few to change (thread access violations when moving the pieces.
I used the pieces of virtual chess II to have a better look for the board and pieces.
Anyway, thank you for the port.
-
I have modified the app so I have a choice of engines. I run the new version 10 of stockfish and I am happy with it. I am still working on the following problems:
1. Based on FEN position, I would like the app to clear the board and place the pieces according to the FEN. How to do this in TChessbrd.
2. The next step is continuing play based on the FEN position.
Things I added to the app 1. Can communicate with electronic chessboard.
2. Can email pgn file
3. Can modify size of board
4. Can modify color of squares
5. Can select which engines to use
6. Can select size of pieces.
7. Can announce move made with voice.
8. Can change voice gender.
Help is needed. I hope TimeWarp is listening.
-
Hi, I am interested in TChessBrd for lazarus, where can I find this source at?