Skip to content

Brazedd/mahjong-soul-auto-brazed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ€„ Mahjong Soul Auto โ€” Brazed

โš ๏ธ WARNING โ€” READ BEFORE USE

Using the autopilot feature violates Mahjong Soul's Terms of Service. Automated gameplay is explicitly prohibited. Your account may be permanently banned if detected.

  • The analysis overlay (manual use only) is a grey area โ€” use at your own discretion
  • The autopilot is a clear ToS violation โ€” you use it entirely at your own risk
  • The authors take no responsibility for any bans, account loss, or other consequences
  • Do not use this on an account you care about

A Chrome extension that adds a real-time hand analysis overlay and autopilot to Mahjong Soul. Reads live game state directly from the game's JavaScript objects and provides smart discard recommendations, danger reading, and optional auto-play.

Brazed overlay in action

โœจ Features

  • Live hand analysis โ€” shanten count, best discard, ukeire (outs) calculation
  • Value-weighted discards โ€” prefers high-han paths (Honitsu, Chinitsu) over raw efficiency
  • Defence mode โ€” detects opponent riichi, switches to safe tile priority automatically
  • Genbutsu tracking โ€” tiles already discarded by a riichi player are marked 100% safe
  • Suji reading โ€” moderate safety inference from opponent discard patterns
  • Furiten warning โ€” alerts when your tenpai wait is in your own discard pile
  • Autopilot โ€” fully automated play with humanised timing and thinking pauses
  • Draggable HUD โ€” resizable crimson-themed overlay, stays out of your way

๐Ÿš€ How to Install

Requirements

  • Google Chrome (or any Chromium-based browser: Edge, Brave, Opera)
  • No Node.js, no build step โ€” just load the folder

Steps

  1. Download the extension

    • Click the green Code button on GitHub โ†’ Download ZIP
    • Extract the ZIP anywhere on your computer
  2. Open Chrome extensions page

    • Type chrome://extensions/ in the address bar and press Enter
  3. Enable Developer Mode

    • Toggle Developer Mode on in the top-right corner of the extensions page
  4. Load the extension

    • Click "Load unpacked"
    • Navigate to and select the mahjong-assistant/ folder (the one containing manifest.json)
  5. Open Mahjong Soul

If the overlay doesn't appear: Open DevTools (F12) โ†’ Console and run:

MJSDetector.stopPolling(); MJSDetector.startPolling();

๐ŸŽฎ How to Use

Overlay Controls

Action How
Show / hide overlay Press Alt+M, or click the ๐Ÿ€„ extension icon โ†’ Toggle Overlay
Move overlay Drag the BRAZED header bar
Minimize Click โ”€ in the top-right of the overlay
Toggle autopilot Press Alt+A, or use the toggle switch at the bottom of the overlay

Reading the HUD

Discard Now box โ€” the tile the engine recommends discarding. Shows:

  • Tile name and suit
  • Safety rating (โœ… Genbutsu โ†’ ๐Ÿ”ด Danger) โ€” how safe it is against riichi opponents
  • Whether discarding it reaches tenpai or improves shanten
  • How many outs (tiles that improve your hand) remain in the wall
  • Confidence: "Strong pick" = clearly best, "Marginal" = close call

Defence Mode banner โ€” appears in red/orange when an opponent is in riichi. The engine switches to safe tile priority.

Furiten warning โ€” appears in yellow if you've discarded your winning tile and can't win by Ron.

All Options list โ€” full ranked list of every possible discard with outs count and safety label.

Value Potential โ€” estimated han count and detected yaku paths (Tanyao, Riichi, Honitsu, etc.)

Autopilot Settings (Settings tab)

Setting What it does
Fastest / Slowest Time range autopilot waits before acting
Declare win automatically Calls Ron / Tsumo when available
Call Pon Steals discards to make a triplet
Call Chi Steals left player's discard to make a sequence
Chi aggression How much Chi needs to help before calling
Call Kan Makes a quad (risky โ€” off by default)

๐Ÿ–ฅ Console Commands

Open DevTools (F12) โ†’ Console while on Mahjong Soul:

MJS.autopilot(true)       // Enable autopilot
MJS.autopilot(false)      // Disable autopilot
MJS.toggle()              // Show/hide overlay
MJS.analyze()             // Force fresh analysis
MJS.getState()            // Dump detected game state
MJS.debugOp()             // Dump current oplist + game state
MJS.debugState()          // Full autopilot state dump
MJS.setDelays(1000, 3000) // Set autopilot delay range (ms)

๐Ÿ“ Project Structure

mahjong-assistant/
โ”œโ”€โ”€ manifest.json                   # Chrome extension manifest (MV3)
โ”œโ”€โ”€ popup.html                      # Extension popup (toolbar icon)
โ”œโ”€โ”€ mjs-assistant.user.js           # Tampermonkey userscript alternative
โ”œโ”€โ”€ icons/
โ”‚   โ”œโ”€โ”€ icon16.png
โ”‚   โ”œโ”€โ”€ icon48.png
โ”‚   โ””โ”€โ”€ icon128.png
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ main.js                     # Entry point โ€” wires all modules together
    โ”œโ”€โ”€ tile-detector.js            # Reads live game state from JS objects
    โ”œโ”€โ”€ utils/
    โ”‚   โ”œโ”€โ”€ constants.js            # Tile codes and lookup tables
    โ”‚   โ””โ”€โ”€ tile-utils.js           # Tile manipulation helpers
    โ”œโ”€โ”€ analysis/
    โ”‚   โ”œโ”€โ”€ shanten.js              # Shanten number calculation (regular/chiitoi/kokushi)
    โ”‚   โ”œโ”€โ”€ ukeire.js               # Outs calculation and discard ranking
    โ”‚   โ”œโ”€โ”€ hand-analyzer.js        # Strategy engine โ€” value weighting, defence integration
    โ”‚   โ””โ”€โ”€ defense.js              # Danger reading โ€” genbutsu, suji, furiten, riichi detection
    โ”œโ”€โ”€ overlay/
    โ”‚   โ”œโ”€โ”€ overlay-ui.js           # Floating HUD โ€” rendering and event handling
    โ”‚   โ””โ”€โ”€ overlay.css             # Brazed dark theme styles
    โ””โ”€โ”€ autoplayer/
        โ””โ”€โ”€ autoplayer.js           # Autopilot โ€” action sequencing and humanisation

๐Ÿง  How the Strategy Engine Works

Shanten (shanten.js)

Calculates how many tiles you need to reach tenpai (shanten = -1 means tenpai). Covers all three hand types: regular (4 sets + pair), Chiitoitsu (7 pairs), and Kokushi.

Ukeire (ukeire.js)

For each possible discard, counts how many tiles in the remaining wall would improve your hand. Higher outs = more chances to improve.

Value Weighting (hand-analyzer.js)

Multiplies outs by hand value potential so the engine doesn't sacrifice a 4-han Honitsu path for 2 extra outs toward a 1-han hand. Detects: Tanyao, Pinfu, Honitsu, Chinitsu, Chiitoitsu, dragons, winds, riichi potential.

Danger Reading (defense.js)

  • Reads each opponent's during_liqi flag live
  • Genbutsu โ€” tiles in a riichi player's discard pile score 100 (always safe)
  • Suji โ€” if they discarded 4, tiles 1 and 7 score higher (partial safety inference)
  • Defence mode โ€” triggered when opponent riichi detected and you're 2+ shanten away
  • Won't call Pon/Chi during active opponent riichi

๐Ÿ”ง Troubleshooting

Problem Solution
Overlay not appearing Check chrome://extensions/ โ€” extension must be enabled
Hand not detected Run in console: MJSDetector.stopPolling(); MJSDetector.startPolling();
Autopilot not discarding Run MJS.debugOp() and MJS.debugState() in console to see what state is detected
Analysis shows wrong info Run MJS.getState() to see what tiles were detected
Extension stopped after browser update Reload it at chrome://extensions/ โ†’ click the reload icon

๐Ÿ“œ Credits

AlphaJong by Jimboom7 https://github.com/Jimboom7/AlphaJong

The confirmed game API call patterns used in this project (inputOperation, inputChiPengGang, NetAgent.sendReq2MJ) and the approach to oplist-based turn detection were researched with significant reference to AlphaJong's source code. AlphaJong is an open source Mahjong Soul coder! Thank you for the help.


โš–๏ธ Disclaimer

This project is released for educational and research purposes only.

The autopilot feature interacts with Mahjong Soul's game client in ways that explicitly violate the Terms of Service. Automated gameplay is prohibited. Using it risks a permanent account ban. The authors take zero responsibility for any consequences including but not limited to account suspension, bans, or data loss.

The analysis overlay used manually is a grey area โ€” you are still responsible for how you use it.

No warranty is provided. Use entirely at your own risk.


๐Ÿ“„ License

MIT

Releases

No releases published

Packages

 
 
 

Contributors