mscroggs.co.uk
mscroggs.co.uk

subscribe

# Blog

2015-08-27

## MENACE

Comments in green were written by me. Comments in blue were not written by me.
I've completed my own Menace, and will be making a video shortly. :)
Mike

@JT: I bought "craft matchboxes" (without the matches inside), but it looks like your bulk normals ones work out cheapers.
Matthew

@JT: correction, the best deal I have found is $120.48 https://www.amazon.com/dp/B07F6PY9XF/r... JT @Matthew: where do you buy your matchboxes at? Because I need 1296 and the best deal I have found is 1300 for$147.57 two packs of 500 for $49.65 each and three packs of 100 for$16.09 each.
JT

@Matthew: would it still work with the "roll over" rule? or would that just make it run out?
JT

@Matthew: Thank you so much, could you email me a link for it once you make it.
JT

@JT: Yes, you could. You need a matchbox for each possible combination of fingers on the players' hands, an beads in each box for each move that could be made in that position.

When I have some time, I'll have a go a write a javascript version of it...
Matthew

Hello Matthew Scroggs, I was wondering if it would be possible to make a "menace" with the game chopsticks? If you don't know what chopsticks is, then here are the rules listed on Wikipedia
Each player uses both hands to play the game, the number of fingers extended on a hand shows the number of points that the hand has.

Both players start with each hand having one point — one finger extended on each hand.

The goal of the game is for a player to force their opponent to extend all of their fingers and thumbs on both hands or to force the player to extend all their fingers and thumb and one hand if their other hand is already out. The score has to be exactly five. If the resulting number is more than five, the player is not out no matter what. For example, if a hand with 4 points is tapped by a hand with 2 points, the hand with 4 points becomes a hand with 1 point. This rule is called a 'roll over'.

Players take turns to tap their live hand(s) against another live hand (either their own other hand or one of their opponent's).

You can tap any live hand per turn, but only one

The number of points on the tapping hand is added to the number on the tapped hand, and the player with the tapped hand extends their digits to show the new score. The tapping hand remains unchanged.

A player may tap their two hands together to transfer points from one hand to the other. This is called a split. If a player has one hand out (0 fingers) and two fingers, on the other hand, they could split to have one finger on each hand. (This counts as a turn).You are not allowed to "swap hands" or switch the number of fingers between hands without splitting (going from 4 on one hand and 2 on the other to 2 on one hand and 4 on the other).
JT

Can you make a version where the ai goes second?
Nukey

@Sterling: To make a MENACE to play chess, you'd need to draw every possible position in chess. As I wrote in this blog post, if you had a matchbox for each possible chess position, your pile of matchboxes would be this big:

This number of positions is too big for this method of learning to work for chess, so you'd need a more advanced method...
Matthew

After watching the video with yourself and Matt, you commented on teaching it chess are there any PDFs on how to teach, the machine chess. Ie what are the mechanics
Sterling

@Alex: You can find the pdfs here. boxes0.pdf to boxes3.pdf are the states for a MENACE that goes first. second_boxes0.pdf to second_boxes2.pdf are the states for a MENACE that goes second.
Matthew

I know this has been asked a lot but would it be possible if you could make a pdf of all possible states of the game on your website? If not please just send them to me directly. Thank you, alex
Alex

@Alexis: Well spotted. There was a typo in the variable name used for the third move boxes, I've fixed this now
Matthew

When I try to change the settings of MENACE2, the sixth move is considered "NaN"... Hope you can fix this
Alexis

@David: I'll email you some pdfs. I've also added the (ugly) Python code I used to make the LaTeX that makes the pdfs to GitHub.
Matthew

My son is looking at doing a variation of this for his science fair, 2 questions: 1) Has there been a version where MENACE moves 2nd? 2) where might I find a pdf of the game states, at least for MENACE moving 1rst, but if possible moving 2nd
David

@Sam: I've emailed them to you
Matthew

I loved the standupmatha video on your MENACE, and I’m trying to build my own. Any way I could get a pdf with the 304 game states on it? Thanks! :)
Sam

@Marc St-jacques: To build MENACE, I only used the boards that could happen when it is player 1's turn, as MENACE always plays as player 1.
Matthew

Hi. I tried to implement my own version but I'm stuck at generating 626 boards, after removing impossible boards, wins and ties and transposing all 8 positions for each remaining board. This fellow here https://stackoverflow.com/a/32019787/7... comes to a similar conclusion stating there are 626 mid-game boards. So what am I missing to reduce my number to 304 ? --- PS. I could have asked the fellow in question, but my reputation on S-O is too low. :(
Marc St-jacques

I put it into a resign loop after 3 games. Left it resigning for a few hours, after selecting 'random' and speed to maximum, just to see what happens. 15 seconds for the first 1,000 resigns. After a couple of hundred thousand resigns, it had slowed to about 10% of the initial speed. It didn't crash. You could use an unlimited number of beads in the first move box, to stop people like me from finding the boundaries!
g0mrb

It seems to work! It didn't loop! Is there a way to represent the matchboxes (the game positions) in memory so that the 90 and 180 rotations of a same position would automatically be the same matchbox object ?
Misccold

I played ~40 games and then it got stuck in a loop of "MENACE resigns" on an empty board. I didn't touch the settings. Cool project :-)
Misccold

@Blan: I think I've fixed that. Let me know if you still have the same problem after refreshing the page.
Matthew

The online version of MENACE is really glitchy. Whenever you change the settings, it just keeps going in the corner. For instance, I changed it to get 1 bead per victory, and it just kept going in the corner every time. It made its second move, and then it just stopped playing after that. I put x's all over the board until I won. This happens with a lot of the custom settings.
Blan

@Matthew: Cool, thanks! Also thanks for translating the site to German, really useful.
Stephan Graf

@Stephan Graf: I do. I will email them to you
Matthew

I would like to build my own menace. Would you happen to still have a document template with the possible game states in matchbox size? This could save me some work ;)
Stephan Graf

If you take one bead out on a loss and put three in on a win, then a careful human player (by judicious choice of moves) can win almost three times as much as losing, without letting the machine "catch on"
Martin

@Steve Paget: I've also made a physical MENACE since writing this. I plan to make a video at some point: I'll let you know when I do...
Matthew

Oh, I just read further and saw that Oliver made the physical MENACE. I shall menace him instead!
Steve Paget

I would love to see a game being played with this machine. Could you make a Youtube video of a game in progress, so we can see it in action? How long does a typical game last with a trained engine?
Steve Paget

@Joe: There may be a mistake in the source code somewhere. I will look into it.
Matthew

Whenever the board turns into two opposite corners, and I have played in bottom middle and center, Menace stops playing for some reason (aka I get a free move).
Joe