/akochan-reviewer

🀄️ Review your Tenhou or Mahjong Soul (Jantama) log with mjai-compatible mahjong AI such as akochan.

Primary LanguageRustApache License 2.0Apache-2.0

akochan-reviewer

GitHub Workflow Status GitHub release (latest by date including pre-releases) GitHub code size in bytes License

Review your Tenhou or Mahjong Soul (Jantama) log with mahjong AI akochan.

Try it online! | Demo result page

This tool is still in early stages. There are still lots of features to be implemented, and breaking changes may be made at anytime. Suggestions and contributions are welcome. 日本語もおk.

How to Review Mahjong Soul Logs

  • Download the latest release
  • Open review-online.bat
  • Paste majsoul log and press enter
  • Enjoy getting bullied by the best enko JK ako

Example

$ # Review majsoul
$ review-online.bat

$ # Alternatively, if the online bot dies
$ review-onffline.bat


$ # Review https://tenhou.net/0/?log=2019050417gm-0029-0000-4f2a8622&tw=2
$ # Note that you may need to quote it in the shell to escape the string
$ akochan-reviewer "https://tenhou.net/0/?log=2019050417gm-0029-0000-4f2a8622&tw=2"

$ # Review https://game.mahjongsoul.com/?paipu=190425-146daa2a-68c2-4b7e-a8d7-2b5c71b54b00_a458023588

$ # Alternatively, you can specify the log ID and actor manually
$ akochan-reviewer -t 2019050417gm-0029-0000-4f2a8622 -a 2

$ # Review with arbitrary pt distribution
$ akochan-reviewer --pt 75,30,0,-165 "https://tenhou.net/0/?log=2019050417gm-0029-0000-4f2a8622&tw=2"

$ # Review with arbitrary pt distribution under the acceptance of <=0.05 pt deviation
$ akochan-reviewer --pt 75,30,0,-165 -n 0.05 "https://tenhou.net/0/?log=2019050417gm-0029-0000-4f2a8622&tw=2"

$ # Review with placement EV instead of pt EV
$ akochan-reviewer -e "https://tenhou.net/0/?log=2019050417gm-0029-0000-4f2a8622&tw=2"

$ # Review with placement EV instead of pt EV under the acceptance of <=0.002 placement deviation
$ akochan-reviewer -e -n 0.002 "https://tenhou.net/0/?log=2019050417gm-0029-0000-4f2a8622&tw=2"

$ # Review 東2局1本場 and 東3局 only
$ akochan-reviewer -k E2.1,E3 "https://tenhou.net/0/?log=2019050417gm-0029-0000-4f2a8622&tw=2"

Usage

USAGE:
    akochan-reviewer.exe [FLAGS] [OPTIONS] [URL]

FLAGS:
        --anonymous           Do not include player names.
    -h, --help                Prints help information
        --json                Output review result in JSON instead of HTML.
        --no-open             Do not open the output file in browser after finishing.
        --no-review           Do not review at all. Only download and save files.
    -e, --use-placement-ev    Use final placement EV instead of pt EV. This will override --pt and "jun_pt" in
                              --tactics-config.
    -V, --version             Prints version information
    -v, --verbose             Use verbose output.
        --without-viewer      Do not include log viewer in the generated HTML report.

OPTIONS:
    -a, --actor <INDEX>                      Specify the actor to review. It is the number after "&tw=" in tenhou's log
                                             url.
        --actor-name <ACTOR_NAME>            Specify the actor name to review when --in-file is specified and --actor is
                                             not specified
    -d, --akochan-dir <DIR>                  Specify the directory of akochan. This will serve as the working directory
                                             of akochan process. Default value "akochan".
    -n, --deviation-threshold <THRESHOLD>    THRESHOLD is an absolute value that the reviewer will ignore all
                                             problematic moves whose EVs are within the range of [best EV - THRESHOLD,
                                             best EV]. This option is effective under both pt and placement EV mode. It
                                             is recommended to use it with --use-placement-ev where the reward
                                             distribution is fixed and even. Reference value: 0.05 when using pt and
                                             0.001 when using placement. Default value: "0.001".
    -i, --in-file <FILE>                     Specify a tenhou.net/6 format log file to review. If FILE is "-" or empty,
                                             read from stdin.
    -k, --kyokus <LIST>                      Specify kyokus to review. If LIST is empty, review all kyokus. Format:
                                             "E1,E4,S3.1".
        --lang <LANG>                        Set the language for the rendered report page. Default value "ja".
                                             Supported languages: ja, en.
        --layout <LAYOUT>                    Set the layout for the rendered report page. Default value "vertical".
                                             Supported layout: vertical, v, horizontal, h.
        --mjai-out <FILE>                    Save the transformed mjai format log to FILE. If FILE is "-", write to
                                             stdout.
    -m, --mjsoul-id <ID>                     Specify a Mahjong Soul log ID to review. Example: "200417-e1f9e08d-487f-
                                             4333-989f-34be08b943c7".
        --out-dir <DIR>                      Specify a directory to save the output for mjai logs. If DIR is empty,
                                             defaults to ".".
    -o, --out-file <FILE>                    Specify the output file for generated HTML report. If FILE is "-", write to
                                             stdout; if FILE is empty, write to "{tenhou_id}&tw={actor}.html" if
                                             --tenhou-id is specified, otherwise "report.html".
        --pt <LIST>                          Shortcut to override "jun_pt" in --tactics-config. Format: "90,45,0,-135".
    -c, --tactics-config <FILE>              Specify the tactics config file for akochan. Default value "tactics.json".
    -t, --tenhou-id <ID>                     Specify a Tenhou log ID to review, overriding --in-file. Example:
                                             "2019050417gm-0029-0000-4f2a8622".
        --tenhou-ids-file <FILE>             Specify a file of Tenhou log ID list to convert to mjai format, implying
                                             --no-review.
        --tenhou-out <FILE>                  Save the downloaded tenhou.net/6 format log to FILE when --tenhou-id is
                                             specified. If FILE is "-", write to stdout.

ARGS:
    <URL>    Tenhou or Mahjong Soul log URL.

Build

Build akochan

First of all, build akochan.

$ git clone https://github.com/critter-mj/akochan.git
$ cd akochan

You have to edit Makefile and ai_src/Makfefile accordingly. Set up correct path for boost and some other options like -march=native of your choice.

On Windows MSYS2 with MinGW-w64 toolchain

$ pacman -Syu mingw-w64-x86_64-{toolchain,boost}

Edit Makefile:

LIBS = -lboost_system-mt -lws2_32 -L./ -lai -s

Edit ai_src/Makefile:

LIBS = -lboost_system-mt -lws2_32
$ cd ai_src
$ make
$ cd ..
$ make

On MacOS

$ brew install llvm libomp boost
$ cd ai_src
$ make -f Makefile_MacOS
$ cd ..
$ make -f Makefile_MacOS

On Arch Linux

$ sudo pacman -Syu base-devel boost
$ make -f Makefile_Linux
$ cd ..
$ make -f Makefile_Linux

Build akochan-reviewer

Follow the instructions here to install Rust toolchains first, if you haven't yet.

$ cd ..
$ git clone https://github.com/Equim-chan/akochan-reviewer.git
$ export RUSTFLAGS="-C target-cpu=native" # optional
$ cargo build --release

akochan-reviewer binary will be in target/release directory.

Docker

Build

$ git clone https://github.com/Equim-chan/akochan-reviewer.git
$ cd akochan-reviewer
$ git clone https://github.com/critter-mj/akochan.git
$ docker build -t akochan-reviewer:latest .

Usage

$ docker run --rm akochan-reviewer:latest --no-open -t 2019050417gm-0029-0000-4f2a8622 -a 3 -o - > report.html
$ open report.html  # or just open in browser

Troubleshooting

Assertion failed errors on Windows

Set environment variable OMP_NUM_THREADS=8.

Under cmd

> set OMP_NUM_THREADS=8

Under Powershell

> $env:OMP_NUM_THREADS = 8

Under MSYS2 bash

$ export OMP_NUM_THREADS=8

failed to canonicalize error

15:39:38.155207 src/main.rs:561	converting to mjai events...
Error: failed to canonicalize akochan_dir path "akochan"

Make sure you have the akochan directory under your current working directory where you run akochan-reviewer.

libai.so not found on Linux

Try adding the directory of libai.so to env LD_LIBRARY_PATH.

Acknowledgment

  • critter: The creater of akochan, who also proposed many advise and gave help to the development of akochan-reviewer.
  • 新篠ゆう: Who helped a lot with the report page template.
  • Amber: English translater of the report page, also has written a blog post about akochan-reviewer.

License

Apache-2.0

akochan itself was licensed separately, see https://github.com/critter-mj/akochan/blob/master/LICENSE.

Contributors ✨


critter-mj

🤔 🔧 🔣

新篠ゆう

🤔 💻 🎨

Amber

🌍 📝