Page 1 of 1

Path to gnubg

Posted: Fri Sep 04, 2015 10:35 am
by Musil
i had to reinstall gnubg and of course set the path to gnubg.

Below just a function which will find gnubg in less then a second when its installed
when added users of GG don't have to set the path to it themselve

Public Function GetGnuBG_Path() As String
Dim WShell As Object
Dim ExePath As String
Set WShell = CreateObject("WScript.Shell")
' As the
ExePath = WShell.regread("HKEY_CLASSES_ROOT\GnuBG_sgf_file\shell\open\command\")
ExePath = Split(ExePath, """")(1)
If Dir(ExePath, vbNormal) = "gnubg.exe" Then
GetGnuBG_Path = ExePath
End If
End Function

Re: Path to gnubg

Posted: Fri Sep 04, 2015 1:18 pm
by admin
very nice code thank u :)

Will implement it as soon as I get a development machine set back up.

Re: Path to gnubg

Posted: Fri Sep 02, 2016 4:09 pm
by admin
I finally got around to adding this code but for some reason it pulled up the path to an older version that was no longer installed. Probably would not be a problem for most users who only installed once. In any case, I did get it to work by substituting

'ExePath = WShell.regread("HKEY_CLASSES_ROOT\GnuBG_sgf_file\shell\open\command\")

with this one.. ExePath = WShell.regread("HKEY_CLASSES_ROOT\Applications\gnubg.exe\shell\open\command\")

The original one led me on a wild goose chase thinking my Dir$ was not working when actually the path it pulled up no longer exists.
But what is strange is that sgf files do open with the correct path to the current gnubg installation.

wrongpath.jpg
correctpath.jpg

Re: GreedyGammon 3.0.x work in progress version uploaded

Posted: Thu Sep 13, 2018 6:28 am
by Musil
1. Greedy Gammon 3.0 runs is fine looks good but why only fullscreen or is there a way to resize Greedy Gammon?
2. There are a few mistakes in the Dutch translation

019 Wachttwoord should be 019 Wachtwoord

075 Do you want to resign gammon?
076 Do you want to resign backgammon?
= translated to
075 Wilt u gammon ontslag?
076 Wilt u backgammon ontslag?

ontslag comes from the dutch word ontslaan it means and when you get "ontslag" it means you are "fired" and lost your job

075 Wilt u opgeven met gammon?
076 Wilt u opgeven met backgammon?


3. You have to navigate te folder of gbubg thats not necessary here some code which I use to detect the gbubg-folder

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Const UninstallKey = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
Const HKEY_LOCAL_MACHINE = &H80000002
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_QUERY_VALUE = &H1
Const ERROR_SUCCESS = 0&

Public Function GetGnuBG_Path() As String
On Local Error GoTo TrapError
Dim WShell As Object
Dim ExePath As String
Set WShell = CreateObject("WScript.Shell")
ExePath = WShell.regread("HKEY_CLASSES_ROOT\GnuBG_sgf_file\shell\open\command\")
ExePath = Split(ExePath, """")(1)
If Dir(ExePath, vbNormal) = "gnubg.exe" Then

If Not Dir(ExePath, vbNormal) = "" Then
booGnuBGFound = True
End If
Else
ExePath = ReadUnInstallKey("GNU Backgammon")
If Not ExePath = "" Then
ExePath = ExePath & "gnubg.exe"
End If
End If
GetGnuBG_Path = ExePath
Exit Function
TrapError:
End Function

Public Function ReadUnInstallKey(strRegEntry As String) As String
On Local Error GoTo ErrorTrap
Dim booFound As Boolean
Dim hKey As Long, hSubKey As Long
Dim SubKey As String * 1000, Index As Long
Dim pData As String * 1000, lData As Long
Dim strTemp As String
RegOpenKeyEx HKEY_LOCAL_MACHINE, UninstallKey, 0, KEY_ENUMERATE_SUB_KEYS, hKey
While RegEnumKeyEx(hKey, Index, SubKey, Len(SubKey), 0, vbNullString, ByVal 0&, ByVal 0&) = ERROR_SUCCESS
lData = Len(pData)
RegOpenKeyEx HKEY_LOCAL_MACHINE, UninstallKey & "\" & SubKey, 0, KEY_QUERY_VALUE, hSubKey
If RegQueryValueEx(hSubKey, "DisplayName", 0, ByVal 0, ByVal pData, lData) = ERROR_SUCCESS Then
If Not InStr(pData, strRegEntry) = 0 Then
strTemp = "Installed"
List1.AddItem pData
If RegQueryValueEx(hSubKey, "InstallLocation", 0, ByVal 0, ByVal pData, lData) = ERROR_SUCCESS Then
strTemp = Left(pData, InStr(pData, Chr(0)))
List1.AddItem pData
GoTo exit_wend
End If
booFound = False
End If
End If
RegCloseKey hSubKey
Index = Index + 1
Wend
exit_wend:
RegCloseKey hKey
ReadUnInstallKey = strTemp
Exit Function
ErrorTrap:
End Function

Greetings

Musil

Re: GreedyGammon 3.0.x work in progress version uploaded

Posted: Thu Sep 13, 2018 9:58 am
by admin
Musil wrote:
Thu Sep 13, 2018 6:28 am
1. Greedy Gammon 3.0 runs is fine looks good but why only fullscreen or is there a way to resize Greedy Gammon?
2. There are a few mistakes in the Dutch translation

019 Wachttwoord should be 019 Wachtwoord

075 Do you want to resign gammon?
076 Do you want to resign backgammon?
= translated to
075 Wilt u gammon ontslag?
076 Wilt u backgammon ontslag?

ontslag comes from the dutch word ontslaan it means and when you get "ontslag" it means you are "fired" and lost your job

075 Wilt u opgeven met gammon?
076 Wilt u opgeven met backgammon?


3. You have to navigate te folder of gbubg thats not necessary here some code which I use to detect the gbubg-folder

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long..
End Function

Greetings

Musil

Hi Musil,

I just now realized BB code had been turned off in this forum, for some reason that I can't recall. Its back on for posting code and other enhancements. If you attach the .bas file and the dutch.txt files from the languages foler that would be easier too.

Unfortunately I broke the .sgf and save jfmat functionality on the last update 3.0.44). Its just a naming mixup will be fixed, and player vs player resume is still not done yet,

Was it you that had mentioned about a screen size that was not compatible with GreedyGammon?
If you can remind me again what that screen size was, I can add it to the check list
You would still need to resize the images yourself and edit the data.txt file for the xy locations of the checkers and cube.
The board image in the "blender" folder shows what each xy location is for.

Another cool feature would be to process in VB the gnubg sgf file and extract the player grade (expert, intermediate ..) from it and how many "bad, very bad" errors are there. And how about VB code to take in gnubg position ID (ex. 4HPwATDgc/ABMA) as described here
https://www.gnu.org/software/gnubg/manu ... on-ID.html

and output it into the format
0 0 0 0 0 0 5 0 3 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 2 0
0 0 0 0 0 0 5 0 3 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 1 0

So much fun VB code so little time :D

cheers

maareyes

PS so I just looked at the loadgamegraphics sub and it shows this

Code: Select all

If IsNumeric(prfBoardSize) Then
  If Val(prfBoardSize) < 1280 Then
      prfBoardSize = "1024"
  End If
End If
      
If IsNumeric(prfBoardSize) Then
  If Val(prfBoardSize) > 1024 And Val(prfBoardSize) < 1920 Then
      prfBoardSize = "1440"
  End If
End If
      
      
If IsNumeric(prfBoardSize) Then
  If Val(prfBoardSize) > 1440 Then
      prfBoardSize = "1920"
  End If
End If
So it seems you should be able to resize the images in that 1024 folder and edit the data.txt file in there for the position of the elements. Just a wild guess.

Re: GreedyGammon 3.0.x work in progress version uploaded

Posted: Sat Sep 15, 2018 4:27 am
by Musil
Hi maareyes

1. I guess when calling gnubg from within GG having clicked on a sgf name gnubg start fullscreen, when it normally i run it resizeded. Obviously GG reset the size of Gnubg. Simple solution i don't open gnubg now manually.
2. When the bot wins te match there is the line f.e. Wins 3 points and the match
But when the player wins tat line is missing.
3. Well I now know how to minimizes GG. Normally in windows the X botton will close the application and the _ will minimizes
4. > Resize would make sense if the board and pieces resized along with the window but since they don't (I don't know how to do that.. do you?
Yes I know not how to resize te board and all other stuff in the windows, at least in my own application but tat will not help you and i can't write that kind code were i don't have access to fit at that code. I think you will not give access to your code of GG just as i don't give access to my code and why should or I ?
You spend an awfull lot to write GG and before on Fibzilla and is your work and your work only. Will give f.e. XG te source of it away ? I don't think so
5. > Another cool feature would be to process in VB the gnubg sgf file and extract the player grade (expert, intermediate ..) from it and how many "bad, very bad" errors are there.
Why do you want to add that in GG as opening a sgf in gnubg and you can see them unless you want a quick look at it in GG.
There is documentation about sgf-file but only if it is about an unanalyzed match / game. How the result of the analysis is stored is not documented. So if one want to know, one have to spend a lot of time to find how that is done
(still on my TODO list)
6. > And how about VB code to take in gnubg position ID (ex. 4HPwATDgc/ABMA) as described here
I know those page just as i do know the page about the MatchID
In the dll there is a function which generate a posID from a given position. Sadly enough decoding a posID to a position is missing
and there is not function in the dll from or to a MacthID
Others have spend time to encode/decode a posID:matchID = gnubgID f.e. XG, , BGBLITZ and a few other who have runned or do run gnubg-bots on another BG server and there is only one who coded it in VB6 and sadly enough its not open source.

Keep up de good work

Greetings

Musil

Re: GreedyGammon 3.0.x work in progress version uploaded

Posted: Sat Sep 15, 2018 5:33 am
by admin
Musil wrote:
Sat Sep 15, 2018 4:27 am

In the dll there is a function which generate a posID from a given position.

Musil
I could never figure out how to call that function. Well anyway I did write a VB version that does the same thing but I forgot what I wanted it for in the first place. It was somewhat clumsy since I didn't know about using the VB bit manipulation routines. It would be good to have in case someone wanted to import a position into GreedyGammon they could set it up in gnubg and import it from the position ID. It is not high priority anyway.

As for the code.. well the main reason for not making it public is that it would kill any usage for any form of a competitive tournament or head to head games if someone can simply edit the code and change a line to make the gnubg player give hints and enable enhanced dice setting for player vs player.


The X to close and minimize.. yes it is not standard windows behavior and is confusing. If it turns out to be a problem will ad a " - " next to the x.

Well VB programmers we are probably soon to be extinct anyway. I fell in love with VB from the very first encounter :D and I've never coded with anything else since.

Re: GreedyGammon 3.0.x work in progress version uploaded

Posted: Sat Sep 15, 2018 9:51 am
by Musil
Hi maareyes

> I could never figure out how to call that function.

How to call can be found f.e. in GoldFish.vbp, maybe also in Snowfish or BlowFish
(Just in case you don't have them anymore and want them i can mail the code to your gmail address)
(BTW you can't download them anymore for about 6 years)

> I did write a VB version that does the same thing but I forgot what I wanted it for in the first place.

You wanted to have it because off the less datatravel. At tat time where you still runned you bg-server you used and maybe still
use in the currrent version of was/is a fibsboard string like

"board:You:someplayer:3:0:0:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:1:6:2:0:0:1:1:1:0:1:-1:0:25:0:0:0:0:2:0:0:0"

= 126 chars

the same position in gnubgID =

4HPwATDgc/ABMA:cAhrAAAAAAAA = 27 chars

which means alomst 80% less data travel

Setup a position in gnubg and then past/import it in your prog is not very handy. For myself and in my application
I made it possible to setup a position more or less equal as BGBLITZ does and can play from there or save it to a JF pos-file
Which I also am able to load again.

But then you have the problem a mat-file can't be read properly by any BG prog not even when te first line contains the
gnubgID

I solved it for my own use. the mat-file start with a gnubg posID f.e.
;PosId :sOfgASSY5+ABMA:MIEFAAAAAAAA followed by the game-notation
f.e.
Game 1
JanusBlot: 0 Test: 0
1) 31: 6/5 8/5 43: 22/18 18/15

I do have also a movelist (a flexgrid with 5 Colls) a little better then gnnubg itself
and selecting a move or so it show the 8 best move or if its a double or not
and depending of my settings it shows them accordingly to the dll or gnubg itself in the
last case of course I call gnubg-cli

> well the main reason for not making it public is that it would kill any usage for any form of a competitive tournament or head to head games if someone can simply edit the code and change a line to make the gnubg player give hints

Thats almost the same reason why i don't open my source and beside that i didn't made client/prog public.
As its possible to play yourself or to login as bot and play as such.

And yes only a few lines to chance and one getting hints what to play or double or not.
Anorther reason: I like to code but not to maintain a website or to react on mail of users wen they think there is a bug
or other things and I was never interested to run a BG server

> Well VB programmers we are probably soon to be extinct anyway.

Very true I guess. Windows 10 will support VB6 as they publiced at least until 2025
and by that time, and I'm still alive, I'm older then 80.

Greetings

Musil

N.B.

I started with VB6 when i retired in 2009 and was familiar with VBA so it was not
really difficult to switch to VB6 and started building my own client/bot etc.

Re: GreedyGammon 3.0.x work in progress version uploaded

Posted: Sun Sep 16, 2018 9:22 am
by Musil
Hi maareyes

When a game it ended a form shows up with the result(s) These results are stored in a textfile and can't do anything with it.
Would it not be more handy in a real database where you can preform queries f.e. opponent len match data from to etc etc
As i have no clue how to add a screenshot of an example how I used it i will send them to your gmail address.

Greetings

Musil

Re: GreedyGammon 3.0.x work in progress version uploaded

Posted: Sun Sep 16, 2018 11:25 am
by admin
Hi Musil,

The prev server version of GreedyGammon used a mysql db to keep user data and passwords. This version is different. clients don't connect to a central server, where a central db would be the sensible way to save all data. They connect directly to each other. In this current scenario, even passwords are gone, so a db would be, in my view, not practical.

But thanks for the idea. I welcome all feedback and suggestions.

maareyes