Skip to content

Hand Indexer Usage #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HieronymusLex opened this issue Aug 24, 2020 · 6 comments
Closed

Hand Indexer Usage #6

HieronymusLex opened this issue Aug 24, 2020 · 6 comments

Comments

@HieronymusLex
Copy link
Contributor

HieronymusLex commented Aug 24, 2020

Just wondering how is the hand indexer being used and if it is actually required? I'm building the lib for use with WASM and getting a bunch of C compiler errors when targeting wasm32-unknown-unknown. the issues seem to be compiler errors (possibly relating to clang version and wasm or general rust+C+WASM interoperability) rather than an issue with this lib. I'll look into fixing those but in the meantime I couldn't see how the hand indexer is being used?

@HieronymusLex
Copy link
Contributor Author

If it is used but only for non-core functionality (evaluator and equity calc), perhaps we could enable it via a feature?

@kmurf1999
Copy link
Owner

Hand Indexer isn't used for the equity calculation. It's instead used for card abstraction in the actual poker solver. It maps isomorphic hands into the same index with no holes so AhKh maps to the same index as AsKs preflop.

I think you're right enabling it via a feature could be a good solution. I'll look into that as well as the C compiler errors that you're getting

@kmurf1999
Copy link
Owner

I've been looking around and it seems like there is no way to compile rust -> wasm with a static c library.

So I've created a workspace and moved hand_indexer to its own module which can be enabled with a feature. I've also made a few other changes.

I'm new to features so take a look and let me know

@kmurf1999
Copy link
Owner

Another thing, the cargo build now generates the entire hand evaluation table. The idea is the you can serve these as assets to your web app so they can be found on the client side by your wasm module

@HieronymusLex
Copy link
Contributor Author

very nice! I ran into a couple of issues when trying to get it working with WASM:

  • local file system operations aren't supported so it panics when trying do File::open
  • the equity calc uses crossbeam which results in an "operation not supported on this platform" error due to lack of threading support with WASM

I played about and got it working by not using crossbeam when on WASM and generating the evaluation table at runtime. It'd be cool to get it working with WASM but I think it might need too many changes and might make the code a bit horrible by littering it with all sorts of platform arch checks? I did also get this deployed as a Lambda function and it worked perfectly!

@kmurf1999
Copy link
Owner

I agree, I think using a lambda function or querying a rust web server is the way to go. Building the evaluation table may take too much time and use too much memory, and even if you could get the wasm to load the files that would mean the client has to download a ~200kb file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants