There are two problems as in Lab 2. The non-robot problem is an individual assignment and the robot problem is a team assignment.
>>> from Bulls import * >>> main() Welcome to the game of BULLS and COWS. The objective in this game is for you to guess a 4-digit number The computer responds with how close your guess is to the target BULLS = # common digits with exact matches and COWS = # common digits in wrong position. Enter guess number 1: 1876 Bulls = 1 Cows = 1 Enter guess number 2: 1183 Your guess should not contain repeating digits Enter guess number 2: 1596 Bulls = 1 Cows = 2 Enter guess number 3: 1956 Bulls = 3 Cows = 0 Enter guess number 4: 1954 Bulls = 3 Cows = 0 Enter guess number 5: 1958 Bulls = 4 Cows = 0 Congratulations You Won!! >>> >>> main() Welcome to the game of BULLS and COWS. The objective in this game is for you to guess a 4-digit number The computer responds with how close your guess is to the target BULLS = # common digits with exact matches and COWS = # common digits in wrong position. Enter guess number 1: 1234 Bulls = 0 Cows = 1 Enter guess number 2: 2345 Bulls = 0 Cows = 0 Enter guess number 3: 1678 Bulls = 0 Cows = 3 Enter guess number 4: 1679 Bulls = 0 Cows = 3 Enter guess number 5: 1670 Bulls = 0 Cows = 4 Enter guess number 6: 6170 Bulls = 0 Cows = 4 Enter guess number 7: 6710 Bulls = 1 Cows = 3 Enter guess number 8: 7610 Bulls = 2 Cows = 2 Enter guess number 9: 7601 Bulls = 1 Cows = 3 Enter guess number 10: 6701 Bulls = 0 Cows = 4 Sorry You ran out of guesses!! The correct number was: 7016 >>>Submit the code under the file Bulls.py.
http://tinman.cs.gsu.edu/~raj/2010/sp10/message1.txt
This page contains a message in which certain words represent robot commands:
Word | Meaning |
---|---|
forward | Move forward |
backward | Move backward |
left | Turn left |
right | Turn right |
one, two, ..., nine | Execute future robot commands for this many seconds |
For example, suppose that the secret web page contains the following text:
The three branches of government must remain independent to maintain a balance between left and right. If we are to remain one nation, we must move forward, not backward.Note: Your program should work for any file (not just this file). The robot will perform the following commands:
Turn left for 3 seconds Turn right for 3 seconds Move forward for 1 second Move backward for 1 secondThe robot will speak each word on the web page, stopping to execute a robot command for the words forward, backward, left, and right. The robot must stop executing a command if its stall sensor indicates a stall. All robot movements are done at full speed. The default duration for a command (if the web page doesn't specify) is one second.
Write your program as four functions:
from urllib import *
["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]If the word is a number, the position in which the word appears in the list represents its numerical value.
word = word.lower()
word = word.rstrip(".,;:?!)")