Saturday, 23 May 2015

Developing a 4 player AI card game - Blackjack / Pontoon / 21

Assignment day one - 16/3/2015

The task for the next project is to develop a 4 player card game - Blackjack, Pontoon or 21. The emphasis for me as a games designer is to develop a script in game maker that will focus on randomly drawing cards from a deck for the players. The player must be able to see the cards on screen and choose whether to stick or twist - draw another card or keep what they have. There are a number of factors that I need to consider:

- Probability / Chance
- Mathematics
- The intelligence of the opposing players - varying intelligence
- A scripting system to mimic the rules of a card game
- Mouse over options for stick or twist


Other factors
- Artwork
- Setting
- Custom card decks
- Screen layout (the game is being designed for an Android phone)

A good place to start would be to look at the rules as I am unfamiliar with the card game:

Blackjack, also known as twenty-one, is the most widely played casino banking game in the world. Blackjack is a comparing card game between a player and dealer, meaning that players compete against the dealer but not against any other players. It is played with one or more decks of 52 cards. The object of the game is to beat the dealer, which can be done in a number of 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 an initial 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 his or her own ace as 1 point or 11 points. All other cards are counted as the numeric value shown on the card. After receiving their initial 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 highest 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".

(taken from http://en.wikipedia.org/wiki/Blackjack)


Each card is given a value, which is its face value. The picture cards Jack / Queen / King are all 10 points each and the ace is 1 or 11  (depending on variant of game rules you choose).

-----------------------------------------------------------------------------------------------------------------------
Probability

To begin with the basic laws of probability are as follows:
Coin - two sides
Say for example we toss a coin - there are two sides to a coin, meaning that there are two possible outcomes, heads or tails.

We say that the probability of the coin landing H is ½.

And the probability of the coin landing T is ½.Dice - six sides
When a single die is thrown, there are six possible outcomes: 1, 2, 3, 4, 5, 6.


The probability of any one of them is 1/6.
In general:
Probability of an event happening =

Number of ways it can happen
divided by
Total number of outcomes
Example: the chances of rolling a "4" with a dieNumber of ways it can happen: 1 (there is only 1 face with a "4" on it)Total number of outcomes: 6 (there are 6 faces altogether)
So the probability =  1
6


Example: there are 5 marbles in a bag. 1 is red, 4 are blue
What is the probability that a blue marble gets picked?

So the probability =  4  = 0.8
5

Number of ways it can happen: 4 (there are 4 blues)Total number of outcomes: 5 (there are 5 marbles in total)




The Probability Line
The probability line can be used to show how likely an event is to happen, However our estimation is not a certainty - it is just a guide. If we were toss a coin 100 times to try and get heads, we could probably estimate that we would get 50 times heads - each side, heads or tails has an equal chance of appearing. However in practice we would probably get heads around 50 times, say 48 or 55.

We can apply certain terminology to help us:
 
Experiment or trial: An action where the result is uncertain
Sample space: All the possible outcomes of an experiment
Sample point: Just one of the possible outcomes
Event: The result of our test or experiment.

In terms of applying these to my games project, a blackjack card game, we can use the following definitions:

A sample space - All 52 cards in a deck
A sample point - The 5 of clubs is a sample point. The King of Clubs is not, as there are 4 different Kings that are 4 different sample points.
Event - Choosing a King from a deck of cards, any King at all, is an event.



Example: the chances of picking any one number card from a set suitNumber of ways it can happen: 1 (there is only 1 card with a designated number / suit value on it)Total number of outcomes: 52 (there are 52 cards altogether)


So the probability =  A 1 in 52 chance of drawing the card


Example: the chances of picking a king
Number of ways it can happen: 4 (there are actually four cards which are King cards)Total number of outcomes: 52 (there are 52 cards altogether)

So the probability =  A 4 in 52 chance of drawing the card



----------------------------------------------------------------------------------------------------------------------
Rules Of Blackjack


http://www.bicyclecards.com/card-games/rule/blackjack
I found this article online which explains Blackjack rules in quite a simple manner.

As far as I can tell, this is how the game should work in terms of what I am aiming to create:


1) The dealer deals a card to each player, going clockwise.
2) The dealer deals himself one card which is face up.

3) The dealer deals a second card to each player.
4) The dealer deals himself a second card which is face down.
-----------------------------------------------------------------------------------------------------------------------
A second idea may be to make 52 objects in game maker and give each a variable value along with graphics. This would be easier to track in terms of card values, but possibly more difficult to randomize. Nonetheless, I recall in my last project that a list of objects could be randomized and displayed on screen. Possibly the two methods could be fused together?

Objects can also have animations applied to them - this will help bring the deck to life on screen: card back, card flip, etc.

I will begin by making a list of  52 cards. to work with in game maker.

I have initially used graphics found online to get started. I will replace these with my own graphics later on.


-----------------------------------------------------------------------------------------------------------------------


Assignment day two - 18/3/2015

The basic strategy for winning at Blackjack

Winning tactics in Blackjack require that the player play each hand in the optimum way, and such strategy always takes into account what the dealer's up card is.

When the dealer's up card is a good one, a 7, 8, 9, 10-card, or ace for example, the player should not stop drawing until a total of 17 or more is reached.

When the dealer's up card is a poor one, 4, 5, or 6, the player should stop drawing as soon as he gets a total of 12 or higher.

The strategy here is never to take a card if there is any chance of going bust. The desire with this poor holding is to let the dealer hit and hopefully go over 21.

Finally, when the dealer's up card is a fair one, 2 or 3, the player should stop with a total of 13 or higher.







Why is this exactly?

Let's look again:


If the dealer's card is a 
 good one, a 7, 8, 9, 10-card, or ace for example, we have to assume that the card face down is a good one that will take them to a maximum of 21 (10 here is the best card).

If the face up card is a 7, 8, 9 or 10 it is probably a good idea to assume that the face down card is an 11. This is the worst case scenario, so any scenario outside of that is a bonus. So with that in mind, each eventuality is as follows: 



Face up card
Face down card
Total
7
11
18
8
11
19
9
11
20
10
11
21

This is why the player should keep drawing until a total of 17 or more is reached, to at least compete with or beat the dealers hand. You can see from the table above that working to the logic that the face down card is 11, the minimum total for the player to beat is 18. That is why the player must reach 17 or more.



Now let's look at a poor hand:

When the dealer's up card is a poor one, 2, 3, 4, 5, or 6, the player should stop drawing as soon as he gets a total of 12 or higher.




Face up card
Face down card
Total
2
11
13
3
11
14
4
11
15
5
11
16
6
11
17



If the face up card is a 2, 3, 4, 5, or 6 it is probably a good idea to assume that the face down card is an 11. These are quite poor cards, so the player must keep drawing until they have reached a total of 12 or higher. This will guarantee that the player equals or exceeds the total of the dealers hand.

This in itself should determine when and why a player sticks or twists.



Assignment day three - 23/3/2015
With a soft hand, the general strategy is to keep hitting until a total of at least 18 is reached.
Thus, with a an ace and a six (7 or 17), the player would not stop at 17, but would hit.

The basic strategy for doubling down is as follows: With a total of 11, the player should always double down. With a total of 10, he should double down unless the dealer shows a ten-card or an ace. With a total of 9, he should double down only if the dealer's card is fair or poor (2 through 6).

For splitting, the player should always split a pair of aces or 8s; identical ten-cards should not be split, and neither should a pair of 5s, since two 5s are a total of 10, which can be used more effectively in doubling down. A pair of 4s should not be split either, as a total of 8 is a good number to draw to. Generally, 2s, 3s, or 7s can be split unless the dealer has an 8, 9, ten-card, or ace. Finally, 6s should not be split unless the dealer's card is poor (2 through 6).

No comments:

Post a comment