Giter Site home page Giter Site logo

mahjongrepository / tenhou-python-bot Goto Github PK

View Code? Open in Web Editor NEW
201.0 23.0 52.0 35.33 MB

Bot for tenhou.net riichi mahjong server written in Python

License: MIT License

Dockerfile 0.04% Makefile 0.17% Python 99.70% Shell 0.09%
tenhou mahjong-bot python mahjong bot

tenhou-python-bot's People

Contributors

0xrgb avatar bogachev-pa avatar extonec avatar nihisil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tenhou-python-bot's Issues

Bot should tsumogiri if he could

Lets assume bot has already 1s and draws 1s.

If bot wants to discard 1s, current version (0.2.7) discards 1s in its hand.
In my opinion, it should tsumogiri if it could, because it gives less information to other players.

p.s. It should check akadora, because it is different pai. (e.g. 5p vs 0p)

Working with calling kan melds

For now bot don't know anything about calling kan melds (open and closed). It can improve his way to play a little bit

Score logs should consider seat wind tiebreaker

From http://arcturus.su/wiki/Tenhou.net_rules

At the end of the game, if there is a tie, the tie is broken in favor of the person having the earlier dealership.
「終了時に同点の場合は東1局の風順で順位を決定」

It means that if you are oya in 東1 (East 1), you will always win when score is tie. (東>南>西>北)

Bot logs scores when each round is started, such as [A (30,300), B (24,900), C (22,900), D (21,900)]. It sorts players by scores. But when score is even (eg. 東1), it sorts players by player numbers. (0-3)

For consistency, it should sort players as,

  1. Score
  2. Place when East 1 started

Change conditions for strategy activation

Проверять стоит ли активировать стратегию (формальный темпай, якухай и т.п.) после броска каждого соперника.

Тут ещё нужно проверить насколько адекватно бот проставляет шантены и укеире в момент активации стратегии, возможно это нужно будет тоже поменять.

Local games. Make more random wall

In local games bots have really god hands from the start almost all the time. We need to make tiles in the wall to be more random.

Example of starting hands:
1

Occassionally printing infinite empty 'GET:' after player calls Riichi

Hi Nihisil,

thank you so much for developing this repo, when I used it to play an online match(with my little dumb AI), it seems encountered a bug described in the title, here are some logs:

2017-01-17 16:50:33 DEBUG: Send: <Z />
2017-01-17 16:50:33 DEBUG: Send: <NEXTREADY />
2017-01-17 16:50:35 DEBUG: Get: <INIT seed="3,0,0,2,5,82" ten="350,158,334,158" oya="1" hai="119,77,68,116,4,37,71,74,73,90,64,66,132"/> <U/> 
2017-01-17 16:50:35 INFO: Round: 3, Honba: 0, Dora Indicators: [82]
2017-01-17 16:50:35 INFO: Players: [NoName (35,000), 上野あいみ (33,400), no_D (15,800), 紅稀 (15,800)]
2017-01-17 16:50:35 INFO: Dealer: no_D (15,800)
2017-01-17 16:50:35 INFO: Round  wind: East
2017-01-17 16:50:35 INFO: Player wind: North
2017-01-17 16:50:41 DEBUG: Get: <E114/> 
2017-01-17 16:50:42 DEBUG: Get: <N who="2" m="44139" /> 
2017-01-17 16:50:42 INFO: Meld: pon, who 2
2017-01-17 16:50:44 DEBUG: Get: <F3/> <W/> 
2017-01-17 16:50:46 DEBUG: Get: <G121/> <T54/> 
2017-01-17 16:50:47 INFO: Hand: 2m158899p1125s337z
2017-01-17 16:50:47 DEBUG: Send: <D p="132"/>
2017-01-17 16:50:47 INFO: Remaining tiles: 67
2017-01-17 16:50:48 DEBUG: Send: <Z />
2017-01-17 16:50:48 DEBUG: Get: <D132/> <U/> 
2017-01-17 16:50:49 DEBUG: Get: <E123/> <V/> 
2017-01-17 16:50:53 DEBUG: Get: <F60/> 
2017-01-17 16:50:58 DEBUG: Get: <W/> 
2017-01-17 16:50:59 DEBUG: Get: <G124/> <T63/> 
2017-01-17 16:51:00 INFO: Hand: 2m1578899p1125s33z
2017-01-17 16:51:00 DEBUG: Send: <D p="37"/>
2017-01-17 16:51:00 INFO: Remaining tiles: 63
2017-01-17 16:51:01 DEBUG: Get: <D37/> <U/> 
2017-01-17 16:51:02 DEBUG: Get: <E34/> <V/> 
2017-01-17 16:51:03 DEBUG: Send: <Z />
2017-01-17 16:51:03 DEBUG: Get: <F135/> <W/> 
2017-01-17 16:51:08 DEBUG: Get: <G133/> <T81/> 
2017-01-17 16:51:09 INFO: Hand: 2m578899p11235s33z
2017-01-17 16:51:09 DEBUG: Send: <D p="4"/>
2017-01-17 16:51:09 INFO: Remaining tiles: 59
2017-01-17 16:51:10 DEBUG: Get: <D4/> 
2017-01-17 16:51:11 DEBUG: Get: <U/> 
2017-01-17 16:51:12 DEBUG: Get: <E32/> <V/> 
2017-01-17 16:51:13 DEBUG: Get: <F127/> <W/> 
2017-01-17 16:51:16 DEBUG: Get: <G107/> <T16/> 
2017-01-17 16:51:17 INFO: Hand: 5m578899p11235s33z
2017-01-17 16:51:17 DEBUG: Send: <D p="16"/>
2017-01-17 16:51:17 INFO: Remaining tiles: 55
2017-01-17 16:51:18 DEBUG: Send: <Z />
2017-01-17 16:51:18 DEBUG: Get: <D16/> <U/> 
2017-01-17 16:51:20 DEBUG: Get: <E98/> <V/> 
2017-01-17 16:51:22 DEBUG: Get: <F101/> 
2017-01-17 16:51:23 DEBUG: Get: <W/> 
2017-01-17 16:51:24 DEBUG: Get: <G36/> <T91/> 
2017-01-17 16:51:25 INFO: Hand: 578899p112355s33z
2017-01-17 16:51:25 DEBUG: Send: <D p="54"/>
2017-01-17 16:51:25 INFO: Remaining tiles: 51
2017-01-17 16:51:26 DEBUG: Get: <D54/> <U/> 
2017-01-17 16:51:27 DEBUG: Get: <E131/> <V/> 
2017-01-17 16:51:31 DEBUG: Get: <F27/> 
2017-01-17 16:51:33 DEBUG: Send: <Z />
2017-01-17 16:51:33 DEBUG: Get: <W/> 
2017-01-17 16:51:34 DEBUG: Get: <g118 t="1"/> 
2017-01-17 16:51:35 DEBUG: Send: <N />
2017-01-17 16:51:36 DEBUG: Get: <T31/> 
2017-01-17 16:51:37 INFO: Hand: 8m78899p112355s33z
2017-01-17 16:51:37 DEBUG: Send: <D p="31"/>
2017-01-17 16:51:37 INFO: Remaining tiles: 47
2017-01-17 16:51:38 DEBUG: Get: <D31/> <U/> 
2017-01-17 16:51:39 DEBUG: Get: <E106/> <V/> 
2017-01-17 16:51:41 DEBUG: Get: <F129/> <W/> 
2017-01-17 16:51:44 DEBUG: Get: <g130/> <T41/> 
2017-01-17 16:51:45 INFO: Hand: 278899p112355s33z
2017-01-17 16:51:45 DEBUG: Send: <D p="41"/>
2017-01-17 16:51:45 INFO: Remaining tiles: 43
2017-01-17 16:51:46 DEBUG: Get: <D41/> <U/> 
2017-01-17 16:51:48 DEBUG: Send: <Z />
2017-01-17 16:51:48 DEBUG: Get: <E0/> <V/> 
2017-01-17 16:51:50 DEBUG: Get: <F83/> <W/> 
2017-01-17 16:51:52 DEBUG: Get: <g109/> <T65/> 
2017-01-17 16:51:53 INFO: Hand: 788899p112355s33z
2017-01-17 16:51:53 DEBUG: Send: <D p="63"/>
2017-01-17 16:51:53 INFO: Remaining tiles: 39
2017-01-17 16:51:54 DEBUG: Get: <D63/> 
2017-01-17 16:51:58 DEBUG: Get: <U/> 
2017-01-17 16:51:59 DEBUG: Get: <e1/> <V/> 
2017-01-17 16:52:00 DEBUG: Get: <f35/> 
2017-01-17 16:52:03 DEBUG: Send: <Z />
2017-01-17 16:52:03 DEBUG: Get: <W/> 
2017-01-17 16:52:04 DEBUG: Get: <g96/> <T89 t="32"/> 
2017-01-17 16:52:05 INFO: Hand: 88899p1123555s33z
2017-01-17 16:52:05 DEBUG: Send: <REACH hai="64" />
2017-01-17 16:52:07 DEBUG: Send: <D p="64"/>
2017-01-17 16:52:07 INFO: Remaining tiles: 35
2017-01-17 16:52:08 DEBUG: Get: <REACH who="0" step="1"/> 
2017-01-17 16:52:09 DEBUG: Get: 
2017-01-17 16:52:10 DEBUG: Get: 
2017-01-17 16:52:11 DEBUG: Get: 
2017-01-17 16:52:12 DEBUG: Get: 
2017-01-17 16:52:13 DEBUG: Get: 
2017-01-17 16:52:14 DEBUG: Get: 
2017-01-17 16:52:15 DEBUG: Get: 
2017-01-17 16:52:16 DEBUG: Get: 
2017-01-17 16:52:17 DEBUG: Get: 
2017-01-17 16:52:18 DEBUG: Send: <Z />
2017-01-17 16:52:18 DEBUG: Get: 
2017-01-17 16:52:19 DEBUG: Get: 
2017-01-17 16:52:20 DEBUG: Get: 
2017-01-17 16:52:21 DEBUG: Get: 
2017-01-17 16:52:22 DEBUG: Get: 
2017-01-17 16:52:23 DEBUG: Get: 
2017-01-17 16:52:24 DEBUG: Get: 
2017-01-17 16:52:25 DEBUG: Get: 
2017-01-17 16:52:26 DEBUG: Get: 
2017-01-17 16:52:27 DEBUG: Get: 
2017-01-17 16:52:28 DEBUG: Get: 
2017-01-17 16:52:29 DEBUG: Get: 
2017-01-17 16:52:30 DEBUG: Get: 
2017-01-17 16:52:31 DEBUG: Get: 
2017-01-17 16:52:32 DEBUG: Get: 
2017-01-17 16:52:33 DEBUG: Send: <Z />
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/home/hao/mahjong/tenhou-python-bot/project/tenhou/client.py", line 304, in send_request
    self._send_message('<Z />')
  File "/home/hao/mahjong/tenhou-python-bot/project/tenhou/client.py", line 280, in _send_message
    self.socket.sendall(message.encode())
BrokenPipeError: [Errno 32] Broken pipe

2017-01-17 16:52:33 DEBUG: Get: 
2017-01-17 16:52:34 DEBUG: Get: 
2017-01-17 16:52:35 DEBUG: Get: 
2017-01-17 16:52:36 DEBUG: Get: 
2017-01-17 16:52:37 DEBUG: Get: 
2017-01-17 16:52:38 DEBUG: Get: 
2017-01-17 16:52:39 DEBUG: Get: 
2017-01-17 16:52:40 DEBUG: Get: 
2017-01-17 16:52:41 DEBUG: Get: 
2017-01-17 16:52:42 DEBUG: Get: 
2017-01-17 16:52:43 DEBUG: Get: 
2017-01-17 16:52:44 DEBUG: Get: 
2017-01-17 16:52:45 DEBUG: Get: 
2017-01-17 16:52:46 DEBUG: Get: 
2017-01-17 16:52:47 DEBUG: Get: 
2017-01-17 16:52:48 DEBUG: Get: 
2017-01-17 16:52:49 DEBUG: Get: 
2017-01-17 16:52:50 DEBUG: Get: 
2017-01-17 16:52:51 DEBUG: Get: 
2017-01-17 16:52:52 DEBUG: Get: 
2017-01-17 16:52:53 DEBUG: Get: 
2017-01-17 16:52:54 DEBUG: Get: 
2017-01-17 16:52:55 DEBUG: Get: 
2017-01-17 16:52:56 DEBUG: Get: 
2017-01-17 16:52:57 DEBUG: Get: 
2017-01-17 16:52:58 DEBUG: Get: 
2017-01-17 16:52:59 DEBUG: Get: 
2017-01-17 16:53:00 DEBUG: Get: 
2017-01-17 16:53:01 DEBUG: Get: 
2017-01-17 16:53:02 DEBUG: Get: 
2017-01-17 16:53:03 DEBUG: Get: 
2017-01-17 16:53:04 DEBUG: Get: 
2017-01-17 16:53:05 DEBUG: Get: 
2017-01-17 16:53:06 DEBUG: Get: 
2017-01-17 16:53:07 DEBUG: Get: 
2017-01-17 16:53:08 DEBUG: Get: 
2017-01-17 16:53:09 DEBUG: Get: 
2017-01-17 16:53:10 DEBUG: Get: 
2017-01-17 16:53:11 DEBUG: Get: 
2017-01-17 16:53:12 DEBUG: Get: 
2017-01-17 16:53:13 DEBUG: Get: 
2017-01-17 16:53:14 DEBUG: Get: 
2017-01-17 16:53:15 DEBUG: Get: 
2017-01-17 16:53:16 DEBUG: Get: 
2017-01-17 16:53:17 DEBUG: Get: 
2017-01-17 16:53:18 DEBUG: Get: 
2017-01-17 16:53:19 DEBUG: Get: 
2017-01-17 16:53:20 DEBUG: Get: 
2017-01-17 16:53:21 DEBUG: Get: 
2017-01-17 16:53:22 DEBUG: Get: 
2017-01-17 16:53:23 DEBUG: Get: 
2017-01-17 16:53:24 DEBUG: Get: 
2017-01-17 16:53:25 DEBUG: Get: 
2017-01-17 16:53:26 DEBUG: Get: 
2017-01-17 16:53:27 DEBUG: Get: 
2017-01-17 16:53:28 DEBUG: Get: 
2017-01-17 16:53:29 DEBUG: Get: 
2017-01-17 16:53:30 DEBUG: Get: 
2017-01-17 16:53:31 DEBUG: Get: 
2017-01-17 16:53:32 DEBUG: Get: 
2017-01-17 16:53:33 DEBUG: Get: 
2017-01-17 16:53:34 DEBUG: Get: 
2017-01-17 16:53:35 DEBUG: Get: 
2017-01-17 16:53:36 DEBUG: Get: 
2017-01-17 16:53:37 DEBUG: Get: 
2017-01-17 16:53:38 DEBUG: Get: 
2017-01-17 16:53:39 DEBUG: Get: 
2017-01-17 16:53:40 DEBUG: Get: 
2017-01-17 16:53:41 DEBUG: Get: 
2017-01-17 16:53:42 DEBUG: Get: 
2017-01-17 16:53:43 DEBUG: Get: 
2017-01-17 16:53:44 DEBUG: Get: 
2017-01-17 16:53:45 DEBUG: Get: 

Change the way how we build our hand with tanyao strategy

Добавить новый метод process_closed_hand_discards в стратегию.

Для таньяо там будет логика предпочтения центральных, при 5% укеире2.

Для остальных стратегий метод будет пустым.

INFO prints dan instead of score

2017-06-22 17:20:01 INFO: Round: 3, Honba: 1, Dora Indicators: [73]
2017-06-22 17:20:01 INFO: Players: [isi1017 (61,400), 辺銀堂 (25,500), ToukaBot (13,100), にこぷり麻雀道. (2級)]
2017-06-22 17:20:01 INFO: Dealer: 辺銀堂 (25,500)
2017-06-22 17:20:01 INFO: Round  wind: East
2017-06-22 17:20:01 INFO: Player wind: West

Here is the link of full log file.
https://app.box.com/s/futa0t1619l1g848trmeihzq8as0lv20

Implement basic support for defence

Theoretically it should significantly increase average place.

I think for the first version beatori will be enough. So, when bot in the defence mode it will fold 100% safe and suji tiles.

  • Store 100% safe tiles for each opponent
  • Calculate presumably safe tiles (based on suji) for each opponent
  • Detect when to go to the defence. For the start I think it can be opponent riichi trigger

Support AI plugins

Allow to easily integrate new AI (from other developers) to the project. Need to think about some kind of plugins system

Logging error related to character set (Codepage)?

Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\logging\__init__.py", line 994, in emit
    stream.write(msg)
UnicodeEncodeError: 'cp949' codec can't encode character '\u5c2d' in position 42: illegal multibyte sequence
Call stack:
  File "main.py", line 70, in <module>
    main()
  File "main.py", line 66, in main
    connect_and_play()
  File "D:\tenhou-python-bot\project\tenhou\main.py", line 21, in connect_and_play
    client.start_game()
  File "D:\tenhou-python-bot\project\tenhou\client.py", line 427, in start_game
    logger.info('Final results: {}'.format(self.table.get_players_sorted_by_scores()))
Message: 'Final results: [尭 (51,600) 61.0, Sith (20,300), tn0975 (14,600) -25.0, Bot (13,500) -36.0]'
Arguments: ()

AI didn't stop and just keep playing. It prints errors when it needs to print japanese nickname.


  • OS: Windows 10
  • Python version: Python 3.6.5 (AMD64)
  • Program version: v0.3.2 (bb53372a)
PS D:\> chcp
Activated Code Page: 949

PS. I'm assuming that this is a problem of python logging module. However, I cannot reproduce this error when I use python logger. The closest error message I could get was this.

>>> x = chr(9999) # Which are cannot be encoded with CP949 (EUC-KR)
>>> x
'✏'
>>> x.encode('cp949')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'cp949' codec can't encode character '\u270f' in position 0: illegal multibyte sequence

Improve call kan logic

Добавить учет укеире при объявлении кана: если укеире после получения с риншана ненужного изолированного тайла падает по сравнению с отказом от объявления кана, то не объявлять.

Пример плохого кана:

1

Bot crashed when calling kan set

2017-06-22 13:45:12 INFO: Meld: Type: pon, Tiles: 555s [88, 90, 91] by 0
2017-06-22 13:45:12 INFO: With hand: 34m455666p + 5s [345m, 555s]
2017-06-22 13:45:12 INFO: Discard tile after called meld: 4p
2017-06-22 13:45:12 DEBUG: Send: <D p="48"/>
2017-06-22 13:45:13 DEBUG: Get: <D48/> <U/> 
2017-06-22 13:45:16 DEBUG: Get: <e47/> <V/> 
2017-06-22 13:45:20 DEBUG: Send: <Z />
2017-06-22 13:45:21 DEBUG: Get: <f59 t="3"/> 
2017-06-22 13:45:21 DEBUG: Send: <N type="2" />
2017-06-22 13:45:21 INFO: We called a kan set!
2017-06-22 13:45:22 DEBUG: Get: <N who="0" m="15106" /> <T45/> 
2017-06-22 13:45:22 ERROR: Unexpected exception
Traceback (most recent call last):
  File "/_github/tenhou-python-bot-0.2.6/project/tenhou/main.py", line 21, in connect_and_play
    client.start_game()
  File "/_github/tenhou-python-bot-0.2.6/project/tenhou/client.py", line 316, in start_game
    self.table.add_called_meld(meld.who, meld)
  File "/_github/tenhou-python-bot-0.2.6/project/mahjong/table.py", line 75, in add_called_meld
    self.get_player(player_seat).add_called_meld(meld)
  File "/_github/tenhou-python-bot-0.2.6/project/mahjong/player.py", line 214, in add_called_meld
    self.tiles.remove(meld.called_tile)
ValueError: list.remove(x): x not in list
2017-06-22 13:45:22 INFO: Ending the game...
2017-06-22 13:45:22 ERROR: Game was ended without success

Here is the log.

Is there a way to see whether a discarded tile from an opponent player is changed tile or not?

Hi, thanks for your effort in this project. I have a question about possibility of telling whether a tile is a changed tile or not.

The definition of a changed tile: if the tile a player discards has existed in his hand, it is called a "changed tile"; if the tile a player discards is the one he just draws, it is NOT a "changed tile". I believe this information is important for mahjong players. When playing mahjong face to face, we always pay attention to players who changed their hands.

In mjlog, we can easily get this information since all tiles (including those in the hands of opponent players) are visible; however, is it possible to get this information while playing real games?

Thanks very much.

Fail to connect if AI takes a long time to load(~3s).

In Tenhou client, if the overhead of AI takes approximately longer than 3s, then it'll show some socket timeout messages, the fix should be trivial.

Many thanks.

Edit:
Sample output:

2017-03-06 11:19:40 INFO: Bot AI enabled: True
2017-03-06 11:19:52 DEBUG: Send: <HELO name="NoName" tid="f0" sx="M" />
2017-03-06 11:19:52 DEBUG: Get: 
2017-03-06 11:19:52 DEBUG: Send: <BYE />
2017-03-06 11:19:52 INFO: End of the game

Are these lines correct?

I feel there are some lines look incorrect:

First: Should it be self.number_isolated_tiles ^= (1 << k)?
Second and Third: Should they be self._run(depth)?

I tried to fix them as above and they passed your unit tests as well. However, I haven't find any negative case that make only original code fail.
So, what do you think about above changes?

Implement bots runner

It should be the runner that will run 4 copy of our bots and will play a lot of hanchans.

We need it to test our improvements in bot strategy.

So, for example we have version 0.0.1 of our bot logic and we did some improvements in our code, for example our bot can build hand more effective now. We will load three copy of bot with v.0.0.1 and one copy with new logic. Runner will play a lot of hanchans (for example 1000), and calculate what is winning rate of new bot version.

  • Ability to load any version of the code (so, not only code that in current project)
  • Ability to play hanchan between different bots
  • Detailed statistics for the played games

AI crashes when calling chankan

2017-07-03 00:26:23 INFO: Hand: 23m55z + 8s [888s, 456m, 999s]
2017-07-03 00:26:24 DEBUG: Send: <N type="5" hai="103" />
2017-07-03 00:26:24 INFO: We called a kan set!
2017-07-03 00:26:25 DEBUG: Get: <N who="0" m="38515" /> <T51/> 
2017-07-03 00:26:25 INFO: Meld: Type: chankan, Tiles: 8888s [100, 101, 102, 103] by 0
2017-07-03 00:26:25 INFO: Hand: 23m8s55z + 4p [888s, 456m, 999s]
2017-07-03 00:26:26 ERROR: Unexpected exception
Traceback (most recent call last):
  File "/mnt/d/programming/wsl/tenhou-python-bot-0.2.7/project/tenhou/main.py", line 24, in connect_and_play
    client.start_game()
  File "/mnt/d/programming/wsl/tenhou-python-bot-0.2.7/project/tenhou/client.py", line 277, in start_game
    discarded_tile = self.player.discard_tile()
  File "/mnt/d/programming/wsl/tenhou-python-bot-0.2.7/project/mahjong/player.py", line 157, in discard_tile
    tile_to_discard = self.ai.discard_tile()
  File "/mnt/d/programming/wsl/tenhou-python-bot-0.2.7/project/mahjong/ai/main.py", line 60, in discard_tile
    selected_tile = self.process_discard_options_and_select_tile_to_discard(results, shanten)
  File "/mnt/d/programming/wsl/tenhou-python-bot-0.2.7/project/mahjong/ai/main.py", line 96, in process_discard_options_and_select_tile_to_discard
    return self.chose_tile_to_discard(results)
  File "/mnt/d/programming/wsl/tenhou-python-bot-0.2.7/project/mahjong/ai/main.py", line 211, in chose_tile_to_discard
    temp_tile = results[0]
IndexError: list index out of range
2017-07-03 00:26:26 INFO: Ending the game...
2017-07-03 00:26:26 ERROR: Game was ended without success

Version is 0.2.7.

Here is the link of full log file.
https://app.box.com/s/zj8tos4qcdjcy5f3d4iolacz9dtiz88u

Change open hand rules for tanyao

До тех пор, пока не можем считать "число шантен на таняо", предлагаю руководствоваться такой логикой:

Правила early-return, когда даже не будем смотреть дальше:

  1. Если в руке 3 или более неизолированных нецентральных тайла, то не открываемся.
  2. Если в руке 2 или более неизолированных нецентральных тайла и это ишантен, то не открываемся.
  3. Если в руке с открытым сетом и заменой нецентральных тайлов на одиночные ветра и драконы число шантен хуже, чем было до открытия, то не открываемся.

Теперь правила, когда надо открываться, если через все предыдушие проверки мы прошли:
4. Если в руке больше 2 центральных дор.
5. Если в руке 2 центральные доры и ход > 6.

Improve the way to build a hand

Currently bot can discard completed set of tiles (for example it discarded pon of dragons).

We need to improve the situation with hand building.

Add basic strategies selection

Something like:

  1. Player called riiichi and our hand in the bad shape, let's go for defence
  2. We are on the first place and there is a fourth south round, we can go for fast and cheap hand

And etc.

Additional conditions for open hand

Если есть возможность взять чи или пон несколькими способами, то:

Сортируем все варианты по укеире, берем самый выгодный. При этом учитываем, что нам после объявления не придется кидать дору.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.