New idea is pretty decent but converting the state to an integer is expensive.

Maybe should just make the state be an integer all the time