import time

minNumber = 1
maxNumber = 100

theNumber = randint(minNumber, maxNumber)

print "The number is: " + str(theNumber)

numberOfTries = 0
found = False
guesses = []
while found == False:
	numberOfTries += 1;
	print "Guess Number " + str(numberOfTries)
	theGuess = myBot(minNumber, maxNumber, guesses)
	print "Got Guess " + str(theGuess)
	if theGuess == theNumber:
		print "Well done!"
		found = True
	elif theGuess < theNumber:
		print "Too Low!"
		guesses.append([theGuess ,-1])
	elif theGuess > theNumber:
		print "Too High!"
		guesses.append([theGuess , 1])
	time.sleep(1)



from bot import myBot


# Test 
val = myBot(1,100,[])
if (val != 1):
	print "Test No guesses yet failed, got "+str(val)


# Test 
val = myBot(1,100,[[1,-1]])
if (val != 2):
	print "Test one guess, got "+str(val)

# Test 
val = myBot(1,100,[[1,-1],[2,-1]])
if (val != 3):
	print "Test two guesses, got "+str(val)


print "All Tests Run!"
예제 #3
0
from random import randint
from bot import myBot
import time

minNumber = 1
maxNumber = 100
rounds = (maxNumber - minNumber) * 10

data = []
for roundNo in range(rounds):
    theNumber = randint(minNumber, maxNumber)
    numberOfTries = 0
    found = False
    guesses = []
    print "Number: " + str(theNumber)
    while found == False:
        numberOfTries += 1
        theGuess = myBot(minNumber, maxNumber, guesses)
        if theGuess == theNumber:
            found = True
        elif theGuess < theNumber:
            guesses.append([theGuess, -1])
        elif theGuess > theNumber:
            guesses.append([theGuess, 1])
    print "Number of tries: " + str(numberOfTries)
    data.append(numberOfTries)

average = sum(data) / len(data)

print "Average number of tries: " + str(average)
예제 #4
0
from bot import myBot

# Test
val = myBot(1, 100, [])
if (val != 1):
    print "Test No guesses yet failed, got " + str(val)

# Test
val = myBot(1, 100, [[1, -1]])
if (val != 2):
    print "Test one guess, got " + str(val)

# Test
val = myBot(1, 100, [[1, -1], [2, -1]])
if (val != 3):
    print "Test two guesses, got " + str(val)

print "All Tests Run!"