Advertisement Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    7
  • comments
    2
  • views
    1067

pseudocode assignment

Sign in to follow this  
WinterDragon

746 views

The assignment was to adapt the guessing game to reverse the process,

by allowing the player to choose the number and let the computer try to guess it,

then to write this game as pseudocode.

Let me know how well you think I did?

 

declare variables

import random

def start

Print "guess cannot be higher than 50"

if number >50 then print "you cheated":break

input (low)"what is the lowest possible number your guess could be?"
input (high)"what is the highest possible number your guess could be?"
computer chooses a random number between low and high
check to see if it is the number
elif check to see if the number is too low
if so numscale=low
elif check to see if the number is too high
if so numscale=high

def new method
if the number is too low tell computer the guess is too low
if the number is too high tell the computer the guess is too high
is this the first time guessing?

if the guess is too low and this is the first time guess=guess+2
if the guess is too high and this is the first time guess=guess-2
if the guess is too low and this is not the first time guess=guess+1
if the guess is too low and this is not the first time guess=guess-1
print guess
guessCount=guessCount+1
goto start

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!