Eschecs FreeBASIC (UCI chess GUI)
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
Yes, it's true. But even this simple result is not so easy to reach !roook_ph wrote:most of its moves looks like random moves of any piece for any open space.
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.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: ESCHECS 0.2
Much better :)Roland Chastain wrote:I would like to present ESCHECS 0.2, my "new" program.
I have replaced the keyboard by the mouse.
What you might add is the high lighting of valid moves when a piece to be moved is selected - handy for beginners.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 !
-
- Posts: 2338
- Joined: May 31, 2005 9:59
- Location: Croatia
- Contact:
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
Re: ESCHECS 0.2
Good idea, thanks. I will think about it.BasicCoder2 wrote:What you might add is the high lighting of valid moves when a piece to be moved is selected - handy for beginners.
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
The whole source code is included in the zip file :roook_ph wrote:Maybe you could post source so that maybe we can improve the algorithm a bit
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.
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
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.Lachie Dazdarian wrote:Maybe Garvan can give us inputs on how he did it in his Chess program.
Sorry, this may be a stupid post because I've no experience with chess engines.Roland Chastain wrote: but I don't manage to put in my own move except by writing it directly with keyboard.
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
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
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: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
Yes, I have to type my move. So I understand now why it couldn't work. Thank you again !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).
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.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: ESCHECS 0.2
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.Roland Chastain wrote:Good idea, thanks. I will think about it.BasicCoder2 wrote:What you might add is the high lighting of valid moves when a piece to be moved is selected - handy for beginners.
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.
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
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 :TJF wrote:Then the engine calculates the response and outputs it to the console.
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.
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
Re: ESCHECS 0.2
Yes !BasicCoder2 wrote:High lighting (...) does teach the legal moves and was a good way to check the legal moves generator was working properly.
Yes again ! It's also what I say to myself.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.