SkillAgentSearch skills...

MahjongKit

Riichi Mahjong Kit: (1) Game log crawler (sqlite3, json, bs4); (2) Game log preprocessor; (3) Deterministic algorithms library

Install / Use

/learn @erreurt/MahjongKit
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

JapaneseRiichiMahjongKit

|Author|Jianyang Tang (Thomas)| |---|--- |E-mail|jian4yang2.tang1@gmail.com

Contents


<a name="crawl"></a>1. Game log crawler: GameLogCrawler

| function | Description | | --------- | ----------- | | db_show_tables() | Display the structure of the database. | | batch_crawl_refids(gr_level, ite=5) | Crawl game log referral ids of players who havn't been explored yet. The crawled ids will be then inserted into the TABLE refids. | | batch_crawl_levels(self, ite=5) | Crawl levels for players who havn't had the value for level and pt in the database. The crawled information will be updated in the TABLE players.| | batch_crawl_logs(self, gr_lv, ite=10) | Crawl game logs, in which players with level higher than gr_lv are involved. The game log will be inserted into TABLE log as text. | | db_get_logs_where_players_lv_gr(self, gr_lv) | Return a generator of game logs, in which player with level higher than gr_lv are involved. | | prt_log_format(log) | Print the game log in a user friendly format |

<a name="showtable"></a>db_show_tables()

glc = GameLogCrawler()
glc.db_show_tables()
TABLE 'player': 7497 rows
      ------------------------------------------- 
    | Column     Name       Type       Primary   |
    | -------------------------------------------|
    | 0          name       text       1         |
    | 1          level      text       0         |
    | 2          pt         text       0         |
    | 3          lv         INTEGER    0         |
    | 4          retrieved  BOOLEAN    0         |
      ------------------------------------------- 

TABLE 'refids': 75575 rows
      ------------------------------------------- 
    | Column     Name       Type       Primary   |
    | -------------------------------------------|
    | 0          ref        text       1         |
    | 1          p1         text       0         |
    | 2          p2         text       0         |
    | 3          p3         text       0         |
    | 4          p4         text       0         |
      ------------------------------------------- 

TABLE 'logs': 60 rows
      ------------------------------------------- 
    | Column     Name       Type       Primary   |
    | -------------------------------------------|
    | 0          refid      text       1         |
    | 1          log        text       0         |
      ------------------------------------------- 

<a name="batchrefids"></a>batch_crawl_refids(gr_level, ite=5)]

glc = GameLogCrawler()
glc.batch_crawl_refids(17, ite=1)
Player Seria's level-十段 and pt-2000pt is updated.
   Refid 2018102710gm-00a9-0000-084f8165 - ['神風てぃっしゅ', 'トキ雀狂人戦代表', 'Seria', 'モロヘイヤ'] inserted into table refids
   Refid 2018102713gm-00a9-0000-ef452bb7 - ['真エトペン', '武威', 'Seria', 'pincers'] inserted into table refids
   Refid 2018102714gm-00a9-0000-bd0a7584 - ['銀色いがぐり', '木漏れ日', 'Seria', 'どいーん'] inserted into table refids
   Refid 2018102715gm-00a9-0000-4b3121a0 - ['ぷんぷん!', 'MrFeng', '早大ダメ修士', 'Seria'] inserted into table refids
   Refid 2018102715gm-00a9-0000-d5d084d8 - ['Seria', '懐く家畜', '★ホース★', 'とびまこ'] inserted into table refids
   Refid 2018102716gm-00a9-0000-14022cce - ['-★独眼鉄★-', '鈴侍', '至如信モノ', 'Seria'] inserted into table refids
   Refid 2018102716gm-00a9-0000-682ca8bc - ['Seria', 'びりびり☆ビリー', 'kazu-', 'ふじかつ'] inserted into table refids
   Refid 2018102717gm-00a9-0000-5385aa06 - ['Seria', 'ryo17', 'つらい。', 'とらいち'] inserted into table refids
   Refid 2018102718gm-00a9-0000-4c334959 - ['Hachinal', 'ちゃる子', 'Seria', 'のぶのぶ'] inserted into table refids
   Refid 2018102719gm-00a9-0000-5aae805b - ['Seria', 'G.K.', '生しらす', 'エスケー'] inserted into table refids
   Refid 2018102720gm-00a9-0000-260f8960 - ['Seria', 'アスタナ', 'くうたろ', 'MJの最高峰'] inserted into table refids
Player Seria's playing history was totally retrieved

<a name="batchlevels"></a>batch_crawl_levels(self, ite=5)

glc = GameLogCrawler()
glc.batch_crawl_levels(ite=1)
Player 新世界の紙's level-七段 and pt-10pt is updated.

<a name="batchlogs"></a>batch_crawl_logs(self, gr_lv, ite=10)

glc = GameLogCrawler()
glc.batch_crawl_logs(17, ite=2)
Game log of 2018102720gm-00a9-0000-260f8960 crawled and inserted into TABLE logs.
Game log of 2018102719gm-00a9-0000-5aae805b crawled and inserted into TABLE logs.

<a name="dblogs"></a>db_get_logs_where_players_lv_gr(self, gr_lv)

glc = GameLogCrawler()
log_generator = glc.db_get_logs_where_players_lv_gr(19)
for log in log_generator:
    print(log)
{'ver': 2.3, 'ref': '2017120321gm-00a9-0000-34e876fb', 'log': [[[0, 0, 0], [25000, 25000, 25000, 25000], [46], [], [12, 13, 13, 17, 22, 22, 27, 34, 37, 42, 45, 46, 47], [32, 39, 44, 22, 47, 19, 11, 11, 35, 24, 11, 18, 16, 16, 24, 28, 21, 39], [42, 46, 60, 45, 27, 60, 13, 17, 32, 37, 39, 60, 60, 60, 35, 60, 34, 60], [15, 18, 19, 26, 28, 31, 31, 32, 33, 33, 53, 38, 38], [47, 21, 14, 13, 26, 17, 43, 36, 39, 27, 46, 41, 23, 26, 11, 12, 21, 22], [19, 60, 18, 47, 31, 60, 60, 28, 33, 39, 60, 60, 38, 38, 53, 31, 32, 36], [21, 23, 25, 25, 26, 27, 28, 29, 32, 36, 38, 42, 44], [27, 15, 38, 14, 45, 37, 37, 17, 33, 29, 43, 25, 46, 14, 35, 16, 37], [32, 44, 42, 36, 60, 60, 60, 60, 60, 60, 60, 38, 38, 46, 60, 29, 60], [12, 15, 17, 19, 23, 23, 52, 28, 29, 31, 36, 41, 43], [18, 13, 41, 24, 34, 14, 24, 34, 42, 12, 41, 19, 42, 18, 44, 39, 34], [43, 31, 15, 36, 60, 29, 'r28', 60, 60, 60, 60, 60, 60, 60, 60, 60, 60], ['流局', [-1000, -1000, -1000, 3000]]], [[1, 1, 1], [24000, 24000, 24000, 27000], [11], [42], [15, 22, 24, 24, 29, 32, 33, 34, 53, 43, 44, 45, 47], [35, 23, 22, 23, 12, 39, 34, 47, 46, 46, 25, 15, 32], [43, 29, 44, 47, 45, 60, 12, 60, 60, 60, 32, 25, 60], [14, 18, 19, 19, 21, 23, 52, 27, 28, 31, 38, 42, 46], [27, 17, 41, 38, 13, 42, 24, 43, 41, 22, 43, 47, 34, 33], [42, 31, 19, 46, 41, 60, 21, 60, 60, 13, 60, 60, 52, 28], [13, 16, 24, 27, 28, 31, 36, 37, 38, 39, 39, 44, 47], [32, 17, 25, 41, 26, 46, 21, 21, 23, 12, 36, 12, 37, 18], [44, 47, 31, 32, 13, 60, 60, 60, 'r41', 60, 60, 60, 60], [51, 16, 17, 19, 21, 25, 26, 28, 28, 29, 33, 38, 39], [37, 44, 44, 18, 26, 36, 18, 26, 31, 29, 35, 29, 15], [21, 60, 60, 33, 29, 39, 26, 60, 60, 60, 38, 60, 28], ['和了', [-2100, -4100, 10300, -2100], [2, 2, 2, '満貫2000-4000点', '立直(1飜)', '門前清自摸和(1飜)', '平和(1飜)', '三色同順(2飜)']]], [[2, 0, 0], [21900, 19900, 33300, 24900], [26], [], [14, 17, 18, 19, 22, 25, 26, 33, 34, 34, 44, 45, 46], [37, 17, 11, 12, 28, 43, 13, 36, 32], [44, 46, 60, 45, 12, 17, 60, 14, 37], [12, 14, 22, 23, 26, 27, 28, 29, 36, 42, 45, 45, 46], [52, 29, 22, 'p454545', 32, 29, '29p2929', 47, 12, 18], [36, 12, 14, 46, 60, 42, 23, 60, 60, 60], [14, 15, 16, 19, 24, 24, 25, 31, 35, 37, 41, 42, 43], [16, 23, 32, 21, 38, 42, 38, 31, 36], [31, 19, 42, 60, 43, 60, 32, 35, 38], [17, 24, 27, 28, 29, 35, 39, 39, 41, 41, 46, 46, 47], [13, 41, 13, 17, '46p4646', 16, 26, 42, 44, 37], [60, 47, 60, 35, 24, 17, 29, 60, 60, 60], ['和了', [0, -5200, 0, 5200], [3, 1, 3, '40符3飜5200点', '場風 東(1飜)', '役牌 發(1飜)', 'ドラ(1飜)']]], [[3, 0, 0], [21900, 14700, 33300, 30100], [24], [], [16, 22, 24, 25, 27, 33, 34, 35, 36, 42, 44, 46, 47], [32, 31, 16, 14, 33, 33], [44, 47, 42, 46, 22, 27], [14, 16, 23, 25, 29, 31, 32, 33, 35, 38, 42, 44, 45], [36, 26, 27, 29], [44, 42, 45, 38], [12, 12, 15, 17, 18, 19, 22, 23, 26, 28, 43, 45, 46], [21, 46, 43, '46p4646', 38], [43, 15, 45, 43, 60], [11, 11, 11, 14, 17, 22, 23, 24, 29, 32, 37, 37, 38], [21, 31, 44, 12, 13, 19], [29, 14, 60, 37, 17, 60], ['和了', [-1000, 0, 1000, 0], [2, 0, 2, '30符1飜1000点', '役牌 發(1飜)']]], [[4, 0, 0], [20900, 14700, 34300, 30100], [51], [], [12, 12, 13, 14, 14, 16, 18, 19, 22, 31, 35, 39, 41], [33, 39, 28, 23, 16, 44, 37, 39, 47, 27, 21, 46, 21, 21, 45, 33], [39, 60, 19, 41, 28, 60, 31, 60, 18, 60, 47, 60, 60, 60, 60, 60], [11, 12, 14, 15, 17, 17, 22, 32, 38, 38, 39, 46, 47], [11, 26, 19, 34, 24, 53, 34, 18, 45, 34, 29, 36, 23, 16, 42, 52], [32, 22, 47, 60, 46, 39, 11, 17, 60, 60, 60, 12, 11, 23, 60], [13, 15, 19, 19, 23, 23, 24, 28, 38, 41, 42, 44, 47], [14, 31, 25, 27, 46, 17, 35, 26, 26, 13, 37, 36, 45, 13, 16], [44, 60, 41, 42, 60, 38, 60, 47, 19, 60, 60, 60, 60, 60, 19], [15, 22, 22, 26, 29, 31, 32, 33, 34, 36, 37, 44, 47], [11, 27, 28, 18, 21, 44, 43, 42, 25, 24, 43, 33, 24, 32, 46], [29, 47, 44, 11, 60, 60, 60, 31, 18, 15, 60, 60, 60, 60, 60], ['和了', [-6000, 12000, -3000, -3000], [1, 1, 1, '跳満3000-6000点', '門前清自摸和(1飜)', '三色同順(2飜)', 'ドラ(1飜)', '赤ドラ(2飜)']]], [[5, 0, 0], [14900, 26700, 31300, 27100], [45], [42], [11, 12, 16, 18, 23, 27, 33, 33, 41, 43, 44, 44, 46], [26, 43, 17, 43, 34, 17, 29, 27, 46, 33, 22, 25, 16, 18], [43, 60, 41, 60, 23, 60, 34, 12, 11, 44, 44, 'r22', 60, 60], [51, 16, 19, 22, 28, 29, 36, 37, 39, 41, 42, 46, 47], [13, 41, 28, 'p414141', 17, 37, 32, 24, 24, 11, 23, 44, 16, 34, 21], [39, 19, 42, 46, 47, 22, 60, 13, 37, 60, 60, 60, 17, 16, 34], [12, 17, 19, 19, 21, 23, 25, 32, 34, 36, 37, 38, 43], [23, 24, 13, 32, 19, 53, 21, 47, 52, 42, 26, 29, 14, 33, 21], [43, 12, 60, 17, 34, 38, 'r23', 60, 60, 60, 60, 60, 60, 60], [13, 14, 15, 15, 18, 26, 31, 31, 35, 35, 37, 39, 45], [12, 22, 45, 22, 31, 41, 38, 11, 27, 28, 13, 12, 14, 28], [45, 18, 60, 39, 26, 60, 60, 15, 37, 12, 11, 13, 22, 22], ['和了', [-1300, -2600, 7200, -1300], [2, 2, 2, '40符3飜1300-2600点', '立直(1飜)', '門前清自摸和(1飜)', '赤ドラ(1飜)']]], [[6, 0, 0], [12600, 24100, 37500, 25800], [14], [21], [13, 15, 16, 17, 18, 23, 23, 25, 28, 31, 39, 41, 44], [16, 44, 37, 14, 24, 23, 18, 12, 11], [44, 60, 31, 41, 28, 39, 37, 'r18'], [12, 17, 18, 21, 24, 34, 53, 36, 37, 39, 45, 47, 47], [23, 35, 35, 42, 13, 25, 39, 11], [21, 12, 45, 60, 60, 39, 60, 37], [16, 19, 22, 24, 26, 29, 32, 34, 38, 42, 44, 46, 47], [11, 36, 33, 27, 31, 47, 14
View on GitHub
GitHub Stars52
CategoryData
Updated3mo ago
Forks9

Languages

Python

Security Score

82/100

Audited on Dec 9, 2025

No findings