Coder Social home page Coder Social logo

blackjack's Introduction

Blackjack

GoDoc License

A console application which simulates a blackjack game.

Install

You can download application from the releases page.

Install directly from the terminal.

curl -L https://github.com/rwx-yxu/blackjack/releases/latest/download/blackjack-linux-amd64 -o ~/.local/bin/blackjack
curl -L https://github.com/rwx-yxu/blackjack/releases/latest/download/blackjack-darwin-amd64 -o ~/.local/bin/blackjack
curl -L https://github.com/rwx-yxu/blackjack/releases/latest/download/blackjack-darwin-arm64 -o ~/.local/bin/blackjack
curl -L https://github.com/rwx-yxu/blackjack/releases/latest/download/blackjack-windows-amd64 -o ~/.local/bin/blackjack

Or with go:

go install github.com/rwx-yxu/blackjack/cmd/blackjack@latest

blackjack's People

Contributors

rwx-yxu avatar

Watchers

 avatar

blackjack's Issues

Split Card into its own package

Opening issue to split the card file into its own package. It currently sits in the blackjack package but the variable names in the file are stuff like CardName.

If it were to be in its own package, the CardName type will be card.Name which is more idiomatic go. Card struct could be renamed to or Self like "card.Self" rather than "card.Card"

Spec/Design

Opening issue to track the specifications and design for a command line blackjack simulator written in Go.

Blackjack is a card game that allows for the player to draw 2 cards from a shuffled deck. The player may draw cards one at a time to get as close or match 21.

Win state:
Sum of cards total 21.

Lose state:
Sum of cards are above 21.

The simple work flow will be as follows:

  • Shuffle deck and cut.
  • Deal 2 cards to player
  • Evaluate total
    • If total 21, player wins.
    • If total less than 21, present player with option to draw more cards one at a time.
    • Check each draw for sum to ensure that total does not exceed 21. Once total exceeds 21, end game.
    • Total will be evaluated once player decides to stand with current cards

Should port to a Bonzai branch

Would be nice to port this over to a Bonzai branch so it can be included in other Bonzai monoliths easily. With Bonzai, I can write up a man page as well have auto complete.

Blackjack condition

The blackjack condition is achieved if there is a combination of Ace and a royal card(jack, queen and king) to score 21.

Currently, when they are drawn, the score is 20 because the default value of Ace is 10 and the royal cards are 10 which added together are 21.

I think a way around this would be to add a blackjack check after the initial draw phase to check the score and adjust?
Another way would be to evaluate the cards when drawn and adjust the value of Ace. Problem is, I wont know which order the cards are drawn first.

Repeat Games

Opening issue to track repeatable games by asking the user if they would like to play again after lose or win.

Dealer and player

Opening issue to document dealer and player structs.

The dealer is the user that is handling out the cards from the deck and getting a new deck once the current playing deck is empty.

Some rough ideas for both structs

type Dealer struct{
  d Deck
  score int
}

type Player struct{
  score int
}

Will need to create a draw method for the deck struct first. Go doesn't have a convenience method for pop so I'll need to make one with the built in append method.

README document

Create a readme document at root of repo to play the game. I am thinking of making a github release with different arch builds so that users can use curl to install the program as a single binary using Robs build tool https://github.com/rwxrob/good.

For now, I can point the install steps using go install.

Test Cases

Starting to create test cases for the game.
Current ones done:

  • Test that the generated deck card count is 52

Ones to do:

  • Test blackjack score with different combination of cards.

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.