Small Basic Small Basic E-Books > Basic Computer Games Small Basic Edition > Acey Ducey
 

This is a simulation of the Acey Ducey card game. In the game, the dealer (the computer) deals two cards face up. You have an option to bet or not to bet depending on whether or not you feel the next card dealt will have a value between the first two. Your initial money (Q) is set to $100; you may alter the line setting Q to 100 if you want to start with more or less than $100. The game keeps going on until you lose all your money or interrupt the program.

The original program author was Bill Palmby of Prairie View, Illinois.

Code Listing (Small Basic File: aceyducy.sb):

TextWindow.CursorLeft = 26 
TextWindow.WriteLine("ACEY DUCEY CARD GAME")
TextWindow.CursorLeft = 15
TextWindow.WriteLine("BIBLEBYTE BOOKS,
MAPLE VALLEY, WASHINGTON")
TextWindow.WriteLine("") TextWindow.WriteLine("")
TextWindow.WriteLine("ACEY-DUCEY IS PLAYED IN THE
FOLLOWING MANNER ")
TextWindow.WriteLine("THE DEALER (COMPUTER) DEALS
TWO CARDS FACE UP")
TextWindow.WriteLine("YOU HAVE AN OPTION TO BET
OR NOT BET DEPENDING")
TextWindow.WriteLine("ON WHETHER OR NOT YOU
FEEL THE CARD WILL HAVE")
TextWindow.WriteLine("A VALUE BETWEEN THE
FIRST TWO.")
TextWindow.WriteLine("IF YOU DO NOT WANT TO BET,
INPUT A 0")
N=100 LN110: Q=100 LN120:
TextWindow.WriteLine("YOU NOW HAVE " + Q +"
DOLLARS.")
TextWindow.WriteLine("")
Goto LN260
LN210: Q=Q+M Goto LN120
LN240: Q=Q-M Goto LN120 LN260:
TextWindow.WriteLine("HERE ARE YOUR NEXT
TWO CARDS:")
LN270: A=Math.GetRandomNumber(14) + 1
If A<2 Then Goto LN270 EndIf
If A>14 Then Goto LN270 EndIf
LN300: B=Math.GetRandomNumber(14) + 1
If B<2 Then Goto LN300 EndIf
If B>14 Then Goto LN300 EndIf
If A>=B Then Goto LN270 EndIf
If A<11 Then Goto LN400 EndIf
If A=11 Then Goto LN420 EndIf
If A=12 Then Goto LN440 EndIf
If A=13 Then Goto LN460 EndIf
If A=14 Then Goto LN480 EndIf
LN400: TextWindow.WriteLine(A)
Goto LN500
LN420: TextWindow.WriteLine("JACK")
Goto LN500
LN440: TextWindow.WriteLine("QUEEN")
Goto LN500
LN460: TextWindow.WriteLine("KING")
Goto LN500
LN480: TextWindow.WriteLine("ACE")
LN500: If B<11 Then Goto LN550 EndIf
If B=11 Then Goto LN570 EndIf
If B=12 Then Goto LN590 EndIf
If B=13 Then Goto LN610 EndIf
If B=14 Then Goto LN630 EndIf
LN550: TextWindow.WriteLine(B)
Goto LN650
LN570: TextWindow.WriteLine("JACK")
Goto LN650
LN590: TextWindow.WriteLine("QUEEN")
Goto LN650
LN610: TextWindow.WriteLine("KING")
Goto LN650
LN630: TextWindow.WriteLine("ACE")
TextWindow.WriteLine("")
LN650: TextWindow.WriteLine("")
TextWindow.Write("WHAT IS YOUR BET ")
M = TextWindow.ReadNumber()
If M<>0 Then Goto LN680 EndIf
TextWindow.WriteLine("CHICKEN!!")
TextWindow.WriteLine("") Goto LN260
LN680: If M<=Q Then Goto LN730 EndIf
TextWindow.WriteLine("SORRY, MY FRIEND, BUT YOU
BET TOO MUCH.")
TextWindow.WriteLine("YOU HAVE ONLY "+Q+"
DOLLARS TO BET.") Goto LN650
LN730: C=Math.GetRandomNumber(14) + 1
If C<2 Then Goto LN730 EndIf
If C>14 Then Goto LN730 EndIf
If C<11 Then Goto LN810 EndIf
If C=11 Then Goto LN830 EndIf
If C=12 Then Goto LN850 EndIf
If C=13 Then Goto LN870 EndIf
If C=14 Then Goto LN890 EndIf
LN810: TextWindow.WriteLine(C)
Goto LN910
LN830: TextWindow.WriteLine("JACK")
Goto LN910
LN850: TextWindow.WriteLine("QUEEN")
Goto LN910
LN870: TextWindow.WriteLine("KING")
Goto LN910
LN890: TextWindow.WriteLine("ACE")
TextWindow.WriteLine("")
LN910: If C>A Then Goto LN930 EndIf
Goto LN970
LN930: If C>=B Then Goto LN970 EndIf
TextWindow.WriteLine("YOU WIN!!!")
Goto LN210
LN970:
TextWindow.WriteLine("SORRY, YOU LOSE")
If M<Q Then Goto LN240 EndIf
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.WriteLine("SORRY, FRIEND,
BUT YOU BLEW YOUR WAD.")
TextWindow.WriteLine("")
TextWindow.WriteLine("")
TextWindow.Write("TRY AGAIN (YES OR NO) ")
AString = TextWindow.Read()
TextWindow.WriteLine("")
TextWindow.WriteLine("")
If AString="YES" Then Goto LN110 EndIf
TextWindow.WriteLine("O.K., HOPE YOU
HAD FUN!")

This chapter is adapted from the book Basic Computer Games Small Basic Edition published by BibleByte Books.

To purchase this book in its entirety, please see the Computer Science For Kids web site.


Sample Run:

Acey Ducey

Next Chapter > >

© Copyright 2010 By BibleByte Books. All Rights Reserved. BibleByte Books, the BibleByte Books Logo, Computer Science For Kids, the Computer Science For Kids logo, and related trade dress are trademarks or registered trademarks of BibleByte Books.