It's not a defeat: I'm trying to help you, not to beat youZirconiumX wrote:I admit defeat...
Lucas was right.
Problem with bitboard knight attack generator
Moderators: hgm, Rebel, chrisw
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Problem with bitboard knight attack generator
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Problem with bitboard knight attack generator
??ZirconiumX wrote: Out of interest, if you declare a typedef struct as extern, which order do the keywords go in? (I think typedef extern struct is correct, but I'll ask anyway)
typedef defines a new type
extern references a variable that is defined in another compiing unit.
not sure what you mean. Can you give a code example of what you want to do ?
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Problem with bitboard knight attack generator
Ah OK, I understand what you mean with typedef extern. Have a look here, it's all explained:
http://www.allegro.cc/forums/print-thread/588235
http://www.allegro.cc/forums/print-thread/588235
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Problem with bitboard knight attack generator
If you're running Linux, you can have a look at the Linux Kernel header files directly:lucasart wrote:Ah OK, I understand what you mean with typedef extern. Have a look here, it's all explained:
http://www.allegro.cc/forums/print-thread/588235
Code: Select all
lucas@megatron:~$ find /usr/src/linux-headers-3.0.0-14-generic/include/ -iname "*.h" -exec grep "extern struct" {} \;
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Problem with bitboard knight attack generator
However, your substitution code for eastOne() and westOne() is not the same as in CPW. Again, you need to take care of the wraparound. In CPW "eastOne(U64 b)" is defined as "(b & notHFile) << 1" (there is also an equivalent second way) and "westOne()" accordingly.ZirconiumX wrote:Blame the CPW for that:I don't have a nortOne or a SoutOne function, so I subsituted the actual code for it.Code: Select all
U64 kingAttacks(U64 kingSet) { U64 attacks = eastOne(kingSet) | westOne(kingSet); kingSet |= attacks; attacks |= nortOne(kingSet) | soutOne(kingSet); return attacks; }
As to the "rank" vs. "file" error in the context of pawn attacks, that was my fault, I proposed a correction but introduced a sloppy error myself. As you see, I am constantly testing the alertness of the forum Thanks to Lucas for correcting it.
Sven
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Problem with bitboard knight attack generator
How about C++, Lucas?lucasart wrote:Ah OK, I understand what you mean with typedef extern. Have a look here, it's all explained:
http://www.allegro.cc/forums/print-thread/588235
Code: Select all
struct A {
...
};
...
extern A my_a;
extern A * my_a_ptr;
999:998 for C++
Sven
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Problem with bitboard knight attack generator
If I Coul;d have only the good stuff in C++ without all the crap, why not. But post C++98 exceptions are everywhere in the STL and even thrown by language operators...Sven Schüle wrote:How about C++, Lucas?lucasart wrote:Ah OK, I understand what you mean with typedef extern. Have a look here, it's all explained:
http://www.allegro.cc/forums/print-thread/588235No need for a "typedef" for structs any longer, "A" from the declaration "struct A" is already the name of the type (since "struct" is a special form of "class" where all members are public).Code: Select all
struct A { ... }; ... extern A my_a; extern A * my_a_ptr;
999:998 for C++
Sven
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Problem with bitboard knight attack generator
You can use C++ without using any single line of STL. All my chess programs were written in C++ but there was never STL in it. Actually you don't need STL for chess programming.lucasart wrote:If I Coul;d have only the good stuff in C++ without all the crap, why not. But post C++98 exceptions are everywhere in the STL and even thrown by language operators...Sven Schüle wrote:How about C++, Lucas?lucasart wrote:Ah OK, I understand what you mean with typedef extern. Have a look here, it's all explained:
http://www.allegro.cc/forums/print-thread/588235No need for a "typedef" for structs any longer, "A" from the declaration "struct A" is already the name of the type (since "struct" is a special form of "class" where all members are public).Code: Select all
struct A { ... }; ... extern A my_a; extern A * my_a_ptr;
999:998 for C++
Sven
In other areas of software development things are probably different. But I promised not to try converting you
Sven
EDIT: Sorry to Matthew for hijacking your thread, I think I'll stop now.
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Problem with bitboard knight attack generator
But if you don't use STL in your chess program, why do you use C++ anyway ? Is it just because of this syntactic sugar (classes and the like can be written in plain C very well)Sven Schüle wrote:You can use C++ without using any single line of STL. All my chess programs were written in C++ but there was never STL in it. Actually you don't need STL for chess programming.lucasart wrote:If I Coul;d have only the good stuff in C++ without all the crap, why not. But post C++98 exceptions are everywhere in the STL and even thrown by language operators...Sven Schüle wrote:How about C++, Lucas?lucasart wrote:Ah OK, I understand what you mean with typedef extern. Have a look here, it's all explained:
http://www.allegro.cc/forums/print-thread/588235No need for a "typedef" for structs any longer, "A" from the declaration "struct A" is already the name of the type (since "struct" is a special form of "class" where all members are public).Code: Select all
struct A { ... }; ... extern A my_a; extern A * my_a_ptr;
999:998 for C++
Sven
In other areas of software development things are probably different. But I promised not to try converting you
Sven
EDIT: Sorry to Matthew for hijacking your thread, I think I'll stop now.
-
- Posts: 397
- Joined: Sun Oct 29, 2006 4:38 am
- Location: Schenectady, NY
Re: Problem with bitboard knight attack generator
@Lucas,
You can remain in pure C and use STL-like libraries
C Containers Library
http://code.google.com/p/ccl/wiki/PageName
BTW, this library is being proposed to be added to the next-generation C standard library.
Look at section 6 of the pdf. It will show some typical library usage. No syntactic sugar necessary!
Ron
You can remain in pure C and use STL-like libraries
C Containers Library
http://code.google.com/p/ccl/wiki/PageName
BTW, this library is being proposed to be added to the next-generation C standard library.
Look at section 6 of the pdf. It will show some typical library usage. No syntactic sugar necessary!
Ron