Skip to content

playing with some different shut the box strategies

Notifications You must be signed in to change notification settings

mampersat/shut_the_box

Repository files navigation

Shut the Box

How to play

  1. Flip all the tiles UP
  2. Roll the dice
  3. Flip DOWN tiles that add up to total number rolled
  4. Continue rolling until:
  • Last tiles flipped down, player wins
  • No combination can be flipped down, player loses
flowchart LR
    A[Start<br>All tiles UP] 
    A --> C[Roll the dice]
    C --> D{Can tiles be flipped down to match the roll?}
    D -->|Yes| E[Flip DOWN tiles that add up to total number rolled]
    E --> G{All tiles flipped down?}
    G -->|Yes| H[Win]
    G -->|No| C
    D -->|No| F[Loss]
Loading

Simulate the game and find optimal strategy

def main():
    '''
    Simulate a game of Shut the Box using different strategies and report the win rate.
    '''
    
    iterations = 100_000

    stratagies = [random_tiles, 
                  highest_tile, 
                  fewest_tiles, 
                  most_tiles, 
                  expirement, 
                  adaptive_strategy, 
                  prioritize_low_high]

    # Run the game for each strategy
    for stratagy in stratagies:
        print(f"stratagy: {stratagy.__name__}")

        wins = 0
        for i in range(iterations):
            wins += play(stratagy)

        # report strategy win rate  as a percentage
        print(f"Win Rate: {wins / iterations * 100:.2f}%")      

        # report stratey win rate as number of times you have to play to expect a win
        print(f"Win Rate: {1 / (wins / iterations):.0f} games\n")  

Create a version of the game with a laser cutter


Google Sheet with form results

The Plaque

I got a bunch of blank plaques from a local auction, and it's not hard to burn stuff on to them. So I'm immortalizing all valid looking submissions (validty 100% my perrogitive) onto a plaque you can also burn at your lesiure.

Useful Links

Here are some useful links for creating a version of the game with a laser cutter and purchasing materials:

Laser Cutter Box Designs from Boxes.PY

Purchase Materials

First Pancake

Notes after playing with v1.0

  1. Lots of fine tuning on laser cutter config stuff like kerfs. Not sure if these should be put into the design or kept in configs to handle different material
  2. Lid is WAY to tall. Could be 10mm (vs. 40mm .) This might add strain on the hunge when it's open on a flat surface though. Consider hinge placement to support opening more than 180d to prevent hinge stress.
  3. Spacers are key to keeping things from rubbing. Tile box with additional supports needs tiles to be just a smidge narrower so 2 more spaces can fir next to the supports
  4. Rob holding supports can be smaller/less material. Add more trimming/rounding on upper front corner.
  5. Fill in the numbers
  6. Random frog behind the 9 tile was an awesomely awesome accident
  7. Plex lid needs the supports, just glue is very prone to seperation on box shut. Doesn't need all four - but some way to anchor it vertically is needed if not using glue
  8. Tile holder should be taller so the back pieces are flush with the top of the bottom box. Original has this, makes tile "grabbing" cleaner
  9. Overall fit - tight fit makes it difficult to glue with hot glue. Maybe with wood glue this isn't a problem
  10. Tile holder is too long. The "resting" piece in the front could be moved back quite a bit.
  11. Lots of design elements burn through to the other side
  12. Tile width - as above, get width right. Should fit 12 spacers + 2 supports
  13. Tile height - had to sand a couple to get them to flip w/o scraping the bottom. Lowering the grove would help. I like the height now. Feels right
  14. Flair: Leaves on corners is good but could be better.

Dice

Teaching ChatGPT to play

Full ChatGPT Session

tl;dr;

Initial Findings

The tree is already revealing that closing fewer tiles with each roll seems to increase the probability of reaching a winning state in many configurations. However, the model is still running for more exhaustive coverage.

Licensing

This repository contains the design files for a laser-cut toy, shared under the Creative Commons Attribution-NonCommercial (CC BY-NC) License. Feel free to use and modify the design for non-commercial purposes, but please provide credit.

Acknowledgments

This design was created using the boxes.py libraries and tools, which are licensed under the GNU General Public License (GPL). Many thanks to the contributors of boxes.py for their work in making these tools available!

Usage

To use this design, simply download the files and load them into your laser cutter software. Make any adjustments you like for non-commercial personal use.

License

This project is licensed under the CC BY-NC License.

About

playing with some different shut the box strategies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages