Homework 5 Bug Buster Summer 2018
Due: July 26, 6pm
In this homework, you are to design a catch-bug game program where a user tries to predict the bug position on a 4 x 4 grid.
The initial position of the bug is fixed at (3, 3). The bug may move to any cell surrounding it, bounded by the 4 x 4 grid. Users have 5 chances to catch the bug, or the bug wins. Whenever the bug wins or is killed, the program changes the bug picture to show the result and ends the game.
During the game, the program shows the remaining moves and the user score. The user score starts from 100, and every unsuccessful catch reduces it by 20. Your program should also show meaningful messages to let users know what they should do next.
Three bug pictures are given, with filenames (“bug.gif”, “bug_win.gif”, and “bug_die.gif”). We have also given you a simple example code showing the basic program structure.
Here are some sample game pictures.
1. Users capture the bug in 4 moves |
Fig. 1: Initial displayFig. Fig. 2: Show user's click |
Fig. 3: The bug moves but still alive Fig. 4: The bug is caught
2. If it is not caught in 5 moves, the bug wins. The program shows the happy bug. The user should click it again to stop the program.
Here are possible error messages.
1) If the user click is outside of the grid, a message should ask the user to click inside again.
2) If the click is not next to the bug, an invalid message appears and the user should retry without penalty.
In this homework, you should design and use the following two functions:
def move(x, y):
# It returns a new, valid position for the bug.
# You should use “random.randint(-1,1)” to randomly move the bug on both x and y positions.
# You should check if the bug stays inside of the grid. If not, do it again.
def showClick(Win):
# It returns the position the user has just clicked.
# The cell should be highlighted briefly to let the user see where it is.
Submission:
The submission deadline is 6pm, July 26 (Thursday).
· Grading Criteria (out of 100 points):
o Programs submitted with no syntax error (10 points)
o Create an initial window with grid and messages (10 points)
o Show bug pictures correctly (20 points)
o Move bugs randomly after user’s clicks (20 points)
o Make the bug capture decision correctly (20 points)
o Show all messages and game logic correctly (20 points)
代写CS&Finance|建模|代码|系统|报告|考试
编程类:C代写, JAVA代写 , 数据库代写, WEB代写, Python代写, Matlab代写, GO语言, R代写
金融类:统计,计量,风险投资,金融工程,R语言,Python语言,Matlab,建立模型,数据分析,数据处理
服务类:Lab/Assignment/Project/Course/Qzui/Midterm/Final/Exam/Test帮助代写代考辅导
天才写手, 代写CS , 代写finance , 代写statistics , 考试助攻
E-mail:850190831@qq.com 微信:BadGeniuscs 工作时间:无休息工作日-早上8点到凌晨3点
如果您用的手机请先保存二维码到手机里面,识别图中二维码。如果用电脑,直接掏出手机果断扫描。