|
Python Task Assignment
|
Table of Contents
Reference. 10
PYTHON CODE FOR THE GAME OF AKADO
print(“You are Sir Robin, the young knight. Your way is blocked by an angry dragon.”)
print ("""What do you do now ?
1...wait
2...fight
3...run away""")
print("my first line "
"is made up from "
"several parts")
if myanswer == "1":
print ("nothing happens, the dragon also wait")
elif myanswer == "2":
print ("you fight the dragon. The dragon run away !")
# next situation...
elif myanswer == "3":
print ("You run away, but the dragon is faster than you. The dragon eat you. Game Over")
else:
print ("wrong key pressed")
# filename: dragon001.py
print("You are Sir Robin, the young knight. Your way is blocked by an angry dragon.")
print ("""What do you do now ?
1...wait
2...fight
3...run away""")
myanswer = input("press the corresponding number and ENTER:")
print("Your choosed the answer number {0}".format(myanswer))
if myanswer == "1":
print ("nothing happens, the dragon also wait")
elif myanswer == "2":
print ("you fight with the dragon.")
print ("you are now faced with the next situation....")
# continue the code here later
elif myanswer == "3":
print ("You run away, but the dragon is faster than you. The dragon eat you. Game Over")
else:
print ("wrong key pressed")
# filename: dragon001.py
print("You are Sir Robin, the young knight. Your way is blocked by an angry dragon.")
print ("""What do you do now ?
1...wait
2...fight
3...run away""")
myanswer = input("press the corresponding number and ENTER:")
print("Your choosed the answer number {0}".format(myanswer))
if myanswer == "1":
print ("nothing happens, the dragon also wait")
elif myanswer == "2":
print ("you fight with the dragon.")
print ("you are now faced with the next situation....")
# continue the code here later
elif myanswer == "3":
print ("You run away, but the dragon is faster than you. The dragon eat you. Game Over")
else:
print ("wrong key pressed")
# filename: dragon003.py
# assign 3 variables to the value False
belly = False # mybelly or belly_wound or dragonbelly etc.
head = False
tail = False
print("You fight the dragon!")
situation2="""Where do you want to attack the dragon?
1...attack the dragon's head
2...attack the dragon's belly
3...attack the dragon's tail
q...quit the game"""
# repeat until all those 3 variables are True
while not (belly and head and tail):
print(situation2)
myanswer = input("what do you want to do?")
if myanswer == "1":
print("You hit the dragon on the head with your sword!")
head = True
elif myanswer == "2":
print("You inflict an ugly wound on the dragon's belly")
belly = True
elif myanswer =="3":
print("You hack a deep wound in the dragon's tail")
tail = True
elif myanswer =="q":
break # leave the game
else:
print("The dragon bleeds from head, tail and belly and runs away.\n You are victorious! Congratulation, you have won the game")
print("bye-bye")
#filename: snippet017.py
def getanswer(acceptable=[]):
"""asking the user for an answer. adds "q" to the list of acceptable answers.
returns the accepted answer or ask again."""
acceptable.append("q")
localanswer = "something stupid" # assign a unacceptable value to localanswer
while localanswer not in acceptable:
localanswer = input("press q and ENTER to quit or the corresponding number and ENTER:")
return localanswer
#filename: snippet017.py
def getanswer(acceptable=[]):
"""asking the user for an answer. adds "q" to the list of acceptable answers.
returns the accepted answer or ask again."""
acceptable.append("q")
localanswer = "something stupid" # assign a unacceptable value to localanswer
while localanswer not in acceptable:
localanswer = input("press q and ENTER to quit or the corresponding number and ENTER:")
return localanswer
# --- the program start here ---
print("You are Sir Robin, the young knight. Your way is blocked by an angry dragon.")
print("""What do you do now ?
1...wait
2...fight
3...run away""")
myanswer = getanswer(["1", "2", "3"]) # call the function getanswer, store the return value in myanswer
# — the program start here —
print("You are Sir Robin, the young knight. Your way is blocked by an angry dragon.")
print("""What do you do now ?
1...wait
2...fight
3...run away""")
myanswer = getanswer(["1", "2", "3"]) # call the function getanswer, store the return value in myanswer
# filename: dragon004.py
def getanswer(acceptable=["1","2","3"]):
"""asking the user for an answer. adds "q" to the list of acceptable answers.
returns the accepted answer or ask again."""
acceptable.append("q")
localanswer = "something stupid" # assign a unacceptable value to localanswer
while localanswer not in acceptable:
localanswer = input("press q and ENTER to quit or the corresponding number and ENTER:")
return localanswer
# --- the program start here ---
# -- assign values to variables
situation1=("You are Sir Robin, the brave knight. Your way is blocked by an angry dragon.")
options1=("""What do you do now ?
1...wait
2...fight
3...run away""")
situation2=("You fight the dragon!")
options2="""Where do you want to attack the dragon?
1...attack the dragon's head
2...attack the dragon's belly
3...attack the dragon's tail
4...retreat away from the dragon
q...quit the game"""
belly = False # the dragon is very healthy yet
head = False
tail = False
gameOver = False
# --- the main loop ---
print(situation1)
while not gameOver:
print(options1)
myanswer = getanswer()
if myanswer == "q":
gameOver = True
elif myanswer == "1":
print("nothing happens, the dragon also wait")
# continue #
elif myanswer == "2":
print("You bravely decide to fight the dragon.")
# ----- dragon fight loop ----
print(situation2)
while not (belly and head and tail):
print(options2)
myanswer = getanswer(["1","2","3","4"])
if myanswer == "1":
print("You hit the dragon on the head with your sword!")
head = True
elif myanswer == "2":
print("You inflict an ugly wound on the dragon's belly")
belly = True
elif myanswer =="3":
print("You hack a deep wound in the dragon's tail")
tail = True
elif myanswer =="4":
print("You carefully retreat some steps away from the dragon")
print(situation1) #return to the main loop
break # leave the dragon loop
elif myanswer =="q":
gameOver = True
break # leave the dragon loop and leave main loop
else:
# dragon loop was leaved correctly
print("The dragon bleeds from head, tail and belly and runs away.\n"
"You are victorious! Congratulation, you have won the game")
gameOver = True #leave the dragon loop correctly
elif myanswer == "3":
print("You run away, but the dragon is faster than you.\n"
"The dragon eat you. Game Over")
gameOver = True
print("Bye-Bye, thanks for playing")
myanswer = getanswer(["1","2","3","4"])
The default parameter of getanswer is [“1”,”2”,”3”]. Because a 4th option (retreat) is possible during the fight, the whole acceptable list must be handed as parameter at the function call.
print(situation1)
Because the player leave the dragon fight loop and return to the main loop, the description1 is printed again.
gameOver = True
By setting gameOver to True before breaking out of the dragon loop, the main loop will also be leaved.
else:
# dragon loop was leaved correctly
print("The dragon bleeds...")
This else part will only be computed if the dragon fight loop was leaved correctly (by beating the dragon)
elif myanswer == "3":
print("You run away...")
What is that ? it is part of the main loop. For coding beauty, it would make sense to code this branch before the dragon fight branch.
print("Bye-Bye, thanks for playing")
Design of Solution
The design of the entire solution is specifically done according to the requirement of the client. The game is basically designed for playing an interactive session with the kids where the kids will be having a lot of brainstorm and intelligence to solve the entire problem effectively. The game uses the concept of race. The game has two sections, one is the player section where there are two coins for each player and the second is the line where they will commence there race. The aim of the game is to win the race by moving both the coins at the top of the road or u can say by reaching the finishing line. This is by far the best technique that is used to design the game of AKADO. This is undoubtedly the best working space that deals with all the issues that are related with the sector of gaming console. The design is very much important as it leads to the movement of the coin upside down with the chances of the dice. This is perhaps the best sporting line that helps the idea of gaming design to fizz out of the structure environment according to the requirement of the client in all specification. The design was also effectively done as it was in favour of the players that are playing in every section (Dayley, 2007). The designing section is the most important section as it deals with revealing the graphical view of the game. The design is also made quite user friendly as it uses both the instance and the view that is determined to be quite effective and at the same time reflects the best situation of the game. The game is also filled up with several other prospects that allow the user to make the friendly issues that supports the entire environment to a huge extent. Even the players love to make all the proper validations by enjoying the game to the fullest. This is one of the most graphical interacted zones that help the entire system to function properly. This method of interacting with the game and with the graphical section tends the user to reveal such steps that are quite helpful and the same time is quite demanding for the entire structure that allows the entire phenomenon to function appropriately. Hence we can easily sate that this section is undoubtedly the best section that deals with all the best designing sections of the AKODO game developed in Python.
Development of Solution
The solution development section is another important section that has all the valid opportunities that are available for the entire development of the game. The gaming section involves all the other structures that are quite inspiring and at the same time helps the user to design all the effective features that are up to be grab. The entire IDE environment that is used with the help of the python codes has helped the user to design all the structures that are quite valid and at the same time quite important in all prospects. The development phase consisted the most time that was required to complete the game.
The department of solution extracts all the necessary components that are useful for the all the games that are mentioned above and at the same time helps the users to play the game effectively. This is perhaps the bets solution model that helps the entire prospect to be developed for future prospect. The solution of the specific game that is mentioned above has a huge prospect for the gaming section and at the same time develops the graphical interface that was previously used by all the experts to design the game for a better prospect. This is the perfect designing model that is used by most of the experienced programmer to design all the modular steps of programming effectively. The program also states all the notions that particularly help in modulating the effective features that provides all the beneficiary prospects that are available for the user and helps them to provide all the structures that are effective at the same time. The solutions that are developed by the programmer to ensure that the game looks perfectly fine and at the time is quite easy for the players to play in all arcade modes. The games has also been allocated with there specific modes and three specific levels the modes that are available for the game are arcade, adventure and puzzle that is for the user to choose the perfect option that they want to select. The levels of the game that are provided to the user for better functioning are hard, medium, and normal. The programmer has tried all the possible methods that are useful enough and at the same time is hand driven for the entire programming section. This is one of the most effective sections that play the major role in highlighting all the effective measures that are quite fruitful for the entire concept of Python. Programming in python helps the entire structure to follow all the remotes states that are quite proficient for the entire programming section and for the section that discloses all the perspectives that adds an important edge over the developing section. The entire programming section helps the current programmer to effectively design the program for the users. The game is designed in such a manner that all the prospects can be easily available for the user and the users can easily avail and enjoy the game to the fullest.
Programming techniques used for the Game
Python programming is a much advanced programming language that is specifically used for designing and developing high ended games. The language uses several programming techniques that are used by professionals to design game and utilize them effectively according to the requirement of the situation. The program uses various object oriented programming techniques such as data encapsulation, inheritance and other data techniques that are quite valuable for the programming techniques that are used in the gaming section and in the administration section. The techniques that are used for a better prospect helps the game to perform effectively. The programmer also used extensive techniques of python programming to complete the gaming procedures that are helped in the above context. The high enabled programming structures acts as the most enhancing agent for the users and for the programmer to utilize the affects of programming standards with then help of extensive measures which will follow the other structures which are important for all the other prospects that are available in the programming section along with the other prospects that are quite helpful for the user and the programmer uses it in other prospects so that the game can be enhanced to a huge extent along with the consideration of the programmer. This is perhaps the most demanding feature that helps the programmer to design all the programming structures so that it helps the user to extract all the beneficial quotients that are quite responsible for all the other structures that are quite important and at the same time is very effective for the students as far as the other structures that are concerned with the game. This is perhaps the most happening features that enable the users to be presentable at one stage and on the other hand it enables the user to use the other prospect of programming to a huge extent. This is most probably the best feature that establishes the best standards in terms of programming techniques and automation that helps the programmer to understand the concept of the programs and also the structure of the program that must be followed in order to obtain the perfect structure for all the programming standards so that it becomes quite easy for the other programmers to utilize it effectively according to the requirement of the client. The above programming code for the game is designed effectively along with the use of various pointers and functions effectively in sequence. The game also used many other substantial techniques to improve the graphical section of the program and stays within the limitation of the programmer. After using all the above prospects the user figured out that there are many other prospects that can be easily proven for the databases that are used in context of the user so that all the programs that are used in the game can be utilized by the use of better prospects for availing all the programming needs that helps the programmer to upgrade all the programming techniques for future prospect.
Testing and Evaluation
The evaluation and the testing phase is the most important section that helps the user and the program to understand the effect and phase. The testing phase enables the programmer to test the entire program and check if there is any sort of problem that is hidden within the network structures. It completely depends on the programmer to check and evaluate all the programming structures that are used in the program and fix it if there is any and make the game quite effective and useful for the other users that are using the above program. The testing process is the main process which is to be performed by the programmer in order to run the game as smooth as the users want it, the evaluation and the testing phase is done because children and even the aged people loves to play game in their mobile phones or in their PCs. The test process provides smoothness to that particular game. The techniques used for the game is of high quality and it generally needs testing. By this particular process the problems generating in the game is been solved and it is easier for the user to understand the effect and phase. The user generally understands the problems relating to that particular game and they can only justify the quality of the game. The problem relating to the game is can only be solved and renowned by the programmer if they test the game by the process of testing. Therefore, from all the above testing and evaluation technique, it can be easily stated that the process determines the entire concept and texture of the programming section that upholds all the other standards that are not effective for the entire programming standards. The process helps the programmer to determine all the above concepts that are primarily joined with the concept of aggressive modulation. The programmer has done his best to enable the gaming features and the other concepts that are joined along with the perception of the other programming concepts that reveals the use of python programming language for the betterment of the entire programming structure. The programmer also checked all the other vital concepts that are used in the technique of checking the program. Hence we can easily state that the test and execution phase determines the over all execution of the programming code that is stated above in all prospects.
Reference
Dayley, B. (2007). Python phrasebook. 1st ed. Indianapolis, IN: Sams Pub.