GithubHelp home page GithubHelp logo

charkecc / japanesemahjong Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibukisaar/japanesemahjong

0.0 0.0 0.0 847 KB

日本麻将的库,“求向听数”、“判断胡牌”、“牌面拆解”采用查表法。

C# 100.00%

japanesemahjong's Introduction

JapaneseMahjong

日本麻将的库,“求向听数”、“判断胡牌”、“牌面拆解”采用查表法。

原理:知乎文章

示例代码:

static void Main() {
    const int N = 50;

    Stopwatch sw = new Stopwatch();

    var game = Game.Instance;
    var tiles = new SortedTilesEnumerator(game.GetRandomTiles(14).Select(t => t.BaseTile));
    //var tiles = BaseTile.ParseSuffixExpr("1112345678999m1m");
    Console.WriteLine(string.Concat<BaseTile>(tiles));
    Console.WriteLine(BaseTile.ToSuffixExpr(tiles));
    Console.WriteLine();
    SuggestResult suggest = null;
    sw.Restart();
    for (int i = 0; i < N; i++) suggest = game.Suggest(tiles);
    sw.Stop();
    Console.WriteLine($"提供建议平均耗时:{TimeSpan.FromTicks(sw.Elapsed.Ticks / N)}");
    Console.WriteLine(suggest);
    Console.WriteLine(string.Join(Environment.NewLine, suggest.Values));
    Console.WriteLine();

    var tiles2 = game.GetTiles(tiles).ToArray();
    tiles2.Last().Owner = Wind.;
    if (game.TestRon(tiles2)) {
        var a = game.Analysis(tiles2);
        if (a != null) {
            Console.WriteLine(string.Join(Environment.NewLine, a));
            Console.WriteLine();
        }
        var score = game.GetScore(tiles2, null, YakuEnvironment.门前清 | YakuEnvironment.自摸);
        Console.WriteLine(score);
        Console.WriteLine(string.Join<YakuValue>(Environment.NewLine, score.YakuValues));
        Console.WriteLine();
    }
}

japanesemahjong's People

Contributors

ibukisaar avatar

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.