Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

External dice DLLs with various BG bots

76 views
Skip to first unread message

mu...@compuplus.net

unread,
Mar 19, 2020, 6:26:35 AM3/19/20
to
I recently reinstalled the various bg bots wanting to come up
with ideas to run some new, interesting experiments.

One thing I want to go back to doing is playing against various
bots using external dice to see if they'll play differently.

Since this cabability was eliminated from Gnubg some time ago,
I'll have to figure out what was the last version that supported
external dice DLLs and install that version also.

With XG, I had already experimented just a little with different
variations of the Mersenne-Twister algorithm, including the one
that comes with XG.

A few days ago, I just wanted to try a very simple DLL using the
srand() and rand() functions but ran into some unexpected (and
interesting) complications.

I want to be able to use the same DLL and same seeds with various
bots but with this simplest DLL, I couldn't reproduce the same set
of rolls for the same seed with XG.

Then I started putting some debugging logic into the DLL and saw
that XG calls the dice DLL not just to fetch dice as expectedly.

It calls the DLL when you double and again when you confirm, when
a player resigns and again when confirms. It also calls the DLL
seemingly unrelated to anything visible.

Countless DLL_THREAD_ATTACH and DLL_THREAD_DETACH calls and even
DLL_PROCESS_DETACH calls after you set the seed with srand()
following the DLL_PROCESS_ATTACH, all of which make you lose the
state of the RNG and start rolling different sequences of rolls.

WTF!?

Has anyone ever tried to use external DLLs with any of the major
bg bots? If yes, can you share your experiences and/or codes here?

I don't know why I asked this, knowing that you all are a bunch of
followers, believers, buyers, shit lickers, ass kissers, cock
suckers, book writing meth phs's, etc...? :((

But, hey, just for the recordd: WTF...!?

MK

Michael

unread,
Mar 20, 2020, 1:31:55 PM3/20/20
to
Please provide a game/match and the log showing the exact times of the DLL calls.

mu...@compuplus.net

unread,
Mar 20, 2020, 8:13:35 PM3/20/20
to
On March 20, 2020 at 11:31:55 AM UTC-6, Michael wrote:

> On March 19, 2020 at 12:26:35 PM UTC+2, mu...@compuplus.net wrote:

>> Countless DLL_THREAD_ATTACH and DLL_THREAD_DETACH calls and even
>> DLL_PROCESS_DETACH calls after you set the seed with srand()
>> following the DLL_PROCESS_ATTACH, all of which make you lose the
>> state of the RNG and start rolling different sequences of rolls.

> Please provide a game/match and the log showing the exact
> times of the DLL calls.

I modified the DLL to write to a text file each time it was called,
started two games with the same seed, made a number of random moves
and cube actions, just enough to illustrate.

Moving the srand outside of the reason for call section seemed to
help but I'm not sure as I haven't compared long enough sequences.

Also, I had to comment out closing of the file right after the 4th
call (DLL_PROCESS_DETACH) in order to be able to keep writing to it.

Below are the two logs. (Dice number is the int returned by the DLL).

MK

=== Log 1 =================================================

DLL_PROCESS_ATTACH Fri Mar 20 14:16:44 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:44 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:44 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:44 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:45 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:45 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:45 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:45 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:45 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:45 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:45 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:45 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:45 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:45 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:45 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:45 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:45 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:45 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:45 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:45 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:45 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:45 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:45 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:45 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:45 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:46 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:46 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:46 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:46 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:46 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:46 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:46 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:46 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:46 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:46 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:46 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:46 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:46 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:46 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:46 2020

seed set 10631Fri Mar 20 14:16:56 2020

dice rolled 52Fri Mar 20 14:16:56 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:56 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:56 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:56 2020

DLL_THREAD_ATTACH Fri Mar 20 14:16:57 2020

DLL_THREAD_DETACH Fri Mar 20 14:16:57 2020

DLL_PROCESS_DETACH Fri Mar 20 14:16:57 2020

dice rolled 25Fri Mar 20 14:17:05 2020

dice rolled 29Fri Mar 20 14:17:07 2020

dice rolled 37Fri Mar 20 14:17:10 2020

dice rolled 51Fri Mar 20 14:17:13 2020

DLL_THREAD_DETACH Fri Mar 20 14:17:14 2020

DLL_PROCESS_DETACH Fri Mar 20 14:17:14 2020

dice rolled 34Fri Mar 20 14:17:15 2020

dice rolled 36Fri Mar 20 14:17:17 2020

dice rolled 20Fri Mar 20 14:17:26 2020

dice rolled 44Fri Mar 20 14:17:33 2020

dice rolled 27Fri Mar 20 14:17:35 2020

dice rolled 33Fri Mar 20 14:17:39 2020

dice rolled 21Fri Mar 20 14:17:41 2020

dice rolled 44Fri Mar 20 14:17:44 2020

dice rolled 43Fri Mar 20 14:17:46 2020

dice rolled 37Fri Mar 20 14:17:49 2020

dice rolled 53Fri Mar 20 14:17:52 2020

dice rolled 50Fri Mar 20 14:17:57 2020

dice rolled 35Fri Mar 20 14:17:59 2020

dice rolled 38Fri Mar 20 14:18:02 2020

dice rolled 44Fri Mar 20 14:18:04 2020

dice rolled 37Fri Mar 20 14:18:09 2020

dice rolled 12Fri Mar 20 14:18:12 2020

dice rolled 33Fri Mar 20 14:18:15 2020

dice rolled 28Fri Mar 20 14:18:18 2020

dice rolled 52Fri Mar 20 14:18:22 2020

dice rolled 27Fri Mar 20 14:18:24 2020

dice rolled 10Fri Mar 20 14:18:30 2020

dice rolled 19Fri Mar 20 14:18:31 2020

dice rolled 53Fri Mar 20 14:18:34 2020

dice rolled 19Fri Mar 20 14:18:36 2020

dice rolled 28Fri Mar 20 14:18:39 2020

DLL_THREAD_ATTACH Fri Mar 20 14:18:41 2020

DLL_THREAD_DETACH Fri Mar 20 14:18:41 2020

DLL_PROCESS_DETACH Fri Mar 20 14:18:41 2020

DLL_THREAD_DETACH Fri Mar 20 14:18:42 2020

DLL_PROCESS_DETACH Fri Mar 20 14:18:42 2020

DLL_PROCESS_DETACH Fri Mar 20 14:18:43 2020

=== Log 2 =================================================


DLL_PROCESS_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:30 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:30 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:30 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:30 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:30 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:30 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:30 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:30 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:30 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:31 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:31 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:31 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:31 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:31 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:31 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:31 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:31 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:31 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:31 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:31 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:31 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:31 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:31 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:31 2020

DLL_THREAD_ATTACH Fri Mar 20 14:23:32 2020

DLL_THREAD_DETACH Fri Mar 20 14:23:32 2020

DLL_PROCESS_DETACH Fri Mar 20 14:23:32 2020

DLL_THREAD_DETACH Fri Mar 20 14:24:00 2020

DLL_PROCESS_DETACH Fri Mar 20 14:24:00 2020

seed set 10631Fri Mar 20 14:24:26 2020

dice rolled 52Fri Mar 20 14:24:26 2020

DLL_THREAD_ATTACH Fri Mar 20 14:24:26 2020

DLL_THREAD_DETACH Fri Mar 20 14:24:26 2020

DLL_PROCESS_DETACH Fri Mar 20 14:24:26 2020

DLL_THREAD_ATTACH Fri Mar 20 14:24:27 2020

DLL_THREAD_DETACH Fri Mar 20 14:24:27 2020

DLL_PROCESS_DETACH Fri Mar 20 14:24:27 2020

dice rolled 25Fri Mar 20 14:24:56 2020

dice rolled 29Fri Mar 20 14:24:58 2020

dice rolled 37Fri Mar 20 14:25:01 2020

dice rolled 51Fri Mar 20 14:25:02 2020

dice rolled 34Fri Mar 20 14:25:05 2020

dice rolled 36Fri Mar 20 14:25:07 2020

dice rolled 20Fri Mar 20 14:25:09 2020

dice rolled 44Fri Mar 20 14:25:15 2020

dice rolled 27Fri Mar 20 14:25:17 2020

dice rolled 33Fri Mar 20 14:26:04 2020

dice rolled 21Fri Mar 20 14:26:06 2020

dice rolled 44Fri Mar 20 14:26:13 2020

dice rolled 43Fri Mar 20 14:26:17 2020

dice rolled 37Fri Mar 20 14:26:21 2020

DLL_THREAD_DETACH Fri Mar 20 14:26:29 2020

DLL_PROCESS_DETACH Fri Mar 20 14:26:29 2020

dice rolled 53Fri Mar 20 14:26:49 2020

dice rolled 50Fri Mar 20 14:26:52 2020

dice rolled 35Fri Mar 20 14:26:58 2020

dice rolled 38Fri Mar 20 14:27:02 2020

dice rolled 44Fri Mar 20 14:27:16 2020

dice rolled 37Fri Mar 20 14:27:19 2020

dice rolled 12Fri Mar 20 14:27:25 2020

dice rolled 33Fri Mar 20 14:27:28 2020

DLL_THREAD_ATTACH Fri Mar 20 14:27:35 2020

DLL_THREAD_DETACH Fri Mar 20 14:27:35 2020

DLL_PROCESS_DETACH Fri Mar 20 14:27:35 2020

DLL_THREAD_DETACH Fri Mar 20 14:27:37 2020

DLL_PROCESS_DETACH Fri Mar 20 14:27:37 2020

DLL_PROCESS_DETACH Fri Mar 20 14:27:37 2020

Michael

unread,
Mar 21, 2020, 2:15:45 PM3/21/20
to
On Saturday, March 21, 2020 at 2:13:35 AM UTC+2, mu...@compuplus.net wrote:
>
> === Log 1 =================================================
>

I am almost certain the DLL is not synchronizing with XG.
Something similar happened with my dice roller when XG was sometimes catching only one of the 2 dice.
Here's something you can do to check if this is the cause:Add some delay to the DLL say 1 sec. If the problem gets worse then for sure it's a matter of synchronisation.

mu...@compuplus.net

unread,
Mar 21, 2020, 4:57:34 PM3/21/20
to
On March 21, 2020 at 12:15:45 PM UTC-6, Michael wrote:

> On March 21, 2020 at 2:13:35 AM UTC+2, mu...@compuplus.net wrote:

>> === Log 1 =================================================

> I am almost certain the DLL is not synchronizing with XG.
> Something similar happened with my dice roller when XG was
> sometimes catching only one of the 2 dice.

Your case was different. Yours was an EXE, not a DLL. You were
passing data from your EXE to XG while it was waiting for dice
from keyboard input.

> Here's something you can do to check if this is the cause:
> Add some delay to the DLL say 1 sec. If the problem gets
> worse then for sure it's a matter of synchronisation.

You don't think I have already done that..? :) Even though it
make me feel silly afterwards.. :(

In the Mersenne-Twister source included with XG, the relevant
code is this:

=============================================================
#define WINAPI __stdcall
int WINAPI DllMain( int hModule, int ul_reason_for_call, void *lpReserved )
{
switch( ul_reason_for_call ) {
case DLL_PROCESS_ATTACH:
init_genrand((unsigned long)GetTickCount());
}
return 1;
}

__declspec( dllexport ) int Dice(void)
{
return genrand_intN(6)*8+genrand_intN(6);
}
=============================================================

In which I only replaced the 6th line with:

srand(12345);

and replaced the next to last line with:

return ((rand () % 6) + 1) * 8 + ((rand () % 6) + 1);

If I hadn't tried to reproduce the same sequence of rolls using
the same seed, I probably wouldn't have noticed anything unusual
because the DLL continued to provide dice rolls without errors.

That's only when I wanted to trace all calls to the DLL by adding
a few more lines to check for all 4 possible reasons for a call:

case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:

Since we are not supposed to see the source code of XG, (which is
distributed not just in compiled format only but also encrypted),
all I can do is to look at what it does from the outside and thus
I can't even begin to guess what may be going on in there...

MK

mu...@compuplus.net

unread,
Mar 21, 2020, 5:17:31 PM3/21/20
to
On March 21, 2020 at 2:57:34 PM UTC-6, mu...@compuplus.net wrote:

Just to prevent any unnecessary discussion about the details,
below is the entire source code of the DLL I tried. If you
want to play around with simple C projects yourselves, you
can get the "Tiny C Compiler" which is portable and merely
takes 1.5Mb of disk space.

https://en.wikipedia.org/wiki/Tiny_C_Compiler

If you want to compile a DLL like my example, save it to a
text file xyz.c and create another text file xyx.def to say:

LIBRARY xyz.dll
EXPORTS
Dice

And compile using the command:

.\tcc xyz.c -shared

Then you can used the xyz.dll in XG or other simiar bots.

Have fun :)

MK

=============================================================
#include <windows.h>
#include <stdlib.h>

#define WINAPI __stdcall

int WINAPI DllMain( int hModule, int ul_reason_for_call, void *lpReserved )
{
switch( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
srand(12345);
}
return 1;
}

__declspec( dllexport ) int Dice(void)
{
return ((rand () % 6) + 1) * 8 + ((rand () % 6) + 1);
}
=============================================================

Michael

unread,
Mar 22, 2020, 3:59:34 PM3/22/20
to
Your dice generator errs multiple times.
Dice rolled 29,37,20,27.... just to mention a few

mu...@compuplus.net

unread,
Mar 22, 2020, 9:20:43 PM3/22/20
to
On March 22, 2020 at 1:59:34 PM UTC-6, Michael wrote:

> On March 21, 2020 at 11:17:31 PM UTC+2, mu...@compuplus.net wrote:

>> return ((rand () % 6) + 1) * 8 + ((rand () % 6) + 1);

> Your dice generator errs multiple times.
> Dice rolled 29,37,20,27.... just to mention a few

For the ones who can't understand "C code" above,
the DLL passes both dice as a single number from
which XG extracts the dice by reversing the above
operation.

29 is 8 times 3 = 24 + 5 = 29 --> dice roll is 35
37 is 8 times 4 = 32 + 5 = 37 --> dice roll is 45
20 is 8 times 2 = 16 + 4 = 20 --> dice roll is 24
...

MK

Michael

unread,
Mar 23, 2020, 2:17:34 PM3/23/20
to
I don't think it's a matter of understanding "C code".
After looking at XG's documentation it's just that XG needs it to be like that. "The DLL needs to export one function called DICE that returns an integer (32 bits signed) containing the 2 dice, as of Dice1*8+Dice2"

Problem is that instead of reversing the operation yourself for creating a log file for further checking with the seed you just left it raw.

Anyway it's been a long time I dealt with these things...
0 new messages