Giter VIP home page Giter VIP logo

blackjack's Introduction

Blackjack

Blackjack hand

Simulating a variation of Blackjack (no splits or doubles), in Java. The player is "Sam".

Gradle is required. Tested with OpenJDK 11 on Arch Linux.

Build

gradle build -x test

Run tests

gradle test

Run

gradle run

Run with a random deck and verbose output

gradle run --args=-v

Run with cards.txt and don't shuffle the cards

gradle run --args='-n cards.txt'

Build a jar file

gradle jar

Run the jar file with verbose output enabled

java -jar build/libs/blackjack-1.0.0.jar -v

Run with cards.txt and don't shuffle the cards

java -jar build/libs/blackjack-1.0.0.jar -n cards.txt

Generate HTML documentation and open it with xdg-open

gradle javadoc && xdg-open build/docs/javadoc/index-all.html

Test the "always stay" strategy

java -jar build/libs/blackjack-1.0.0.jar -t -s

This strategy doesn't perform too well. Sam wins around 38% of the rounds.

Test the "basic optimized" strategy

java -jar build/libs/blackjack-1.0.0.jar -t -b

This strategy performs better. Sam wins around 76% of the rounds.

Command line help text

Usage: blackjack [ flags ] FILE

The BasicOptimized strategy is used by default for Sam.

Flags:
-b | --basicopt       Use the BasicOptimized strategy for Sam. (default)
-2 | --second         Use the SecondOptimized strategy for Sam.
-3 | --third          Use the Third strategy for Sam.
-a | --always-hit     Use a strategy where Sam always hits.
-s | --always-stay    Use a strategy where Sam always stays.
-t | --test           Quickly test the current strategy.
-n | --noshuffle      Don't shuffle the cards.
-o | --optimize       Optimize the parameters of the chosen strategy.
-r | --random         Randomize parameters when optimizing them.
-h | --help           Output this help.
-v | --verbose        Output detailed information about the games.
--version             Output the current version number.

General info

  • Version: 1.0.0
  • License: BSD-3

The Blackjack image is from WikiMedia and is licensed under a Creative Commons license.

blackjack's People

Contributors

xyproto avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.