Skip to content

Instantly share code, notes, and snippets.

Created July 1, 2011 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1058978 to your computer and use it in GitHub Desktop.
Save anonymous/1058978 to your computer and use it in GitHub Desktop.
start
declarations
arrFull_Deck [2,3,4,5,6,7,8,9,10,11,12,13,14, 2,3,4,5,6,7,8,9,10,11,12,13,14, 2,3,4,5,6,7,8,9,10,11,12,13,14, 2,3,4,5,6,7,8,9,10,11,12,13,14]
arrP1_hand [ ]
arrP2_hand [ ]
arrTable [ ]
num Full_DeckCardCount = 52
num Table = 0
num P1_CardValue
num P2_CardValue
num P1_CardCount = 26
num P2_CardCount = 26
num ran_num
while Full_DeckCardCount ! = 0
distributing cards()
endwhile
while P1_CardCount, P2_CardCount !=0
Battle()
endwhile
if P1_CardCount = 0 then
output “Player 2 is the winner!”
else P2_CardCount = 0 then
output “player 1 is the winner!”
endif
stop
<Battle>
1st value in arrP1_hand [ ] = P1_CardValue
1st value in arrP2_hand [ ] = P2_cardValue
P1_CardCount – 1
P2_CardCount – 1
Table + 2
copy P1_CardValue to arrTable [ ], Delete P1_cardValue from arrP1_hand [ ]
copy P2_CardValue to arrTable [ ], delete P2_cardValue from arr P2_hand [ ]
if P1_CardValue > P2_CardValue then
copy all values in arrTable [ ] to arrP1_hand [ ], delete all values in arrTable [ ]
P1_CardCount + 2
Table – 2
Battle()
endif
if P1_CardValue < P2_CardValue then
Copy all values in arrTable [ ] to arrP2_hand [ ], delete all values In arrTable [ ]
P2_Cardcount + 2
Table – 2
Battle()
endif
if P1_CardValue = P2_CardValue then
WAR()
endif
<WAR>
copy the first 3 values from arrP1_hand [ ] to arrTable [ ], Delete the first 3 values from arrP1_hand
copy the first 3 values from arrP2_hand [ ] to arrTable [ ], Delete the first 3 values from arrP1_hand
P1_CardCount – 3
P2_CardCount - 3
Table + 6
Battle()
<distributingCards>
rand_Num = random an index value from arrFull_Deck [ ]
P1_CardValue = arrFull_Deck [ran_num] //P1_CardValue = the value located at ran_num spot in arrFull_Deck[ ]
copy P1_CardValue to arrP1_hand [ ], delete P1_CardValue from arrFull_Deck [ ]
Full_DeckCardCount – 1
rand_num = random an index value from arrFull_Deck [ ]
P2_CardValue = arrFull_Deck [ran_num] //P1_CardValue = the value located at ran_num spot in arrFull_Deck [ ]
copy P2_CardValue to arrP2_hand [ ] , Delete P2_CardValue from arrFull_Deck [ ]
Full_DeckCardCount – 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment