Mahjong, against Hazel
Hazel activities › Hazel AI opponents · source on GitHub · hazeljs on npmHong Kong rules: you against three Hazel players, who sit in turn order to your right, across and to your left. Make a winning hand of four sets and a pair: a set is a chow (three in a row of one suit), a pung (three alike) or a kong (four alike). On your turn you draw (the page does it) and discard: tap a tile, then tap it again. When another player discards, you may claim the tile, to win or to make a pung or a kong, or a chow if you are next. A win counts its faan, and the faan make the points. The deal, the turns, the claims and which comes first, the winning hands, the faan and the points, and what each Hazel player discards and claims, are a Hazel program, shown beside the table.
This app needs JavaScript, and a page served over http (python3 -m http.server, then localhost).
The vocabulary the module sees (mahjong/rules/preamble.hz): a tile is a number from 0 to 33. The listings are text, highlighted, until Edit in Hazel opens each in Hazel's own editor; an edit changes the next step of the game.
loading preamble.hz…
(start, step, options, next_hand).loading Mahjong.hz…
hazeljs-examples · versions · Apache 2.0 (code), CC BY 4.0 (words, the icon) · by Matthew Hammer · an example for hazeljs