• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

ChrisZieba/blackjack: A small game engine for casino blackjack and a library for ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ChrisZieba/blackjack

开源软件地址:

https://github.com/ChrisZieba/blackjack

开源编程语言:

JavaScript 100.0%

开源软件介绍:

#blackjack

Build Status

A small game engine for blackjack, and a library for calculating hand probabilities.

The game engine is still very basic and needs a lot of functionality added. Its use is to create the needed scenarios for calculating hand probabilities. To see an example of hand probabilities being calculated please see here. There is also an example source file that can be found in the examples directory.

##Usage

You can use the game engine and probability library separately or together.

var game = new Blackjack.Game('player1', 'house', {
	numberOfDecks: 1
});

// Start a new game
game.deal();

var shoe = game.getShoe();
var dealerCards = game.getDealer().getCards();
var playerCards = game.getPlayer().getCards();			

// Calculate probabilities for standing, hitting, and doubling down
var stand = Blackjack.Probability.stand(shoe, dealerCards, playerCards, 3);
var hit = Blackjack.Probability.hit(shoe, dealerCards, playerCards, 3);
var double = Blackjack.Probability.double(shoe, dealerCards, playerCards, 3);

##Options

  • numberOfDecks {Integer}
    • The number of decks in a shoe. The standard in most casinos is between 4 and 8.
  • dealerHitSoft17 {Boolean}
    • If true the dealer will hit on soft 17, otherwise the dealer will continue to draw cards.

##Methods

The following are all the public methods exposed through the Game, Player, and Probability API.

####Game

  • getDealer()
    • Returns the dealer object.
  • getPlayer()
    • Returns the player object. Only one player in a game supported right now.
  • getTurn()
    • Returns the player or dealer, depending on which turn is set.
  • setTurn(player)
    • Takes a player object and sets that player or dealer as the active turn.
  • getShoe()
    • Returns an array of all card objects in the shoe.
  • deal()
    • Handles the game setup, i.e., card shuffling, turn setting, etc.

####Player

  • getCards()
    • Returns an array of the players cards.
  • canSplit()
    • True if the player can split their cards, false otherwise.
  • canDouble()
    • True if the player can double down, false otherwise.
  • getActions()
    • Returns an array of all the actions available to the player.

####Probabilities

The dealerCards and playerCards can be retrieved using game.getPlayer().getCards(). The maxPullCount is used to limit the number of times the recursive function is called. A number between 3 and 5 will return a reasonably accurate result while still being fast.

  • stand(shoe, dealerCards, playerCards, maxPullCount)
  • hit(shoe, dealerCards, playerCards, maxPullCount)
  • double(shoe, dealerCards, playerCards, maxPullCount)

##Development

There are many features for the game engine that need to be added and/or worked on:

  • Add splitting to the probability library
  • Handle player and dealer chip amounts
  • Support for more than one player to a game

There are many options that need to be supported in the game constructor:

  • playerResplitAces
  • player5Card21
  • playerSurrender

####Local

To build blackjack please run:

grunt

The combined minified file will appear in the dist folder.

##License

MIT license.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
scellecs/morpeh: 发布时间:2022-06-07
下一篇:
xiyoo0812/quanta: A Game Server Engine based on Lua!发布时间:2022-06-07
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap