Eschecs FreeBASIC (UCI chess GUI)

User projects written in or related to FreeBASIC.
Post Reply
roook_ph
Posts: 402
Joined: Apr 01, 2006 20:50
Location: philippines
Contact:

Post by roook_ph »

I tried it, algorithm needs improvement. I am not that good chess player but most of its moves looks like random moves of any piece for any open space. I think.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Post by Roland Chastain »

roook_ph wrote:most of its moves looks like random moves of any piece for any open space.
Yes, it's true. But even this simple result is not so easy to reach !

It looks for all his possible moves ; for each one, all moves of the other side ; and for each one, all his own moves again. In order to select a move, it has twenty or thirty simple rules. When it can't choose by this mean between several moves, it takes the first.
Last edited by Roland Chastain on Feb 11, 2014 12:37, edited 2 times in total.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: ESCHECS 0.2

Post by BasicCoder2 »

Roland Chastain wrote:I would like to present ESCHECS 0.2, my "new" program.
I have replaced the keyboard by the mouse.
Much better :)
I did work also on the "engine", but the play is not really stronger. A little different maybe... Let us say that I wanted to make made a chess game for children !
What you might add is the high lighting of valid moves when a piece to be moved is selected - handy for beginners.
roook_ph
Posts: 402
Joined: Apr 01, 2006 20:50
Location: philippines
Contact:

Post by roook_ph »

I do not notice the source .Maybe you could post source so that maybe we can improve the algorithm a bit
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Post by Lachie Dazdarian »

Roland Chastain wrote:
Lachie Dazdarian wrote:I would really appreciate if someone would take the time and write a tutorial on how to plug these engines into a FB program.
Good idea ! I would make it with pleasure if I could.
Maybe Garvan can give us inputs on how he did it in his Chess program.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: ESCHECS 0.2

Post by Roland Chastain »

BasicCoder2 wrote:What you might add is the high lighting of valid moves when a piece to be moved is selected - handy for beginners.
Good idea, thanks. I will think about it.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Post by Roland Chastain »

roook_ph wrote:Maybe you could post source so that maybe we can improve the algorithm a bit
The whole source code is included in the zip file :
http://www.freebasic-portal.de/dlfiles/ ... HECS02.zip

I would be glad if you had a look in it, but I'm afraid my code isn't enough readable and understandable for another than me. Let's try ! The file concerned, where moves are evaluated, is "esch13.bas". I post it at once.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Post by Roland Chastain »

[deleted]
Last edited by Roland Chastain on Oct 19, 2013 10:12, edited 1 time in total.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Post by Roland Chastain »

Lachie Dazdarian wrote:Maybe Garvan can give us inputs on how he did it in his Chess program.
It would be nice. I began to study the use of Open Pipe. With the manual example, I manage to run the engine and read his move but I don't manage to put in my own move except by writing it directly with keyboard.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Roland Chastain wrote: but I don't manage to put in my own move except by writing it directly with keyboard.
Sorry, this may be a stupid post because I've no experience with chess engines.

I think when the engine gets executed, it gets the data of your move (and maybe some parameters) passed as a command line parameter. Then the engine calculates the response and outputs it to the console.

So the code should look like

Code: Select all

VAR c = "your move and parameters ...", r = "", l = ""
VAR fnr = FREEFILE

IF OPEN PIPE c FOR OUTPUT AS #fnr THEN
  ?"Error while running the engine!"
ELSE
  WHILE NOT EOF(#fnr)
    LINE INPUT #fnr, l
    r &= l & CHR(10)
  WEND
  CLOSE #fnr
  ?r ' the output of the engine
END IF
If this guess isn't right and you have to type your move after starting the engine (instead of passing your move as a command line parameter), then it's much more dificile because OPEN PIPE can handle only one direction. You cannot write to a PIPE and then read from the same PIPE. This has to be handled by an extern library (ie GLib).
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Post by Roland Chastain »

:-)
Last edited by Roland Chastain on May 19, 2012 10:26, edited 2 times in total.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Post by Roland Chastain »

TJF wrote:I think when the engine gets executed, it gets the data of your move (and maybe some parameters) passed as a command line parameter. Then the engine calculates the response and outputs it to the console. So the code should look like
Thank you for your new answer, and for this interesting (to my mind) code example. I copy it and I'm sure I will have use of it anyway.
TJF wrote:If this guess isn't right and you have to type your move after starting the engine (instead of passing your move as a command line parameter), then it's much more dificile because OPEN PIPE can handle only one direction. You cannot write to a PIPE and then read from the same PIPE. This has to be handled by an extern library (ie GLib).
Yes, I have to type my move. So I understand now why it couldn't work. Thank you again !
I will have a look at GLib.
But I think again to what you call "command line parameter". I don't know exactly what it is, but it seems to me that it could be also another good idea.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: ESCHECS 0.2

Post by BasicCoder2 »

Roland Chastain wrote:
BasicCoder2 wrote:What you might add is the high lighting of valid moves when a piece to be moved is selected - handy for beginners.
Good idea, thanks. I will think about it.
Inspired by your efforts and having a few hours to spare this weekend I had a go at my own chess program. I got as far as a two human player board with mouse manipulation of pieces but it includes the suggested high lighting of legal moves for a chosen chess piece which only needs an evaluator to decide which one is the best for a computer player to choose its own move. I say only needs an evaluator but of course that is the hard bit, the creative bit, the fun bit.

High lighting is kind of cheating because you can't miss seeing any of the possible moves but it does teach the legal moves and was a good way to check the legal moves generator was working properly.

To plug in someone else’s evaluator seems to me to defeat the purpose of writing your own chess program. For me writing the evaluator would be the on going fun brain challenge part.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Post by Roland Chastain »

TJF wrote:Then the engine calculates the response and outputs it to the console.
Here is a link to one of the chess engines I'm working with, if someone wants to have an idea of what it is. Its name is Minimax :

http://home.pacific.net.au/~tommyinoz/minimax.zip

It's very simple. After I have run the program, if I don't worry about any option and play white, I just have to type my move, for example "e2e4" and press enter. Then, as you say, the engine calculates and outputs for example "e7e5" (and other things I don't need).
I've just had an idea. If I manage to make my program give this order, with an "output pipe", isn't there a mean to "read" the answer on the screen, with something like a "Point" statement ? I will think to it. Please let me know what you think about it.
Last edited by Roland Chastain on Dec 11, 2011 20:35, edited 1 time in total.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: ESCHECS 0.2

Post by Roland Chastain »

BasicCoder2 wrote:High lighting (...) does teach the legal moves and was a good way to check the legal moves generator was working properly.
Yes !
BasicCoder2 wrote:To plug in someone else’s evaluator seems to me to defeat the purpose of writing your own chess program. For me writing the evaluator would be the on going fun brain challenge part.
Yes again ! It's also what I say to myself.
Post Reply