# Pseudocode Help

Page 1 of 1

## 1 Replies - 2418 Views - Last Post: 13 March 2005 - 10:17 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=10625&amp;s=abfb520c7de56484930a08f6788d7911&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Sarah.K

Reputation: 0
• Posts: 2
• Joined: 13-March 05

# Pseudocode Help

Posted 13 March 2005 - 01:53 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.

Is This A Good Question/Topic? 0

## Replies To: Pseudocode Help

### #2 born2c0de

• printf("I'm a %XR",195936478);

Reputation: 186
• Posts: 4,673
• Joined: 26-November 04

## Re: Pseudocode Help

Posted 13 March 2005 - 10:17 PM

You can create a flag that is given the value TRUE when the guess is correct. As in you can modify your code like this: ( ahh...yes...I even cleaned a few loops of yours )

```SET point_valueA = suit_valueA = guess_count = game_count = = 0

REPEAT
SET point_value = 10
SET suit_flag = false
SET value_flag = false
SET suit_value = Hearts
OUTPUT message to operator for suit_valueA
GET suit_valueA
IF suit_valueA == suit_value THEN
SET suit_flag = true
OUTPUT message indicates successful guess
ELSE
SET suit_flag = false
OUTPUT message indicates incorrect guess
END IF

OUTPUT message to operator for point_valueA
GET point_valueA
IF point_valueA == point_value THEN
SET value_flag=true
OUTPUT messages indicates successful guess
ELSE
value_flag=false
IF point_valueA < point_value THEN
OUTPUT message indicates guess to low
ELSE
OUTPUT message indicates guess to high
END IF
END IF

IF (suit_flag==true) and (value_flag==true) THEN
OUTPUT message indicating Game's end
SET game_count = game_count +1
ELSE
OUTPUT Wrong Guess
END IF

UNTIL game_count < 4

```

A mistake you have made is that you have insured that the user gets the suit correct before guessing the value. Removing the loops like how shown above can make it work.

I've also partly taken care of step 6 (3 games)...the rest can be similarly done using various other flags.

If you still experience problems...drop by this thread again...and we'll help.