Skip to content

Releases: Kenny2github/mahjong

2.0.0rc3

08 Feb 17:43
Compare
Choose a tag to compare
2.0.0rc3 Pre-release
Pre-release

New Stuff

  • Hand.discarders contains a Player for every Tile in Hand.discarded

Changes

  • Number no longer includes Flower and Season
  • Tile and subclasses now have run-time typechecking on the number based on suit
  • Hand.play now raises a RuntimeError if the hand is part of a Round

Fixes

  • (answerable).answer could return None instead of a HandEnding when running standalone from Hand
  • Annotated some attributes that were missing them
  • Hand.turncount can no longer be None, only 0
  • Flower and Season values were being set to Wind.* instead of the integer values

2.0.0rc2

08 Feb 09:50
Compare
Choose a tag to compare
2.0.0rc2 Pre-release
Pre-release

Fixes

  • Update __all__s in the various modules
  • Cleanup a little

2.0.0rc1

08 Feb 09:46
Compare
Choose a tag to compare
2.0.0rc1 Pre-release
Pre-release

New Stuff

  • py -m mahjong now takes a --game argument to specify playing a whole game instead of the new default, one hand only.
  • mahjong.melds.FLAG_FAAN is a mapping from each WuFlag to the amount of faan it's worth.
  • Wu() now takes a discarder argument before flags representing the seat of who pays the penalty for this hand being won. It is set as a Wind to Wu.discarder.
  • Wu.flags takes the same arguments as Wu.faan and computes only the situational flags. Faan calculation is still done in Wu.faan.
  • mahjong.melds.faan is a simple function that computes faan from flags, using FLAG_FAAN.
  • Bonus-related WuFlags.
  • HandEnding.faan combines Wu.faan and Player.faan since it has access to both, as well as seat and prevailing winds.
  • HandEnding.points calculates the points that each player owes or receives, as well as still returning the flags.
  • mahjong.game.STOCK_TABLES are some stock faan-to-points translation tables to pass to HandEnding.points. The default is STOCK_TABLES['random_app'].
  • Question.SELF_DRAW_Q is now asked to confirm whether to commit to a self-draw, instead of just seizing upon it by default.
  • A Hand can be instantiated on its own now:
    • with a Round subclass if the instantiator has control over such machinery.
    • with a list of Players if the instantiator has control over the machinery by means of something other than a Round subclass.
    • with None if the Hand is to be played standalone, in which case Hand.play is the entry point instead of Game.play.
  • WuFlag.TWELVE_PIECE, GAVE_DRAGON, GAVE_KONG, and support for such penalties (including in HandEnding.points).

Changes

  • py -m mahjong now plays only one hand by default
  • WuFlag values are now hardcoded instead of auto
  • Swapped WuFlag.NINE_GATES to 1 << 9 and WuFlag.THIRTEEN_ORPHANS to 1 << 13 because it just makes sense that way
  • Renamed Wu.flags to Wu.base_flags
  • Just use *args and **kwargs in Wu.from_str for the extra arguments
  • Separated faan calculation from flags computation. This has little effect on Wu.faan; the most significant is that mutually exclusive flags are now actually mutually excluded, rather than just the faan being reduced to compensate.
  • Things that were nominally ints but semantically Winds are now all Winds, except in some cases when passing them as arguments (in which case the Wind constructor is applied).
  • Player.bonus_faan now returns both faan and flags of its own
  • HandEnding.gen: Generator is now HandEnding.hand: Hand
  • Hand.round is now Optional
  • Hand.gen and Hand.players are now set, to support playing a standalone hand
  • Stealing a tile from the previous player's discard is now confirmed by Question.MELD_FROM_DISCARD_Q for winning hands in addition to other melds
  • Removed internal Answerable ABC

Fixes

  • Wu.base_flags (formerly Wu.flags) is now properly annotated
  • Thirteen Orphans are only valid if the extra tile is a duplicate of any of the other tiles, not when it's literally any tile. A set of valid Thirteen Orphans tiles will therefore equal a set of all Thirteen Orphans tiles.
  • _UncheckedWu.fixed_melds was missing and caused an AttributeError when actually encountering Thirteen Orphans
  • Tile.from_str failed to typecheck because of suit
  • Game.play might return a HandEnding on first go, though all wins should be confirmed first by now.

1.0.0

25 Jan 19:59
Compare
Choose a tag to compare

I spent a year on this. I'm not writing it all down. See the docs.