wk5.0 (almost half-way!)

Stuff that's due this week

1. Your project proposal

  • Approach your project from a technical perspective; what part of the stack do you want to know more about?
  • Focus on one basic thing that you want to go really deep into.
  • For everything else, it's okay to use libraries.

2. Your individual assignment: Blackjack!

Blackjack is a comparing card game between a player and dealer, meaning players compete against the dealer but not against other players. It is played with one or more decks of 52 cards. The object of the game is to beat the dealer in one of the following ways:

  • Get 21 points on the player's first two cards (called a blackjack), without a dealer blackjack;
  • Reach a final score higher than the dealer without exceeding 21; or
  • Let the dealer draw additional cards until his or her hand exceeds 21.

The player or players are dealt a two-card hand and add together the value of their cards. Face cards (kings, queens, and jacks) are counted as ten points. A player and the dealer can count an ace as 1 point or 11 points. All other cards are counted as the numeric value shown on the card. After receiving their first two cards, players have the option of getting a "hit", or taking an additional card. In a given round, the player or the dealer wins by having a score of 21 or by having the higher score that is less than 21. Scoring higher than 21 (called "busting" or "going bust") results in a loss. A player may win by having any final score equal to or less than 21 if the dealer busts. If a player holds an ace valued as 11, the hand is called "soft", meaning that the player cannot go bust by taking an additional card; 11 plus the value of any other card will always be less than or equal to 21. Otherwise, the hand is "hard".

Requirements

Create a repo called Blackjack on your github account that contains a python implementation of blackjack.

OOP

  • Implement blackjack using classes. Your code should at least implement a deck object that contains the following methods (non-exhaustive):
    • constructor: Creates a new deck of 52 cards in a standard order.
    • shuffle: Randomizes the order of the cards.
    • draw_card: Returns a single card from the top of the deck and removes the card from the deck.
    • cards_left: Returns the number of cards remaining in the deck.
    • sort: Sorts the cards back into standard order. Should be $O(nlog(n))$ (I suggest implementing merge sort).

Clean design

Test Driven Development

Wonderful documentation

Suggested approach

  • Create a Card class, which has a value (1, 2 ... 10) and a name (2, ... K, A)
    • Note: In blackjack, aces can be either one or eleven.
  • Create a Deck class, which is a list/tuple or other collection of Card with a shuffle function and a draw_card function.
  • Create a Hand class, which is also similar to the Deck class
  • Create a Player class, which basically has a Hand class object associated with it.
  • Create a Blackjack class which has the main game logic.

When are we going to work on our individual assignments!?

  • This week will be less lecture based to allow for individual project and capstone proposal time.
  • One of the goals of this week will be managing three projects at once (javascript, blackjack, and capstone proposal). Where you decide to spend your time is up to you (although I would suggest getting the easy stuff out of the way first).

Introducing Javascript

Based off Douglas Crockford's A Survey of the JavaScript Language

History

JavaScript was developed by Brendan Eich at Netscape as the in-page scripting language for Navigator 2. It is a remarkably expressive dynamic programming language. Because of its linkage to web browsers, it instantly became massively popular. It never got a trial period in which it could be corrected and polished based on actual use. The language is powerful and flawed.

Note that JavaScript has nothing to do with Java (it was initially called livescript). Some say that Netscape changed the name to JavaScript to capitalize on the popularity of Java.

Alerts

Basic syntax

Javascript

Lunchtime conference talk: Javascript: The good parts


In [ ]: