Main Program Repeat call InitialiseVar # a procedure to reset all variables call ShufflePack# a procedure to generate a random list of 52 cards call PlayerGo#

Slides:



Advertisements
Similar presentations
GAME:IT Junior Learning Game Maker: The Control Tab.
Advertisements

Microsoft® Small Basic
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
CSE 332: Lab 6 overview Overview of Lab 6 Your Lab 6 program will –Correct a glitch in the lab 5 specification Use exceptions only for abnormal flow control.
While Loops. Challenge: ● Ask the user a simple math questions ● Continue asking the question until the user gets it right.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Loops (Part 1) Computer Science Erwin High School Fall 2014.
12 Pontoon1May Pontoon program CE : Fundamental Programming Techniques.
Blackjack Programming Project
Rene Plowden Joseph Libby. Improving the profit margin by optimizing the win ratio through the use of various strategies and algorithmic computations.
Design Example. Requirements Make a program that simulates the game of blackjack For now, we ignore money/betting…. just simulate game play But… this.
James Tam Loops In Python In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
J. Michael Moore Other Control Structures CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
James Tam Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
James Tam Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
J. Michael Moore Other Control Structures CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
James Tam Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
ACSE th Conference The Iconic Programmer Stephen Chen.
Test Abstractions Intent Nat. Lang. Spec. HW Behavioral Tests can be described at different abstraction levels Tests can be defined top-down or bottom-up.
Bug Session Three. Session description In this session, pupils will discover how the Bug software makes drawing shapes easier (this is based on the use.
Adapted from slides by Marie desJardins
SPELLING GAME PROJECT SAMPLE ASSESSMENT MATERIAL GCSE Computing.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Reynolds 2006 Complexity1 Complexity Analysis Algorithm: –A sequence of computations that operates on some set of inputs and produces a result in a finite.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
First tutorial.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Computer Programming for Engineers. Outline Tic-Tac-Toe (O-X Game) Drawing 3x3 grid Receiving the inputs Checking for a winner Taking turns between.
By the end of this session you should be able to...
Bug Session Three. Session description In this session, pupils will discover how the Bug software makes drawing shapes easier (this is based on the use.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
30/10/ Iteration Loops Do While (condition is true) … Loop.
Scratch Programming Lesson 4 Question asking and answering.
Visual Basic Programming
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
Algorithms Writing instructions in the order they should execute.
ITI 1120 Lab #5 Contributors: S. Boyd, R. Plesa, A. Felty, D. Inkpen, A. Williams, D. Amyot.
Chapter 4: Elementary Number Theory and Methods of Proof 4.8 Application: Algorithms 1 Begin at the beginning…and go on till you come to the end: then.
Lec 21 More Fun with Arrays: For Loops. Agenda Some backfill for Lab 20: – Using an array in an applet or class – array instance variables – using Math.random()
Chapter 8: MuPAD Programming I Conditional Control and Loops MATLAB for Scientist and Engineers Using Symbolic Toolbox.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
Advanced Higher Computing Science Stacks Queues and linked lists.
Programming Fundamentals I Java Programming Spring 2009 Instructor: Xuan Tung Hoang TA: Tran Minh Trung Lab 03.
Random Numbers Random numbers are extremely useful: especially for games, and also for calculating experimental probabilities. Formula for generating random.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
CS 104 – Fall 2011 Exploring Computer Science Build Your Own Blocks September 19, 2011.
COM148X1 Interactive Programming Lecture 8. Topics Today Review.
Conditionals.
Computer Science Up Down Controls, Decisions and Random Numbers.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Output “Funds not available”
Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate the code. Repetition in Pascal:
While Loops in Python.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Coding Concepts (Basics)
Logical Operations In Matlab.
Console.WriteLine(“Good luck!”);
While Loops in Python.
BY: Cesar, Jennifer, Adrianne & Allen
Presentation transcript:

Main Program Repeat call InitialiseVar # a procedure to reset all variables call ShufflePack# a procedure to generate a random list of 52 cards call PlayerGo# a procedure to deal with the players go first call ComputerGo# a procedure to deal with the computers go call CheckResults# a procedure to check to see who has won REPEAT OUTPUT “Do you want to play again?” INPUT Choice UNTIL Choice = “Y” or “N” WHILE Choice = “Y”

InitialiseVar gPack = "ac", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "tc", "jc", "qc", "kc", "ad", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "td", "jd", "qd", "kd", "as", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "ts", "js", "qs", "ks", "ah", "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "th", "jh", "qh", "kh“ FOR 0 to 4 gPlayerHand(counter) = “” gComputerHand(counter) = “” END FOR FOR 0 to 51 gPlayPack(counter) = “” END FOR gPlayerScore = 0 gComputerScore = 0

ShufflePack Used(52) is an integer array Valid is a Boolean Index is an integer FOR 0 to 51 REPEAT valid = true INPUT Index randomly IF Used(Index) = TRUE then valid = false ELSE Used(Index) = TRUE ENDIF UNTIL Valid = true gPlayPack(counter) = gPack(Index) END FOR

PlayerGo #Draw the first two starting cards. Draw the first two starting cards (This can be done with a DrawCard Function) Display the cards drawn Work out the value of these cards (This can be done with a ReturnValue function) Display the value of these cards Repeat until player “Sticks” or is bust or scores a 5 card trick Ask if player wants to twist or stick Draw a new card if player “twists” (Using DrawCard) Work out new value of hand (Using ReturnValue) Check to see if you have bust (greater than 21) Work out the final score whether the player has bust or not

ComputerGo #Draw the first two starting cards. Draw the first two starting cards (This can be done with a DrawCard Function) Display the cards drawn Work out the value of these cards (This can be done with a ReturnValue function) Display the value of these cards Repeat until computer “Sticks” or is bust or scores a 5 card trick Computer will twist if cards are under a certain value (16) and not already 21 If twist - Draw a new card (DrawCard) Work out new value of hand (Using ReturnValue) Check to see if computer has bust (greater than 21) Work out the final score whether the player has bust or not

CheckResults Count number of cards each play has got. Display number of cards and total score for Player and the Computer Check to see who has won. OutcomePlayerComputerWho has won BustYes Draw BustYesNoComputer BustNoYesPlayer 21YesNoPlayer 21NoYesComputer 21Yes Computer 5 CardYesNoPlayer 5 CardNoYesComputer 5 CardYes Computer Higher scoreYesNoPlayer Higher scoreNoYesComputer Higher scoreNo Computer

DrawCard REPEAT valid = TRUE Index = random number 0-51 IF gPlayPack(index) = “” THEN valid = FALSE ELSE card = gPlayPack(Index) gPlayPack(Index) = “” ENDIF UNTIL valid = true RETURN card NOTE: If you have implemented the Shuffle function you could just draw cards from gPlayPack in sequence rather than randomly.

ReturnValue FOR 0 to 4 SELECT CASE Cards(Counter) Case Aces value = value + 1 or value = value + 11 Case 2svalue = value + 2 Case 3svalue = value + 3 Case 4svalue = value + 4 Case 5svalue = value + 5 Case 6svalue = value + 6 Case 7svalue = value + 7 Case 8svalue = value + 8 Case 9svalue = value + 9 Case 10svalue = value + 10 Case Jacksvalue = value + 10 Case Queensvalue = value + 10 Case Kingsvalue = value + 10 OUTPUT Value RETURN VALUE