Anyone interested in writing a chess program together?

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Postby tomcant » Wed Oct 05, 2005 12:56 pm

devil_slayer wrote:Alvaro, I saw the code. It's very short and to the point. I guess it will all come clear once we actually see some algorithms that use those structures. One question, how do you define the board?


Yep, there is a lot more code to go with that. What you see at the moment is the underlying structures/objects used by the engine.

The board is represented with a method called 0x88. Read this. Basically, the board is represented by a 16*12 array of Piece values, where the game board is the middle 64 squares. It all becomes clear when you read the article :)
If it wasn't for C, we would be using BASI, PASAL and OBOL.
User avatar
tomcant
 
Posts: 3101
Joined: Tue Sep 23, 2003 1:56 am
Location: Colchester, UK

Postby Alvaro » Wed Oct 05, 2005 1:12 pm

devil_slayer wrote:Could you recommend some nice windows front-end?
It would be nice to start working on the protocol.

There is an interface called arena: http://www.playwitharena.com/
Please, try it and let us know if you like it. It's great that you want to work on the protocol, since I don't have a lot of experience doing that. I once implemented the xboard protocol for my old engine, but I did it in a hackish way that I would be ashamed of showing to other people.

Alvaro, I saw the code. It's very short and to the point. I guess it will all come clear once we actually see some algorithms that use those structures. One question, how do you define the board?

Yes, I was just trying to get familiar with the process of posting to the Subversion server and to make sure that people could download it and that it compiles on Windows compilers. I will keep adding modules as I make them (the original prototype that Tomcant has seen was one monolithic file). Tonight I will post enough that we can run perft and that we can build boards from EPD strings.
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

Postby Emery » Wed Oct 05, 2005 2:57 pm

Alvaro wrote:devil_slayer and RITZ seem to be worried about time control. The solution to your problems is called "iterative deepening". Take a look at Bruce Moreland's page about it.
I was thinking of something more complicated but that will suffice.
--~~~~
User avatar
Emery
 
Posts: 4313
Joined: Sat Mar 19, 2005 9:16 am

Postby devil_slayer » Wed Oct 05, 2005 4:08 pm

Well, in any case, UCI doesn't look hard to implement. It seems more modern too, so I'd go with that.
User avatar
devil_slayer
 
Posts: 489
Joined: Wed Oct 01, 2003 3:44 am
Location: Warsaw, POLAND

Postby t i l e x » Thu Oct 06, 2005 8:19 pm

I almost threw my computer out the window... how the hell are we supposed to submit code ? I searched for like 20 minutes and I still didn't find.
User avatar
t i l e x
 
Posts: 3604
Joined: Wed Dec 03, 2003 3:59 pm
Location: Québec (Canada)

Postby Alvaro » Fri Oct 07, 2005 5:37 am

t i l e x wrote:I almost threw my computer out the window... how the hell are we supposed to submit code ? I searched for like 20 minutes and I still didn't find.

The way I do it, I type `svn commit' and any modifications are sent to the server. If I want to add new files, I type `svn add <file1> <file2> ...' before I "commit". What Subversion client are you using? The steps are probably the same and have pretty much the same names, even if you don't use a command-line tool.
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

Postby Darryl » Fri Oct 07, 2005 7:44 am

Alvaro wrote:
t i l e x wrote:I almost threw my computer out the window... how the hell are we supposed to submit code ? I searched for like 20 minutes and I still didn't find.

The way I do it, I type `svn commit' and any modifications are sent to the server. If I want to add new files, I type `svn add <file1> <file2> ...' before I "commit". What Subversion client are you using? The steps are probably the same and have pretty much the same names, even if you don't use a command-line tool.


If you are using windows, I'd strongly suggest you use TortoiseSVN as suggested on the getting started wiki page. If you are using Tortiose:
1. Did you successfully checkout the code to your machine?
2. If so, you add files to that directory or modify existing file in that directory
3. When you are ready to submit you right click on the folder and choose SVN Commit
4. A dialog will come up, listing first modified files with a check next to them, and new files second, with no check, if you want those new files added, you check them.
5. Hit OK

PS. I haven't run across it yet, but from reading on SVN, if the files have been modified in the repository between the time you checked them out and the time you commit, the commit will fail. You must first update your working copy, resolves any conflicts and then commit.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Darryl » Fri Oct 07, 2005 7:59 am

tomcant wrote:
The board is represented with a method called 0x88. Read this. Basically, the board is represented by a 16*12 array of Piece values, where the game board is the middle 64 squares. It all becomes clear when you read the article :)


Ok I read the article and understand a 16x8 board, but why a 16x12 board?
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Alvaro » Fri Oct 07, 2005 8:27 am

Darryl wrote:
tomcant wrote:
The board is represented with a method called 0x88. Read this. Basically, the board is represented by a 16*12 array of Piece values, where the game board is the middle 64 squares. It all becomes clear when you read the article :)


Ok I read the article and understand a 16x8 board, but why a 16x12 board?

The method I am using is not exactly 0x88. If you want to generate all knight moves from a given square, in 0x88 you would do:
[syntax="cpp"]Move *Board::generate_knight_moves_from_square(Move *m, Square from){
static int KnightJump={-33,-31,-18,-14,+14,+18,+31,+33};
for(int i=0;i<8;++i){
Square to=from+KnightJump[i];
if(!(to&0x88) && color(a[to])!=stm)
*m++=Move(from,to);
}
}

[/syntax]

If instead of 16x8 you use 16x12 with the 8x8 board centered, you can fill the squares outside the 8x8 board with the value `out', which has color `both'. Now you don't have to test if the square is inside the board before you access it. Just do:
[syntax="cpp"]Move *Board::generate_knight_moves_from_square(Move *m, Square from){
static int KnightJump={-33,-31,-18,-14,+14,+18,+31,+33};
for(int i=0;i<8;++i){
Square to=from+KnightJump[i];
if(!(color(a[to])&stm))
*m++=Move(from,to);
}
}

[/syntax]

In the evaluation function you can check if a white knight is defended by a white pawn by doing
[syntax="cpp"] if(a[white_knight_square-15]==wp || a[white_knight_square-17]==wp)
...
[/syntax]
and you don't have to worry about accessing a square outside the board, because that is now a legal operation and you will never find a white pawn there. My old chess program used a 8x8 representation, and the evaluation function is full of exceptions for the sides of the board. 16x12 (or even 10x12) makes all that unnecessary. 10x12 is enough for this, but with 16x12 you also get the nice property that the difference between two squares represents the vector between them exactly, so you can still use the attack detection tricks of 0x88.
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

Postby t i l e x » Fri Oct 07, 2005 1:40 pm

I added my Logger class. It logs to a .XML file. I only need to design the .XSL stylesheet and we're done with the logger.
User avatar
t i l e x
 
Posts: 3604
Joined: Wed Dec 03, 2003 3:59 pm
Location: Québec (Canada)

Postby Corsix » Fri Oct 07, 2005 4:03 pm

OK, I've got several complaints with your implemention (here) and have coded a version that is IMO, better. I don't know whether to sumbit it to the repository and replace the old version (this is a total rewrite) or what...
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby t i l e x » Fri Oct 07, 2005 10:05 pm

I don't know how to answer you on tiki (this thing sucks as hell) so I'll answer here.

Why group events by file? Events should be logged in order they are logged. If you want to see the events grouped by file, an XLS stylesheet can do this
I could ask you the very same question. Why would you do this with an XSL stylesheet when you can do it inside your program ? Preference.
Things like the type of event (fatal error, warning, etc.) are missing
1) A logger is not supposed to determine wether something is fatal or could be fatal or whatever. It's supposed to log what worked, and what failed.
No singleton instance
:? :?:
Class private members have no distinction (surely something like "m_" or "_" should be put on the beggining?)
This would be Hungarian notation. Some prefer that syntax, others don't. I don't like it, so it doesn't need to be modified, since I wrote the code.
No quick logging macro (eg. #define Log(message) TheLog->AddNewElem(__FILE__,1,__LINE__,message)
The best would be to assign default values to parameters, but I absolutely refuse to use a macro, like this. It can only make the code worse.
No !AddNewElem equivalent with variable argument list
What do you mean here ?
AddNewElem - should print entries to files ASAP incase of a crash
I will modify this part, I agree that it could make it better.
Destructor - should call the Close() method if not already called
I assumed that you guys are bright enough to call it yourself but yeah.. It can't hurt.
The Empty Constructor - should contain a Create("default_file.xml"); instead of nothing.
The problem with this method is that if you want to declare the variable before defining it, you're fucked because you can't open the file, you'll have a file open and it will basically be really really ugly, leaking code.
User avatar
t i l e x
 
Posts: 3604
Joined: Wed Dec 03, 2003 3:59 pm
Location: Québec (Canada)

Postby Corsix » Sat Oct 08, 2005 12:48 am

t i l e x wrote:
Why group events by file? Events should be logged in order they are logged. If you want to see the events grouped by file, an XLS stylesheet can do this
I could ask you the very same question. Why would you do this with an XSL stylesheet when you can do it inside your program ? Preference.
Every log that I've seen logs events as they happen, if you group them by file, you cannot tell which events happened first. Also, you spend valuable time adding elements to maps/vectors. The beauty of using XML / XSL is that you can filter / sort the log file.

t i l e x wrote:
Class private members have no distinction (surely something like "m_" or "_" should be put on the beggining?)
This would be Hungarian notation. Some prefer that syntax, others don't. I don't like it, so it doesn't need to be modified, since I wrote the code.
It doesn't need it but it makes the code alot easier to understand to those who have not seen the code before.

t i l e x wrote:
Things like the type of event (fatal error, warning, etc.) are missing
1) A logger is not supposed to determine wether something is fatal or could be fatal or whatever. It's supposed to log what worked, and what failed.
It's just an extension of work/fail - you may want to print something other than a work or fail. Again, the beauty of using XML/XSL is that you can filter out the evnet types that you don't want to see.

t i l e x wrote:
No quick logging macro (eg. #define Log(message) TheLog->AddNewElem(__FILE__,1,__LINE__,message)
The best would be to assign default values to parameters, but I absolutely refuse to use a macro, like this. It can only make the code worse.
If you define a default value (eg. Logger::AddNewElem(const char* sFile = __FILE__) etc.) then it will always have the file and line of the AddNewElem function. Also, you would have to put __FILE__,__LINE__ at the beginning of every log entry you make. Having a macro makes it easier to log a message and makes the code shorter and more concise.
So instead of g_pTheLog->AddNewElem(__FILE__,__LINE__,"Message"); it would be Log_Write("Message");

t i l e x wrote:
No !AddNewElem equivalent with variable argument list
What do you mean here ?
no way to do AddNewElem("Remote player %s gave code %02i",sPlayer,iCode);
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby Safari » Sat Oct 08, 2005 4:51 am

Sorry but I think I have to quit.
It became too much. Focusing on this project takes much time and it impacts with school and homework (collage isn't easy here).
Damn, this would have been fun :cry:
I wish you all the best with this project.
I hope you guys don't have any hard feelings for this? :(
你 好!
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

Postby tomcant » Sat Oct 08, 2005 5:01 am

Safari wrote:I hope you guys don't have any hard feelings for this? :(


No hard feelings. Good luck with your college work!
If it wasn't for C, we would be using BASI, PASAL and OBOL.
User avatar
tomcant
 
Posts: 3101
Joined: Tue Sep 23, 2003 1:56 am
Location: Colchester, UK

PreviousNext

Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 0 guests