Skip to content

Commit

Permalink
finished cli with probability function + updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
eRaMvn committed Dec 19, 2021
1 parent 03353fa commit 3130841
Show file tree
Hide file tree
Showing 9 changed files with 828 additions and 223 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Continuous integration

on:
push:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: "${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: "${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: "${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: "${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish

on:
push:
branches:
- master

jobs:
publish:
name: Publish for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: poker_prob
asset_name: poker-prob-linux-amd64
- os: windows-latest
artifact_name: poker_prob.exe
asset_name: poker-prob-windows-amd64
- os: macos-latest
artifact_name: poker_prob
asset_name: poker-prob-macos-amd64

steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --release
- name: Set outputs
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.RELEASE_TOKEN }}
file: target/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ steps.vars.outputs.sha_short }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Cargo.lock
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
*.pdb
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "3.0.0-beta.5"
rs_poker = "2.0.0-alpha.1"
clap = { version = "3.0.0-rc.7", features = ["derive"] }
rs_poker = "2.0.0-alpha.1"
colored = "2"
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# `poker_prob`

Program to calculate the probabilities of winning hands in rust. This is a work in progress as part of my process to learn rust
Program to calculate the probabilities of winning hands in rust based on rule of 4 and 2

## Sample command
cargo run poker_prob -- --ch As10s -n 4 -f 2h5c6d
## Sample commands

### Help command

`poker_prob.exe -h`

Output:

```/bin/bash
poker_prob.exe [OPTIONS] --mh <STRING> --ch <STRING>
OPTIONS:
-a Set whether this is all in or not
--ch <STRING> Set community cards
-h, --help Print help information
--mh <STRING> Set my hand
-V, --version Print version information
```

### Calculate probabilities

`poker_prob.exe --ch Ad3h --mh 4h3c5c6h -a`

Output:

```/bin/bash
Straight has the probability of 8%
Two Pair has the probability of 6%
One Pair has the probability of 0%
Three Of A Kind has the probability of 4%
Flush has the probability of 20%
Full House has the probability of 10%
```
Binary file added drawing-hands-outs.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3130841

Please sign in to comment.