Skip to content

AOrcilla/Mahjong-Scorer-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mahjong Scorer

A comprehensive web application that analyzes mahjong hands and provides detailed scoring based on Japanese mahjong rules. Input your tiles manually and get instant analysis of yaku patterns, hand validation, and scoring results.

Features

  • Text-Based Input: Enter mahjong tiles manually using a simple format
  • Quick Input Buttons: Click buttons for individual tiles (1m, 2m, 3m, etc.)
  • Example Hands: Pre-built examples of winning hands to test the system
  • Comprehensive Yaku Detection: Recognizes 20+ different scoring patterns
  • Proper Hand Validation: Ensures hands meet mahjong requirements (4 sets + 1 pair)
  • Detailed Scoring: Shows total han, individual yaku, and point values
  • Modern UI: Clean, responsive design that works on both desktop and mobile
  • Instant Results: No server required - all processing happens in the browser

Project Structure

Mahjong-Scorer-/
├── index.html          # Main HTML page with input interface
├── styles.css          # Modern styling with responsive design
├── script.js           # Comprehensive mahjong logic and scoring
└── README.md           # This file

Getting Started

Frontend (JavaScript)

  1. Open the HTML file in a modern web browser
  2. Enter your tiles manually or use the quick input buttons
  3. Click example buttons to see pre-built winning hands
  4. Click "Analyze & Score Hand" to get detailed results
  5. View scoring breakdown including yaku patterns and total han

Tile Format

Basic Tiles

  • Numbers + Suit: 1m (1 of man), 5p (5 of pin), 3s (3 of sou)
  • Winds: E (East), S (South), W (West), N (North)
  • Dragons: rd (red dragon), wd (white dragon), gd (green dragon)

Example Hands

  • Seven Pairs: 1m 1m 2m 2m 3m 3m 4m 4m 5m 5m 6m 6m 7m 7m
  • Thirteen Orphans: 1m 9m 1p 9p 1s 9s E S W N rd wd gd 1m
  • Standard Hand: 1m 2m 3m 4m 5m 6m 7m 8m 9m 1p 2p 3p 4p 5p

Yaku Patterns Detected

Yakuman (Limit Hands - 32,000 points)

  • Thirteen Orphans (Kokushi Musou)
  • Four Concealed Triplets (Suuankou)
  • Big Four Winds (Daisuushii)
  • Big Three Dragons (Daisangen)
  • All Green (Ryuuiisou)
  • All Terminals (Chuurenpoutou)
  • Nine Gates (Chuurenpoutou)

High-Scoring Hands (3,200+ points)

  • Little Four Winds (Shousuushii)
  • Little Three Dragons (Shousangen)
  • Seven Pairs (Chiitoi)
  • All Honors (Tsuuiisou)
  • All Terminals (Chinroutou)

Standard Hand Yaku (1-6 han)

  • Tanyao (All Simples) - 1 han
  • Yakuhai (Honor Tiles) - 1 han
  • Pinfu (All Sequences) - 1 han
  • Iipeikou (Identical Sequences) - 1 han
  • Chanta (Terminal or Honor in Each Set) - 1 han
  • Sanshoku Doujun (Three Color Straight) - 1 han
  • Ittsu (Straight) - 1 han
  • Toitoi (All Triplets) - 2 han
  • Sanankou (Three Concealed Triplets) - 2 han
  • Sanshoku Doukou (Three Color Triplets) - 2 han
  • Honitsu (Half Flush) - 3 han
  • Chinitsu (Flush) - 6 han

Technical Details

Frontend Technologies

  • HTML5: Semantic markup with intuitive input interface
  • CSS3: Modern styling with gradients, animations, and responsive design
  • JavaScript ES6+: Class-based architecture with comprehensive mahjong logic
  • Web APIs: Local processing with no external dependencies

Hand Validation Logic

  • Structure Check: Validates 4 sets + 1 pair formation
  • Set Recognition: Identifies triplets and sequences
  • Yaku Detection: Scans for scoring patterns
  • Scoring Calculation: Converts han to points using standard mahjong rules

Usage Flow

  1. Input Tiles: Type tiles manually or use quick input buttons
  2. Load Examples: Click example buttons to see winning hand patterns
  3. Analysis: Click "Analyze & Score Hand" for instant results
  4. Results: View detailed breakdown of yaku, han, and scoring
  5. Feedback: Get specific guidance on non-winning hands

Current Status

✅ Implemented

  • Comprehensive tile input system with quick buttons
  • 20+ yaku pattern detection
  • Proper hand structure validation (4 sets + 1 pair)
  • Accurate scoring based on Japanese mahjong rules
  • Example hands for testing and learning
  • Beautiful, responsive UI design
  • Instant analysis and scoring results
  • Detailed feedback for non-winning hands

📋 Next Steps

  • Add more advanced yaku patterns
  • Implement dora (bonus tile) detection
  • Add hand history and statistics
  • Improve sequence detection algorithms
  • Add multiplayer scoring comparison

Hand Validation Rules

Winning Hand Requirements

  1. Valid Structure: Exactly 4 sets + 1 pair, OR special patterns
  2. Valid Sets: Each set must be either:
    • Triplet: 3 identical tiles (e.g., 1m 1m 1m)
    • Sequence: 3 consecutive numbers of same suit (e.g., 1m 2m 3m)
  3. Valid Pair: 2 identical tiles
  4. Yaku Required: Must contain at least one scoring pattern

Non-Winning Hand Types

  • Invalid Hand Structure: Tiles can't form 4 sets + 1 pair
  • Valid Hand (No Yaku): Correct structure but no scoring patterns

Browser Compatibility

  • Chrome/Edge: Full support
  • Firefox: Full support
  • Safari: Full support (iOS 11+)
  • Mobile Browsers: Responsive design with touch-friendly controls

Development Notes

  • Frontend-only application: No backend server required
  • Local processing: All analysis happens in the browser
  • No external dependencies: Works completely offline
  • Real mahjong rules: Based on Japanese mahjong scoring system

Troubleshooting

Input Issues

  • Ensure you have exactly 14 tiles
  • Use correct tile format (e.g., 1m, not 1 or 1M)
  • Check that tiles can form valid sets and pairs

General Issues

  • Make sure you're using a modern browser
  • Check that JavaScript is enabled
  • Try the example hands to verify the system is working

Happy Mahjong Scoring! Test your hands and discover all the yaku patterns!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors