Created
December 25, 2015 14:08
-
-
Save showa-yojyo/07f4fd1bb9f9d09524bc to your computer and use it in GitHub Desktop.
An unused script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""mahjongscoring.py: Output a scoring table to look up the score of | |
a Mahjong hand. | |
Usage: | |
mahjongscoring.py | |
""" | |
from itertools import chain | |
__version__ = '0.0.0' | |
def fu(): | |
"""Return a generator which yields fu values.""" | |
return chain((20, 25), range(30, 120, 10)) | |
def roundup(score): | |
"""Round a score up to the nearest 100.""" | |
remainder = score % 100 | |
if remainder: | |
score += 100 | |
score -= remainder | |
return score | |
def main(): | |
"""Output a scoring table to look up the score of a Mahjong hand.""" | |
han_max = 13 + 1 | |
payment = [(f, f << 3) for f in fu()] | |
for h in range(1, han_max): | |
print(' | '.join(('fu', 'han', 'non-dealer', 'dealer'))) | |
print('-' * 60) | |
print('\n'.join(['{:3} | {:2} | {:8} ({:8}/{:8}) | {:8} ({:8})'.format( | |
f, h, | |
roundup(i << 2), | |
roundup(i), roundup(i << 1), | |
roundup(i * 6), | |
roundup(i << 1)) for f, i in payment])) | |
print('-' * 60) | |
payment = [(f, i << 1) for f, i in payment] | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excel 使ったほうが早いのでボツ。