I’ve been playing enough Letterpress lately to realize that I’m not great at it. This is super frustrating for me when this is a game that you could easily teach a computer to play.
I’m not the first person to have that thought. There are plenty of cheating programs for Letterpress (just google or search in the app store).
I haven’t investigated these solvers but in thinking about the problem, the basic approach would seem to be:
Take screenshot of game and import it into solver
Parse the board into a string of letters
Reduce a dictionary of valid words against those characters to find playable words
Optionally make recommendations of which word to play based on current board state and strategy.
I wondered how quickly I could throw something together to simply parse the game board into a string of letters. It turns out it is super easy. To get started I took a screenshot of a game in progress and downloaded it from my phone.
Pretty straight-forward, right? For each state I specify which of the sprite sub-images it should show.
Unfortunately, I was bumping into an issue in Chrome where the button would sometimes flash between image states on hover and active.
After a bit of googling, I found an answer. The problem is that I was specifying the URL redundantly, causing Chrome to show no background while it briefly loads that same sprite again to show it at the new position. After a little digging in the Compass docs, I found sprite-position and tweaked accordingly: