Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Merge branch 'develop', 0.6 stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-bondar committed May 15, 2018
2 parents 74f72f0 + 6859627 commit 8237555
Show file tree
Hide file tree
Showing 101 changed files with 6,229 additions and 220 deletions.
123 changes: 86 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,66 @@
# Λambd'em Poker

## Description
Client for playing Texas Hold`em versus AI or human beings with some additional features, possibly. \
Full initial project description can be read [here](/docs/description.md).
Client for playing Texas Hold 'em versus AI or human beings with some additional features, possibly.

![layout](docs/images/layout.png)
*Feel uncomfortable if you don't know/remember game rules?* \
Be prepared, read 'em [all](docs/game%20rules.md) or tl; dr & look at pictures.

List of implemented features:
- table
- player seats
- dealing cards
- dealing board
## Features

![gameplay](docs/images/gameplay.gif)

### Layout

- table (with shadow! ~~It's important~~)
- player seats that display name & balance
- quasar deck layout (from One Site Which Must Not Be Named)
- chips layout (from the same source that deck)
- action buttons, small bet sizing buttons and slider (finally, original)

### UX

![slider](docs/images/slider.gif)

- slider to choose bet with big blind step
- small buttons to choose bet in % of current pot
- only possible actions are suggested for buttons
- fold is blocked when check is available

![highlight](docs/images/highlight.gif)

- active player is highlighted
- game results are showed when one player is left
- AI think time is 1s
- showdown is showed only for 2.44s, don't miss it!
- clicked action button is faded

### Logic

- dealing random cards and board
- posting blinds
- interactable slider
- change of positions
- bet % of pot buttons
- bet display in chips
- time delayed actions
- fade on button click
- bottom & up seatbolds
- detecting end of game
- automove on timebank end
- hightlighting of active player
- calculation of possible actions
- autoskip when no action is required
- handling bet rounds until showdown
- detecting winner(-s) and awarding them
- handling of bet rounds
- detecting & comparing of poker combinations
- *another not really cool stuff*
- detecting winner(-s) and awarding them

~~Link to huge haddocs here, although no one will really read them...~~
### AI

## Status

One phrase review: \
*Base version seemed to be done*
- 5 predefined play styles: telephone, passive, loose, tight and aggresive
- chooses move on pre-flop depending on hand range and size of incoming bet
- has probabilities of performing some move relying on chance and combination strength
- considerates random distribution for choosing bet size
- can use continuation bets up to triple barrel bluff on air

Release candidate for base version,
you can play to your heart content versus yourself,
although some bugs are sneaking nearby, probably.
## Status

Developing AI ...
Solid release candidate is made, although some bugs are sneaking nearby and deep inside you still think that some shizzle sugar stuff like move timer or highlighting of winner is critically essential.

![serious coding](/docs/images/serious%20coding.gif)
Play to your heart content versus AI or at least try winning all of them. Just remember, none of them ever pretends to be hazardous entity and still requires at least twice as much work as was done to be reborn in *Serious Strategy Unit* ©.

## Build and run

First of all - install [Stack](https://www.haskellstack.org).
First of all - install [Stack](https://www.haskellstack.org) tool.

Setup it on first launch:

Expand All @@ -56,13 +70,48 @@ For launching client:

`stack build && stack exec poker`

Use command line argument to explicitly set opponent play style:

`stack exec poker %playstylename%`

Available options:

- `telephone`
- `passive`
- `loose`
- `tight`
- `aggresive`
- `random`

When choosing `random` play style, one of previous 5 is chosen fortuitously. Also, it's default setting for missing, misspelled or multiply argument.

Disregard that, [Cabal](https://www.haskell.org/cabal/) is fine too.

```
cabal install --only-dependencies
cabal run %playstylename%
```

## Documentation

Initial project requirements document can be read [here](docs/description.md).
And for brave ones, feel free to look through haddock documentation, it's offline version is located in `docs/lambdem-poker-0.6`.

## Additional stuff

As part of project web based range selector is supplemented.

![](docs/images/range%20selector.png)

~~Wait, what?! That peasant front end?! In my cozy haskell project?!~~

## Testing

Added some hand templates to test detecting and comparing of combinations.
Although isn't pretending to be a good test coverage and still requires a human eye
to verify results.
Contains some hand templates to test detecting and comparing of combinations.
Isn't pretending to be a test coverage at all and still requires a human eye
to verify results. Consider it like sandboxed appendage for debugging purposes.

For launching tests:
For launching tests use:

`stack test`

Expand Down
5 changes: 2 additions & 3 deletions docs/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

## Описание

В данном задании предполагается реализация клиента для игры в покер. В зависимости от количества функционала
конечная реализация может иметь такой вид (по увеличению степени запущенности):
В данном задании предполагается реализация клиента для игры в покер. В зависимости от количества функционала конечная реализация может иметь такой вид (по увеличению степени запущенности):

<img src="/docs/images/HU.png" width="33%"><img src="/docs/images/6 max.png" width="33%"><img src="/docs/images/6 max with HUD.jpg" width="33%">
<img src="images/HU.png" width="33%"><img src="images/6 max.png" width="33%"><img src="images/6 max with HUD.jpg" width="33%">

## Минимальные требования (базовая часть)

Expand Down
66 changes: 66 additions & 0 deletions docs/game rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
*Beginner’s Guide to*

# Texas Hold’em

# ♥ ♣ ♦ ♠

## 1. Introduction, Pre-Flop Play

Texas Hold’em is a poker game that uses a round disc called a “button” to indicate the theoretical dealer of each hand. After each hand is
completed, as with standard poker rules, the button moves clockwise to the next active player. This player will be considered “the dealer” for
that hand.
Before any cards are dealt, the player to the immediate left of the button is required to place the “small blind” and the player to the immediate
left of the small blind is required to post the “big blind.” The purpose of the blinds is to stimulate action (i.e. betting) by creating a pot (the
more money in the pot, the more incentive there is for players to play the hand rather than fold). As a general rule, the small blind is usually
half the amount of the big blind, but occasionally it is two-thirds. The blinds were considered “live” bets and the players who posted them will
have the option of checking, calling, raising or folding when the bett ing returns to their position.
After the blinds have been posted, two “hole cards” (meaning they are face down) are dealt to each player. The player to the immediate left
of the big blind starts the betting for this round. This player will have the option of calling (putting out an amount equal to the previous bet,
which in this case is the amount of the big blind), raising (by increasing the bet by and amount at least equal to the previous bet or raise
amount), or folding (not putting an money into the pot, and relinquishing the player’s hole cards as well as any right to the pot). Betting
continues in a clock-wise direction, with each player acting in turn until all of the remaining players (i.e. those that have not folded) have
placed the same amount of money into the pot for that betting round.

## 2. The Flop

After the first round of betting is over, the “flop” (the first three of what will eventually be five community cards) is dealt. The community cards
are common to all the players participating in the hand-everyone can use any combination of the community cards and their own two hole
cards to make their best possible five-card hand (only five cards are used to determine a poker hand). After the flop and in each subsequent
betting round, the first player to the left of the button is first to act. This player can check or bet. All subsequent players will have the option
to check, bet, call or raise depending on the actions of player(s) acting before them. Once all remaining players have put the same amount
of money into the pot for this betting round, the betting round is complete.

## 3. The Turn

After the flop betting round is complete, a fourth community card (called the “turn”) is dealt. This is followed by another betting round which
proceeds in the same fashion as the betting round on the flop-betting begins with the first player to the left of the button and continues in a
clockwise direction until all remaining players have placed the same amount of money into the pot for this betting round.

## 4. The River (also known as “Fifth Street”) and Showdown

After the turn betting round is complete, a fifth and final community card (called the “river”) is dealt. This is followed by a final betting round
which proceeds in the same fashion as the betting rounds on the flop and the turn. At any time during the hand, if all players but one fold,
the hand is over and the remaining player takes the pot. However, after the betting round on the river is complete, if more than one player
remains, there is a showdown, in which the players turn over their cards (beginning with the player who made the last bet or raise, or, if no
player bet or raised on the final round, beginning to the left of the button). Whichever player has the best 5-card hand, using any
combination of the community cards and that player’s hole cards, wins the pot. If two or more players have hands of equal rank, then they
split the pot (more common than one would think).

## 5. Hand Rankings

<img src="images/hand ranking.jpg" width="50%">

The following is the ranking of poker hands, from best to worst. Note that all poker hands include exactly five cards:
- Straight Flush – five cards of the same suit and in consecutive rank (i.e. 4, 5, 6, 7, 8, all spades). The highest Straight flush
is called a Royal Straight Flush or simply a Royal Flush, and includes the Ten, Jack, Queen, King and Ace, all of the same
suit.
- Four of a Kind – fours cards of identical rank (i.e. 9, 9, 9, 9, 2).
- Full House – three cards of one rank, and a pair of a different rank (i.e. 8, 8, 8, 3, 3).
- Flush – five cards of the same suit (i.e. King, Ten, 9, 7, 5, all hearts).
- Straight – five cards of consecutive rank (i.e. 2, 3, 4, 5, 6). Note that Aces can be used to make the highest straight or the
lowest straight, but a straight can not “wrap around” from high to low (i.e. Q,K,A,2,3 is not a straight, but A,2,3,4,5 is a
straight).
- Three –of-a-Kind – three cards of the same rank with any two cards (i.e. 7, 7, 7, 9, 3).
- Two Pair – a pair of one rank and a pair of another rank (i.e. 6, 6, 4, 4, 7).
- Pair – two cards of the same rank (i.e. 9,9, Ace, Jack, 2).
- High Card – none of the above (i.e. Ace, Ten, 9, 7, 2, of more than one suite).
Binary file added docs/images/gameplay.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/hand ranking.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/highlight.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/layout.png
Binary file not shown.
Binary file added docs/images/range selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/serious coding.gif
Binary file not shown.
Binary file added docs/images/slider.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/lambdem-poker-0.6/Client.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Client</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Client.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">lambdem-poker-0.6: Poker client</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">Client</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Game launch related functions</a></li><li><a href="#g:2">Game maintance related functions</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Core module that handles all major game processes.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:launchGame">launchGame</a> :: <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:parsePlaystyle">parsePlaystyle</a> :: <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> [<a href="../base-4.10.1.0/Data-String.html#t:String">String</a>] -&gt; <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> <a href="Poker-AI-Types.html#t:PlayStyleType">PlayStyleType</a></li><li class="src short"><a href="#v:initTableScreen">initTableScreen</a> :: StdGen -&gt; <a href="Poker-AI-Types.html#t:PlayStyleType">PlayStyleType</a> -&gt; <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a></li><li class="src short"><a href="#v:createTableScreenWith">createTableScreenWith</a> :: StdGen -&gt; <a href="Poker-AI-Types.html#t:PlayStyleType">PlayStyleType</a> -&gt; <a href="Poker-Interface-Types.html#t:TableImages">TableImages</a> -&gt; <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a></li><li class="src short"><a href="#v:updateGame">updateGame</a> :: <a href="../base-4.10.1.0/Prelude.html#t:Float">Float</a> -&gt; <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a> -&gt; <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a></li></ul></div><div id="interface"><h1 id="g:1">Game launch related functions</h1><div class="top"><p class="src"><a id="v:launchGame" class="def">launchGame</a> :: <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> () <a href="src/Client.html#launchGame" class="link">Source</a> <a href="#v:launchGame" class="selflink">#</a></p><div class="doc"><p>Launch game screen.</p></div></div><div class="top"><p class="src"><a id="v:parsePlaystyle" class="def">parsePlaystyle</a> :: <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> [<a href="../base-4.10.1.0/Data-String.html#t:String">String</a>] -&gt; <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> <a href="Poker-AI-Types.html#t:PlayStyleType">PlayStyleType</a> <a href="src/Client.html#parsePlaystyle" class="link">Source</a> <a href="#v:parsePlaystyle" class="selflink">#</a></p><div class="doc"><p>Parse command line arguments.</p></div></div><div class="top"><p class="src"><a id="v:initTableScreen" class="def">initTableScreen</a> :: StdGen -&gt; <a href="Poker-AI-Types.html#t:PlayStyleType">PlayStyleType</a> -&gt; <a href="../base-4.10.1.0/System-IO.html#t:IO">IO</a> <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a> <a href="src/Client.html#initTableScreen" class="link">Source</a> <a href="#v:initTableScreen" class="selflink">#</a></p><div class="doc"><p>Initialization of table screen.
All images are loaded and all player data is set.</p></div></div><div class="top"><p class="src"><a id="v:createTableScreenWith" class="def">createTableScreenWith</a> :: StdGen -&gt; <a href="Poker-AI-Types.html#t:PlayStyleType">PlayStyleType</a> -&gt; <a href="Poker-Interface-Types.html#t:TableImages">TableImages</a> -&gt; <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a> <a href="src/Client.html#createTableScreenWith" class="link">Source</a> <a href="#v:createTableScreenWith" class="selflink">#</a></p><div class="doc"><p>Create new table screen made of images and set default parameters.</p></div></div><h1 id="g:2">Game maintance related functions</h1><div class="top"><p class="src"><a id="v:updateGame" class="def">updateGame</a> :: <a href="../base-4.10.1.0/Prelude.html#t:Float">Float</a> -&gt; <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a> -&gt; <a href="Poker-Interface-Types.html#t:TableScreen">TableScreen</a> <a href="src/Client.html#updateGame" class="link">Source</a> <a href="#v:updateGame" class="selflink">#</a></p><div class="doc"><p>Update game parameters depending on game state.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.18.1</p></div></body></html>
Loading

0 comments on commit 8237555

Please sign in to comment.