Greg Hewgill ([info]ghewgill) wrote,
@ 2006-05-13 10:43:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:widgets

mahjongg widget

I'm back to writing more widgets using the Yahoo! Widgets framework. This one is Mahjongg, the terribly addictive tile removal solitaire game. It includes an option to generate either a random initial game, or one that is guaranteed to have a solution. It also (optionally) times your game and keeps track of your fastest time.

Interestingly, the most difficult part of writing this was writing the algorithm that generates a solvable game. The general idea is to work backwards: Start with a blank board and place pairs of matching tiles on the board (in legal positions) until you reach the starting point. Then the solution is just doing the same thing the other way - ie. forwards, like you would play it. The problem is there are ways that the game generator can sort of paint itself into a corner. For example, if you have two tiles left to place on the board (which would be the first move of a solution), you can't place them side by side on one end of a row, because the player won't be able to remove them that way. If the game generator encounters such a situation, it just gives up and tries again from scratch. On average, the generator has to start over once or twice per valid generated game.



(Post a new comment)


[info]amyrtw
2006-05-12 11:51 pm UTC (link)
As the lead tester for this widgett, I can vouch that this game is terribly addictive. I started cursing Greg as soon as he made it because I'll spend hours in front of the computer wasting time.

(Reply to this)


[info]mduell
2006-05-13 01:48 am UTC (link)
How about a FlightAware widget?

(Reply to this) (Thread)


[info]ghewgill
2006-05-13 12:01 pm UTC (link)
Something like this?

(Reply to this) (Parent)


[info]texaspatsfan
2006-05-13 06:23 pm UTC (link)
damn you, greg!

must...stop...playing...................................................

(Reply to this)


[info]paradox0220
2006-05-15 03:56 pm UTC (link)
Interestingly enough, I recently learned the Chinese way of playing this game and it is nothing like the solitaire type game we are used to. It requires at least 4 people and is more like Spades or something like that.

(Reply to this) (Thread)


[info]ghewgill
2006-05-16 10:14 am UTC (link)
Yeah, the solitaire game appears to be a relatively recent invention. Classic multiplayer Mahjongg has been played around the world for centuries!

(Reply to this) (Parent)(Thread)


[info]willyumtx
2008-10-17 06:51 pm UTC (link)
And it's confusing when people talk about playing mah jong when they are really playing the "match two tiles and remove them all" game.

The actual game is like gin rummy. And there is a lot of cool little traditional things. Like feeling the tile face to determine what it is instead of examining it visually. And slamming down certain tiles or sets with a "pow" sound.

Also, there is a wickedly cool scene involving tiles in the movie, God of Gamblers.

http://www.youtube.com/watch?v=PYUkkAGzgec

The ultimate in shuffle tracking (http://en.wikipedia.org/wiki/Shuffle_tracking) and dexterity. But then again, he is the God of Gamblers.

(Reply to this) (Parent)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…