PDA

View Full Version : Pseudocode Help.


Rob.K
03-12-2005, 10:34 PM
Hi,
Im a computing student and need help with some pseudocode. The following is what I have got so far...

SET point_value = 10
SET suit_value = Hearts
SET point_valueA = suit_valueA = guess_count = game_count = = 0
REPEAT
OUTPUT message to operator for suit_valueA
GET suit_valueA
IF suit_valueA == suit_value THEN
OUTPUT message indicates successful guess
ELSE
OUTPUT message indicates incorrect guess
END IF
UNTIL suit_valueA == suit_value
REPEAT
OUTPUT message to operator for point_valueA
GET point_valueA
IF point_valueA == point_value THEN
OUTPUT messages indicates successful guess
ELSE
IF point_valueA < point_value THEN
OUTPUT message indicates guess to low
ELSE
OUTPUT message indicates guess to high
END IF
END IF
UNTIL point_valueA == point_value

The code is for a game which goes by the following rules...

1) Imagine computer randomly selects a card from a pack of cards.
2) The first player must guess the suit then its value
3) After each guess for the suit a message will display whether the player was correct or not.
4) After each guess for the value a message will display whether the player was correct, too high or too low.
5) The individual game ends when a player has correctly identfied the card, the next player is now given a new card.
6) On completing 3 games each the average number of guesses to correctly identify the card should be displayed for each player.
7) The game should be restricted to three players.

So basically I have completed the first 4 steps but need help editing my code to include rules 5, 6 and 7.

Any help at all would be very much appreciated.

Many Thanks,

Rob.

aman
03-12-2005, 11:22 PM
I think you should write it all yourself and post for help on specific parts of your code if you need it.

Rob.K
03-12-2005, 11:41 PM
I wrote as much as i was capable of. I cant get my head round the loops etc. I just need help with some code which does the average score and arranges the players turns.

Rob.K
03-13-2005, 08:31 PM
Anyone out there?

nightthepope
03-15-2005, 08:56 PM
Assign values to the suits.
c = 0
d = 1
h = 2
s = 2

Then use a loop to enumerate all the cards

for i = 1 to 52
int[i] = i
next

with a decklist from 1 to 52 you can now translate from card number to the array with the formula.

card = (suit * 13) * (cardValue -1)

with the card number you can remove it from the cardArray so you now know which cards are still int he deck.