lorserker / ben

a game engine for bridge
GNU General Public License v3.0
41 stars 30 forks source link

Installing BEN on a Mac with M1 #60

Closed ThorvaldAagaard closed 1 year ago

ThorvaldAagaard commented 1 year ago

I have download the repository and installed all prereq's

When I start game.py all goes well until we get to using the double dummy solver, when I get the error libddds.so file not found - or more specific it finds it but report (not a mach-o file)

I assume it is because the libdds.so distributed here is the old x86-architecture

ThorvaldAagaard commented 1 year ago

I have compiled a version of libdds.so for M1, but without the boost libraries.

I will add the file to this repository

ZiggerZZ commented 1 year ago

@ThorvaldAagaard I have a Mac with M2 and I have compiled libddds.so with the boost libraries. I can share the instructions if you want. I could open a PR to dds but it seems that they are not checking GitHub anymore.

ThorvaldAagaard commented 1 year ago

I think you should make a PR for DDS. I will follow up with the authors. I can see they have 10 PR's, so you are probably right they don't check GitHub

Can you add libdds.so for M2 to this site and make the platform change in dds.py - my platform is reported as darwin

ZiggerZZ commented 1 year ago

How do you want to handle Windows, Linux and Mac? Also, I don't know if my compiled libdds.so works on your machine.

ZiggerZZ commented 1 year ago

I opened a PR #126 in dds repo. There are the instructions.

ThorvaldAagaard commented 1 year ago

If you look in dds.py you can see how Lorand implemented the first version, and fell free to make a better solution.

ddsis not providing any compiled modules, and looking at the repository endplay I can see they just included the dll

BEN is using the solution from https://github.com/Afwas/python-dds and a good platform solution could also be useful there.

I have no strong feelings about how it should be implemented

ZiggerZZ commented 1 year ago

I'm using my compiled for Mac M2 libdds.so with python-dds too. I've attached it here, you can try to see if it works on your machine. libdds.so.zip

ThorvaldAagaard commented 1 year ago

I get an error message: libdds.so' not valid for use in process: library load disallowed by system policy and something about Apple not being able to check the file.

Googleing it it seems the file should be signed when from another source.

ZiggerZZ commented 1 year ago

You can try to disable Apple checking or recompile it following the instructions in https://github.com/dds-bridge/dds/pull/126.

I googled to see if I can change/sign libdds.so but I didn't find anything meaningful quickly.

ThorvaldAagaard commented 1 year ago

Googling a bit I found that just opening the file in Xcode would remove the protection attributes, so now it is almost being loaded as I hit the next error

/usr/lib/libboost_system.dylib' (no such file, not in dyld cache)

Is this something I should have installed or should it be included in the distribution?

https://support.apple.com/en-gb/guide/mac-help/mchleab3a043/mac

ZiggerZZ commented 1 year ago

Can't tell you, I installed it with homebrew and then compiled.

ThorvaldAagaard commented 1 year ago

I can see in your PR you installed a few components but did not mention which. Seems to be the right way to go. Will you give me the module names?

drk1806 commented 1 year ago

So far I am in a similar situation as you Thorvald. I am using Apple Mac M1. I overrode the security exception but now getting this.

Referenced from: <4B11801E-B761-3627-9049-FC4C382AD230> /Users/jay/miniconda3/envs/ben-main/bin/libdds.so Reason: tried: '/opt/homebrew/opt/boost/lib/libboost_system.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/boost/lib/libboost_system.dylib' (no such file), '/opt/homebrew/opt/boost/lib/libboost_system.dylib' (no such file), '/usr/local/lib/libboost_system.dylib' (no such file), '/usr/lib/libboost_system.dylib' (no such file, not in dyld cache)

ThorvaldAagaard commented 1 year ago

Try brew install boost

drk1806 commented 1 year ago

Thanks. Had to do this, /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

and then brew install boost.

Ben is working on my Apple Mac mini M1

ThorvaldAagaard commented 1 year ago

Great, now we just have to figure out, where to place that in the documentation. Perhaps Zigfrid will make a guide for Mac?

drk1806 commented 1 year ago

I am also eagaerly awaiting for the new UI you have been working on Thorvald. Images on cards would be greatly appreciated. Any update on that build?

ZiggerZZ commented 1 year ago

What did you do? Just installed boost with brew and then used libdds.so that I attached earlier in this issue?

drk1806 commented 1 year ago

Yes, used your libdds.so and used the above 2 commands I mentioned. I then restarted gameserver.py.

ThorvaldAagaard commented 1 year ago

Yes, that was all I did, besides to open libdds.so in xcode to remove the protection

ZiggerZZ commented 1 year ago

I'll open a PR with added instructions in Readme and modified dds.py.

ThorvaldAagaard commented 1 year ago

@drk1806 I am not working on a new UI, but more focusing on improving BEN's bidding an play.

ZiggerZZ commented 1 year ago

opened PR #62 I kept darwin directory for storing libdss.so on Mac.

@drk1806 I'm working on a bridge UI and AI in a separate project. I'm keen on comparing ben with my AI once I finish the development!

@ThorvaldAagaard is ben's card play based purely on dds simulations, i.e. sampling 200 full states compatible with visible cards and history and picking the best action on average? Or there is some neural networks learning for card play as well?

ThorvaldAagaard commented 1 year ago

I haven't dived deep into the play yet, but BEN is using 8 neural network in total.

One for bidding, and one for bidding info. The last six are for playing.

BEN is sampling 4096 boards, and then filtering based on bidding, leads, actual card play and information from the neural networks. Then up to 100 boards are calculated with DDS. Perhaps Lorand can find time to a better description :-)

DDS is also used during bidding, when the neural network has no clear bid to make, and I am working to change the threshold based on the actual bidding, so we besides the nn also has some logic based on what we know from the bidding.

Closing with this comment as the PR from Zigfrid has solved the issue.