Author: Lieven Clarisse
Date: 02:15:02 01/17/03
Go up one level in this thread
On January 17, 2003 at 01:49:39, Joshua Haglund wrote:
>On January 16, 2003 at 06:39:35, Lieven Clarisse wrote:
>
>>This should bring you a little closer to your goal, it is by no means a working
>>example, but will show you how to get started.
>>
>>
>>#include <string.h>
>>
>>
>>{
>>moves[3]= {"e2e4", "d2d4", "c2c4"}; //I assume these are the legal moves
>> //the current position
>>
>>//---> better and more general is this:
>>
>>generatemoves(boardrepresentation, moves);
>>//boardrepresentation can be any object reprenting the current board position
>>//moves is defined by char moves[100][10] (place for 100 moves)
>>
>>getline(input);
>>
>>if (!strcmp(input,moves[0]) || !strcmp(input,moves[1]) !strcmp(input,moves[2]))
>>//you probably want this in a seperate function, using a for loop
>> //so you can use it in general, using any number of moves
>> {
>> domove(boardrepresentation, input);
>> move=evaluate_board(boardrepresentation);
>> }
>>
>>else cout <<"invalid move" << endl;
>>
>>return move; // reply move to be displayed from the evaluated position.
>>}
>
>
>Thanks Lieven, for you efforts!
>
>I didn't end up going this way, but thanks for helping me.
>
>Thanks for the motivation!
>
>Joshua
>toneewa@yahoo.com
I suggest writing first a separate program that reads in a fen, and
generates the moves. This will keep you busy for a while, and it is a good I
programming exercise.
I would keep it simple and use an ordinary array as board representation
for instance
char boardrep[8][8]; 'K'=white king, 'k'=black king, ' '=empty, etc..
and maybe
int whitecastlerights[2];
int blackcastlerights[2];
and maybe some flag for enpassant
you can put these in a structure "board" if you like.
Then with a number of if's and else's it is quite easy (but it will take a few
hours though) to make a move generator.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.