Coder Social home page Coder Social logo

poker-algorithm's Introduction

扑克游戏算法 for php

使用

1. 德州扑克

<?php
include __DIR__ . 'vendor/autoload.php';

$texas = new \Goodspb\PokerAlgorithm\Games\Texas();
//生成2个玩家的牌 和 公共牌
$texas->generate(2);
//输出玩家牌 和 公共牌
var_dump($texas->getPlayersCards(), $texas->getPublicCards());
//输出比较结果
echo "<pre>";
print_r($texas->comparePlayer($texas->getPlayersCards()[1], $texas->getPlayersCards()[2]));

2. 牛牛

<?php
include __DIR__ . 'vendor/autoload.php';

//创建实例
$niu = new \Goodspb\PokerAlgorithm\Games\NiuNiu();
//随机生成3位玩家, 2种方式二选一,但是如果手工填入的话,需要自己管理随机性和牌的唯一性
$niu->generate(3);
//手工填入2位玩家
//$niu->setPlayerCard(1, [[1, 4], [2, 4], [3, 4], [4, 4], [5, 2]]);
//$niu->setPlayerCard(2, [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]);

//执行计算
$result = $niu->execute();
$players = $niu->getPlayersCards();

//输出剩余的牌
//var_dump($niu->getRound());

//输出玩家牌
var_dump($players);

//输出结果
echo '<pre>';
print_r($result);

3. 三公

<?php
include __DIR__ . 'vendor/autoload.php';

//创建实例
$niu = new \Goodspb\PokerAlgorithm\Games\SanGong();
//随机生成3位玩家的牌
$niu->generate(3);

//执行计算
$result = $niu->execute();

//输出结果
echo '<pre>';
print_r($result);

问题

欢迎 issues 哦。

poker-algorithm's People

Contributors

goodspb 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.