Skip to content

rbcalc

Best Bridge Handrbcalc

We have recently been working on a online Bridge game for a client, running on a Ruby + JS + Redis + Websockets stack.

Leonardo Bridge is now about to go live, and during the development process we created a few libraries that we feel are generic enough to share with the community. rbcalc is the first such library. It consists of Ruby bindings for Piotr Beling’s Bridge Calculator.

While we did not end up using this in production, it may still be useful for Bridge fiends out there.

Usage

# gem install rbcalc first yo.
# Create an instance with four hands, a trump suit and the board leader.
rbc = Rbcalc.new(hands: 'S2579H38AD458QC26,S4H24569TJQKD9CJK,S36TQH7D23TKC379Q,SAKJ8HDAJ76CAT854', trump_suit: 2, leader: 0)
# play a couple of cards
rbc.exec('3S AS')
rbc.played_count # => 2
rbc.cards_left # => 50
# how many tricks is the current direction getting?
rbc.tricks_to_take # => 12
# which direction is playing next?
rbc.now_playing # => 1

More details in the spec file.

Linkage

LICENSE:

Copyright © 2014 Achillefs Charmpilas, Humbucker Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.