david-pfx / AmzPlayer

A Modern Player for Zillions
Other
14 stars 1 forks source link

Reversi: custom AI Engine (Jello.dll) location and failure #6

Closed Soolost closed 3 years ago

Soolost commented 3 years ago

(sorry, I couldn’t help myself - this is primarily meant to have a record of my findings, and definitely not to push the issue)

Regarding the custom AI engine DLL’s, your remark got me thinking:

I noticed in the ZoG v2 installation that engines are addressed relative to the location of the exe. However, AmzEngine.exe is located in a subfolder, where zillions.exe is not.

Before, I tried to create the same directory structure as in ZoG v2, and put the “Engines" folder next to the “Images" folder. After all, images are addressed in a similar way as engines. But, while images are found this way, engines are not, so it turned out.

When I put the “Engines” folder from the ZoG v2 installation (holding the Ninuki and Reversi engines) next to AmzEngine.exe the dll's are found! Yey!

Unfortunately, not without trouble. 8x8 Reversi (Criss-Cross) just sits there waiting on the second player’s first turn, and when I click to return to the selection screen, this comes up:

AMZ Reversi -  Select Screen Shot 2021-08-13

Here's the console log (showing a pointer error again):

AMZ Reversi -> Select Console Log 2021-08-13.txt

Whenever you have the time and inclination ...

david-pfx commented 3 years ago

I can confirm this. The DLL is called at the DLL_Search entry point and never returns. The parameters are (since 3.0):

Does it have to be polled to know when to stop?

Regards

David M Bennett FACS


Polygamo – Programming Languages and Players for Games and Puzzles -- http://www.polyomino.com http://www.polyomino.com/

From: Soolost @.> Sent: Saturday, 14 August 2021 2:12 AM To: david-pfx/AmzPlayer @.> Cc: Subscribed @.***> Subject: [david-pfx/AmzPlayer] Reversi: custom AI Engine (Jello.dll) location and failure (#6)

(sorry, I couldn’t help myself - this is primarily meant to have a record of my findings, and definitely not to push the issue)

Regarding the custom AI engine DLL’s, your remark got me thinking:

I noticed in the ZoG v2 installation that engines are addressed relative to the location of the exe. However, AmzEngine.exe is located in a subfolder, where zillions.exe is not.

Before, I tried to create the same directory structure as in ZoG v2, and put the “Engines" folder next to the “Images" folder. After all, images are addressed in a similar way as engines. But, while images are found this way, engines are not, so it turned out.

When I put the “Engines” folder from the ZoG v2 installation (holding the Ninuki and Reversi engines) next to AmzEngine.exe the dll's are found! Yey!

Unfortunately, not without trouble. 8x8 Reversi (Criss-Cross) just sits there waiting on the second player’s first turn, and when I click to return to the selection screen, this comes up:

https://user-images.githubusercontent.com/88584129/129386611-b1952e2c-cdc8-4ce3-bca8-1c851b1b1432.png

Here's the console log (showing a pointer error again):

AMZ Reversi - https://github.com/david-pfx/AmzPlayer/files/6983739/AMZ.Reversi.-.Select.Console.Log.2021-08-13.txt > Select Console Log 2021-08-13.txt

Whenever you have the time and inclination ...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/david-pfx/AmzPlayer/issues/6 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBMEXIACL2JU7XHXQGVPVLT4U74JANCNFSM5CD4EXLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email . https://github.com/notifications/beacon/ADBMEXIW7BJZIFC2DJSNJO3T4U74JA5CNFSM5CD4EXL2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4OOZJNGA.gif

Soolost commented 3 years ago

I can confirm this. The DLL is called at the DLL_Search entry point and never returns. ... Does it have to be polled to know when to stop?

I've never created a custom engine, but what I gather from the LangRef chapter "TechNote #1: How To Write An Engine Plug-In For Zillions of Games" the main program should change a flag (memory location *pSearchStatus) to indicate that the dll should finish up.

quote: The engine does not call Zillions of Games. However, during a search it can find out from Zillions whether it should continue searching. When DLL_Search is called, the engine should store away the argument pSearchStatus and then refer to it during the search. If the user requests that the program move now or the time has expired, the value will change to kSTOPSOON. In this case the engine should return a result as soon as possible. If Zillions of Games needs to abort the search prematurely, e.g. the user has chosen to exit the program, the value will change to kSTOPNOW. In this case the engine should return as soon as possible, whether or not a good result is available. The engine should not change the value of *pSearchStatus itself. /quote.


On a different, related matter, and perhaps worth noting: moves are communicated to and from the dll using a string format. Since the (existing) dll's are expecting/generating move strings from/for ZoG, it's important that AMZ formats these strings in exactly the same way.

quote: Moves are passed back and forth as move strings. These move strings are the same as those written out to a saved game, such as "Pawn e2 - e4", and don't include the move number. For most games these strings are also the same as the move strings displayed in the move list (the part following the move number), which makes it easy for you to see what is being passed to your engine. There are two exceptions:

  1. The move involves setting piece attributes. For example, when a Rook in Chess moves, the ZRF sets an attribute saying that the Rook may no longer be used in castling. The setting of piece attributes is not displayed to the user on the movelist, but it is sent to the engine in case the engine needs that information in differentiating moves. Example: "Rook h1 - f1 @ f1 0 0"
  2. The move is a partial move. In this case a "partial" string is added. Example: "partial 2 Checker d4 - b6 x c5"

To see the exact format of moves, simply look at what is saved in the .ZSG. /quote.

(I mention this because I noticed the 'Moves record' in AMZ can show somewhat different strings than the 'Moves Played' in ZoG. See for example the Emergo screen shots in issue #1.)

david-pfx commented 3 years ago

Yes, I’ve studied that carefully. It gives no hint as to whether it is the AI engine or Zillions itself that ultimately keeps track of time. If Zillions says to think for 5 seconds and the AI runs forever, will Zillions interrupt? I don’t know.

All this code is original Zillions, not mine. If move formats sent to the AI are wrong it’s not of my doing.

But I will look at the displayed move record and see if that should be different.

david-pfx commented 3 years ago

The Go-Moku and Go version that use an engine now seem to play correctly.

The Reversi game plays, but thinks forever unless you tell it to play now. I have no idea why. Closed, but please reopen at will.