anntzer / redeal

A reimplementation of Thomas Andrews' Deal in Python.
Other
64 stars 41 forks source link

Consider using combinatorial number system to flatten #47

Closed phiSgr closed 7 months ago

phiSgr commented 8 months ago

The table in Shape has 38416 entries. A lot of the possibilities are not valid shapes, i.e. the corresponding s, h, d, c values don't add up to 13.

If we use a slightly more complex way to flatten the shape, we can compact the table to 16C3 = 560 possibilities.

(Shameless plug) check my implementation here: https://github.com/phiSgr/rektdeal/blob/101cb144952bd7575f8b4e896770a8b40c9f0ef4/rektdeal/src/main/kotlin/com/github/phisgr/rektdeal/internal/util.kt#L136-L144

anntzer commented 7 months ago

Thanks, that's a nice idea. Actually I think in Python it's even easier (and possibly hardly slower...) to simply have a list of all possible shapes and a dict mapping shapes back to their indices; I pushed that to main.