RuyDos publicly available

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: RuyDos publicly available

Post by AlvaroBegue »

Ras wrote:
AlvaroBegue wrote:With --enable=warning it complains about several constructors that don't initialize things that don't need to be initialized.
engine.cpp also has several warnings for redundant condition checking:

Things like line 593

Code: Select all

(b.a[g2] == WhitePawn || b.a[g2] == WhitePawn)
might be an copy/paste issue because either the coordinate or the piece type could have been intended to actually be different.

Or also line 838

Code: Select all

if ((move_type == Quiet || move_type == DoublePawnPush || move_type == KingCastle || move_type == QueenCastle)
gets the annotation that the first term is always true. But if you had intended it to be that way, you would not have put a condition around the following block?


And yeah, the sanitiser is cool. :-)
Ah, good catches. What option exactly did you use to get these warnings?
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: RuyDos publicly available

Post by Ras »

AlvaroBegue wrote:Ah, good catches. What option exactly did you use to get these warnings?
That shows up with style warnings enabled. I'm using the GUI, so that's just clicking on the yellowish whatever-it-is-icon.
tttony
Posts: 268
Joined: Sun Apr 24, 2011 12:33 am

Re: RuyDos publicly available

Post by tttony »

Cool! Another engine to fight :D

I would recommend to change in engine.cpp the condition to see if the move it's not legal to:

Code: Select all

if (board.is_king_exposed()) {
    continue;
}

// PVS here...
Also avoid the use of goto
tttony
Posts: 268
Joined: Sun Apr 24, 2011 12:33 am

Re: RuyDos publicly available

Post by tttony »

I've compiled with mingw64 7.1.0 in windows and crash, here is the error log with Dr. Memory

Code: Select all

Dr. Memory version 1.11.0 build 2 built on Aug 29 2016 02:41:18
Dr. Memory results for pid 5904: "ruy_sse42.exe"
Application cmdline: "F:\Descargas\Compressed\alonamaloh-ruydos-18439f6979af\alonamaloh-ruydos-18439f6979af\ruy_sse42.exe"
Recorded 115 suppression(s) from default F:\SSD_APPS\Software by Design\bin64\suppress-default.txt

Error #1: UNADDRESSABLE ACCESS: executing 0x0000000000000000-0x0000000000000001 1 byte(s)
# 0 <not in a module> &#40;0x0000000000000000&#41;
# 1 main                            &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
Note&#58; @0&#58;00&#58;00.715 in thread 5916

===========================================================================
FINAL SUMMARY&#58;

DUPLICATE ERROR COUNTS&#58;

SUPPRESSIONS USED&#58;

ERRORS FOUND&#58;
      1 unique,     1 total unaddressable access&#40;es&#41;
      0 unique,     0 total invalid heap argument&#40;s&#41;
      0 unique,     0 total GDI usage error&#40;s&#41;
      0 unique,     0 total handle leak&#40;s&#41;
      0 unique,     0 total warning&#40;s&#41;
      0 unique,     0 total,      0 byte&#40;s&#41; of leak&#40;s&#41;
      0 unique,     0 total,      0 byte&#40;s&#41; of possible leak&#40;s&#41;
ERRORS IGNORED&#58;
      2 potential error&#40;s&#41; &#40;suspected false positives&#41;
         &#40;details&#58; F&#58;\SSD_APPS\Software by Design\drmemory\logs\DrMemory-ruy_sse42.exe.5904.000\potential_errors.txt&#41;
     30 unique,    30 total, 201405508 byte&#40;s&#41; of still-reachable allocation&#40;s&#41;
         &#40;re-run with "-show_reachable" for details&#41;
Details&#58; F&#58;\SSD_APPS\Software by Design\drmemory\logs\DrMemory-ruy_sse42.exe.5904.000\results.txt

Code: Select all

Dr. Memory version 1.11.0 build 2 built on Aug 29 2016 02&#58;41&#58;18
Dr. Memory errors that are likely to be false positives, for pid 5904&#58; "ruy_sse42.exe"
These errors matched the blacklist 'C&#58;\Windows*.d??' for 4 frames.
Run with -lib_blacklist_frames 0 to treat these as regular errors.
If these are all false positives and your focus is unaddressable errors, consider running with -light to skip all uninitialized reads and leaks for higher performance.

Potential Error #1&#58; HANDLE LEAK&#58; KERNEL handle 0x0000000000000058 and 0 similar handle&#40;s&#41; were opened but not closed&#58;
# 0 system call NtCreateEvent              
# 1 KERNELBASE.dll!CreateEventA                          +0x91     &#40;0x000007fefd063c92 <KERNELBASE.dll+0x3c92>)
# 2 pthread_mutex_unlock                                  &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 3 pop_pthread_mem                                       &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 4 __pthread_self_lite                                   &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 5 pthread_mutex_lock                                    &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 6 enterOnceObject                                       &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 7 pthread_once                                          &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 8 std&#58;&#58;locale&#58;&#58;_S_initialize                            &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 9 std&#58;&#58;locale&#58;&#58;locale                                   &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#10 std&#58;&#58;ios_base&#58;&#58;Init&#58;&#58;Init                             &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#11 _GLOBAL__sub_I__Z19platform_initializev               &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#12 _GLOBAL__I_65535_0_ccnhghLA.o.8246                    &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#13 __mingw_init_ehandler
#14 __do_global_ctors
#15 __tmainCRTStartup
#16 .l_start     
#17 KERNEL32.dll!BaseThreadInitThunk                     +0xc      &#40;0x0000000076e159cd <KERNEL32.dll+0x159cd>)
Note&#58; @0&#58;00&#58;12.052 in thread 5916

Potential Error #2&#58; HANDLE LEAK&#58; KERNEL handle 0x000000000000005c and 0 similar handle&#40;s&#41; were opened but not closed&#58;
# 0 system call NtDuplicateObject          
# 1 KERNELBASE.dll!DuplicateHandle                       +0x34     &#40;0x000007fefd062d95 <KERNELBASE.dll+0x2d95>)
# 2 KERNEL32.dll!DuplicateHandle                         +0x15a    &#40;0x0000000076e1530b <KERNEL32.dll+0x1530b>)
# 3 pthread_mutex_unlock                                  &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 4 pop_pthread_mem                                       &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 5 __pthread_self_lite                                   &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 6 pthread_mutex_lock                                    &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 7 pthread_once                                          &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 8 std&#58;&#58;locale&#58;&#58;_S_initialize                            &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
# 9 std&#58;&#58;locale&#58;&#58;locale                                   &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#10 std&#58;&#58;ios_base&#58;&#58;Init&#58;&#58;Init                             &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#11 _GLOBAL__sub_I__Z19platform_initializev               &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#12 _GLOBAL__I_65535_0_ccnhghLA.o.8246                    &#91;../../../../../src/gcc-7.1.0/libgcc/emutls.c&#58;203&#93;
#13 __mingw_init_ehandler
#14 __do_global_ctors
#15 __tmainCRTStartup
#16 .l_start     
#17 KERNEL32.dll!BaseThreadInitThunk                     +0xc      &#40;0x0000000076e159cd <KERNEL32.dll+0x159cd>)
Note&#58; @0&#58;00&#58;12.053 in thread 5916

DUPLICATE POTENTIAL ERROR COUNTS&#58;

POTENTIAL ERRORS FOUND&#58;
      0 unique,     0 total potential unaddressable access&#40;es&#41;
      0 unique,     0 total potential invalid heap argument&#40;s&#41;
      0 unique,     0 total potential GDI usage error&#40;s&#41;
      2 unique,     2 total potential handle leak&#40;s&#41;
      0 unique,     0 total potential warning&#40;s&#41;
      0 unique,     0 total,      0 byte&#40;s&#41; of potential leak&#40;s&#41;
      0 unique,     0 total,      0 byte&#40;s&#41; of potential possible leak&#40;s&#41;
Details&#58; F&#58;\SSD_APPS\Software by Design\drmemory\logs\DrMemory-ruy_sse42.exe.5904.000\potential_errors.txt
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: RuyDos publicly available

Post by Ras »

tttony wrote:Also avoid the use of goto
goto is totally fine for error handling, especially with stacked error handling. I'm even using the extended version of that, computed goto, via a jump table if that gains more performance.

It just should only be used for jumping forward, and not as part of the algorithm itself (unless it gains measurable performance).

Fragments like

Code: Select all

if &#40;score >= beta && reduction == 0&#41;
	  goto DONE; // No need to search this again
      &#125;
      score = board.draw&#40;) ? 0 &#58; -negamax&#40;-beta, -alpha, next_depth, from_root + 1&#41;;
    DONE&#58;;
    &#125;
will certainly raise eyebrows. That should be done with if/else.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: RuyDos publicly available

Post by AlvaroBegue »

tttony wrote:Cool! Another engine to fight :D

I would recommend to change in engine.cpp the condition to see if the move it's not legal to:

Code: Select all

if &#40;board.is_king_exposed&#40;)) &#123;
    continue;
&#125;

// PVS here...
That's likely to turn out to be a simplification. I'll give it a try.

Also avoid the use of goto
Nah, I'm not going to enter any religious wars. It's my program, and if I think that goto expresses the intent of the code, I am not going to go out of my way to remove it. If I find a more expressive way to organize the code, I'll go with it.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: RuyDos publicly available

Post by AlvaroBegue »

tttony wrote:I've compiled with mingw64 7.1.0 in windows and crash, here is the error log with Dr. Memory
Paraphrasing a Spanish idiom, I am looking at that output from Dr. Memory like cows look at trains. :)

Is there any useful information there? I don't see any identifiable connection to any of my code.
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: RuyDos publicly available

Post by MikeB »

AlvaroBegue wrote:Hi,

I am making RuyDos publicly available: https://bitbucket.org/alonamaloh/ruydos

There are two things I would like help with:
1) Does it work for you? In particular I am curious if the Windows version works, because I don't have Windows anywhere and I compiled it from Linux.
2) What kind of license should I release it under? I want to be about as permissive as possible. Not that I expect anyone will really try to do anything with the code, since it's probably 700 Elo points weaker than the top programs.

Any other feedback is welcome.

Thanks!
clang warnings using the latest source:

Code: Select all

Mac-Pro&#58;alonamaloh-ruydos-88d7ffc10263 michaelbyrne$ make -j
In file included from main.cpp&#58;8&#58;
In file included from ./uci.h&#58;8&#58;
./engine.h&#58;18&#58;1&#58; warning&#58; class 'Board' was previously declared as a struct &#91;-Wmismatched-tags&#93;
class Board;
^
./board.h&#58;83&#58;8&#58; note&#58; previous use is here
struct Board &#123;
       ^
./engine.h&#58;18&#58;1&#58; note&#58; did you mean struct here?
class Board;
^~~~~
struct
1 warning generated.
In file included from uci.cpp&#58;1&#58;
In file included from ./uci.h&#58;8&#58;
./engine.h&#58;18&#58;1&#58; warning&#58; class 'Board' was previously declared as a struct &#91;-Wmismatched-tags&#93;
class Board;
^
./board.h&#58;83&#58;8&#58; note&#58; previous use is here
struct Board &#123;
       ^
./engine.h&#58;18&#58;1&#58; note&#58; did you mean struct here?
class Board;
^~~~~
struct
1 warning generated.
In file included from engine.cpp&#58;12&#58;
./board.h&#58;83&#58;1&#58; warning&#58; 'Board' defined as a struct here but previously declared as a class
      &#91;-Wmismatched-tags&#93;
struct Board &#123;
^
./engine.h&#58;18&#58;1&#58; note&#58; did you mean struct here?
class Board;
^~~~~
struct
1 warning generated.
hash.cpp&#58;251&#58;1&#58; warning&#58; 'HashEntry' defined as a struct here but previously declared as a class
      &#91;-Wmismatched-tags&#93;
struct HashEntry &#123;
^
./hash.h&#58;11&#58;1&#58; note&#58; did you mean struct here?
class HashEntry;
^~~~~
struct
1 warning generated
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: RuyDos publicly available

Post by AlvaroBegue »

MikeB wrote:
AlvaroBegue wrote:Hi,

I am making RuyDos publicly available: https://bitbucket.org/alonamaloh/ruydos

There are two things I would like help with:
1) Does it work for you? In particular I am curious if the Windows version works, because I don't have Windows anywhere and I compiled it from Linux.
2) What kind of license should I release it under? I want to be about as permissive as possible. Not that I expect anyone will really try to do anything with the code, since it's probably 700 Elo points weaker than the top programs.

Any other feedback is welcome.

Thanks!
clang warnings using the latest source:

Code: Select all

Mac-Pro&#58;alonamaloh-ruydos-88d7ffc10263 michaelbyrne$ make -j
In file included from main.cpp&#58;8&#58;
In file included from ./uci.h&#58;8&#58;
./engine.h&#58;18&#58;1&#58; warning&#58; class 'Board' was previously declared as a struct &#91;-Wmismatched-tags&#93;
class Board;
^
./board.h&#58;83&#58;8&#58; note&#58; previous use is here
struct Board &#123;
       ^
./engine.h&#58;18&#58;1&#58; note&#58; did you mean struct here?
class Board;
^~~~~
struct
1 warning generated.
In file included from uci.cpp&#58;1&#58;
In file included from ./uci.h&#58;8&#58;
./engine.h&#58;18&#58;1&#58; warning&#58; class 'Board' was previously declared as a struct &#91;-Wmismatched-tags&#93;
class Board;
^
./board.h&#58;83&#58;8&#58; note&#58; previous use is here
struct Board &#123;
       ^
./engine.h&#58;18&#58;1&#58; note&#58; did you mean struct here?
class Board;
^~~~~
struct
1 warning generated.
In file included from engine.cpp&#58;12&#58;
./board.h&#58;83&#58;1&#58; warning&#58; 'Board' defined as a struct here but previously declared as a class
      &#91;-Wmismatched-tags&#93;
struct Board &#123;
^
./engine.h&#58;18&#58;1&#58; note&#58; did you mean struct here?
class Board;
^~~~~
struct
1 warning generated.
hash.cpp&#58;251&#58;1&#58; warning&#58; 'HashEntry' defined as a struct here but previously declared as a class
      &#91;-Wmismatched-tags&#93;
struct HashEntry &#123;
^
./hash.h&#58;11&#58;1&#58; note&#58; did you mean struct here?
class HashEntry;
^~~~~
struct
1 warning generated
It's easy enough to change those `class' forward declarations to `struct'. I'll do it. Thanks!