Skip to content

A Poker: Texas Holdem cli game built with Scala 3 and ❤️

License

Notifications You must be signed in to change notification settings

Robert-Nickel/scala-texas-holdem

Repository files navigation

Poker: Texas Holdem CLI game - built with Scala 3

Build Status Coverage Status

The coverage relates to the Scala 2 version of the project

Overview

A CLI version of Texas Holdem using Scala 3 for the course "Reactive Programming" at HTWG WS20/21.

Table of contents

  1. Functional
    1. How to play
      1. Starting the Game
      2. Playing the Game
    2. Bot logic
      1. Preflop
      2. Postflop
    3. Yet missing Features
  2. Technological

Functional

All typical cash game rules are covered.

How to play

Starting the Game

You can play poker with one of two card deck. One has symbols on the cards (♥,♦,♣,♠), and one has letters (h,d,c,s).

To play with the symbols run

sbt "run symbols"

to play with letters run

sbt "run letters"

HINT: h = hearts = ♥, d = diamonds = ♦, c = clubs = ♣, s = spades = ♠
The symbols are unicode characters that cannot be rendered by every console, use letters if you encounter rendering issues.

Playing the Game

You can use these commands if it is your turn:

fold
check
call
raise 42
all-in

Here is an example of how it looks if you call. Look at your current bet (that 6 above the betting line) to understand what is going on.

                                          Pot 0
                                            
                                                                                ⬇️
0               1               2               2               6               0               
________________________________________________________________________________________
[xx][xx]        [xx][xx]        [xx][xx]        [xx][xx]        [xx][xx]        [7♦][8♦]        
Amy (D)         Bob             Dev             Fox             Udo             You             
200             199             198             198             194             200             
                                                                                ________

call


                                          Pot 0
                                            
                                                                                ⬇️
0               1               2               2               6               6               
________________________________________________________________________________________
[xx][xx]        [xx][xx]        [xx][xx]        [xx][xx]        [xx][xx]        [7♦][8♦]        
Amy (D)         Bob             Dev             Fox             Udo             You             
200             199             198             198             194             194             
________

Here you have called Udo's bet of 6 with [7♦][8♦].

If you ever get confused on what happened, have a look into what_happened.txt, where you can analyse your current match in detail.

Bot logic

You are playing against our bots Amy, Bob, Dev, Fox and Udo that make their actions based on multiple parameters.

Preflop

The bot evaluates his hand by

  • If the values are high
  • If the values are close to each other, which increases the chances to get a straight (cards are "connectors")
  • If the values have the same symbol (cards are "suited") If the evaluation of the hole cards is
  • good, the bot will play aggressively
  • mediocre, the bot will play passively
  • bad, the bot is likely to fold

Postflop

After the flop, the bot evaluates his own hand in combination with the board. This is a more complex process, since the evaluation is multidimensional:

  • The bot might have nothing
  • The bot might have something, e.g. a pair
  • The bot might have nothing yet, but a relatively high chance to get a flush or a straight (a "draw")

All that is taken into consideration.
One thing that is not taken into consideration is a differentiation between the absolute and the relative hand value. If the board is a flush and the bot has no card of that suit, he will play aggressively, since he thinks he has a great hand, without taking into consideration, that EVERYONE has a flush.

Yet missing Features

  • Side pots, so that if two players with different stacks go all-in, they win different amounts. Reason: A player should not be able to win more than what he invested.

Technological

Many different aspects of the Scala Programming Language and surrounding libraries are covered, therefore some effort is put onto the technology rather than the game itself.

You can find the basics (Introduction to Scala, More Scala, Tests, Functional Style and Monads) everywhere around the code. The more specific aspects and technologies are linked below:

Internal DSLs

External DSLs

Actors

Reactive Streams

Kafka

Spark

Scala 3

To evaluate hands, we borrowed the solution from the TwoPlusTwo hand ranks evaluator as described here. To get the implementation of the evaluation done, we looked here, here and here.

About

A Poker: Texas Holdem cli game built with Scala 3 and ❤️

Topics

Resources

License

Stars

Watchers

Forks

Languages