CPSC 231 Assignment 2 Chasing Alice solved

$24.99

Original Work ?

Download Details:

  • Name: as2.zip
  • Type: zip
  • Size: 465.19 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

For this assignment, you develop a turn-based game where you control a blue turtle, Alex, to chase and catch a red turtle, Alice. Create a canvas (also known as screen) of size 500 x 500. Alex must appear at the middle of the canvas. Alice appears at a random location inside the canvas.
In each turn, Alice can move either forward by 20 pixels or she can change her direction randomly to left or right by 90 degrees. 2/3 of Alice’s movements should be forward movements and 1/3 should be the random direction changing left or right, see figure 1 below.

Alex moves as directed by the player using the keyboard. In each turn, the buttons w, a, s, and d lead Alex to move forward for 30 pixels, turn left for 45 degrees, back for 30 pixels, and right for 45 degrees, respectively. If Alex or Alice cross the canvas’s boundaries, they should reappear at a random1 location on the canvas. The game statistic needs to be provided on the screen as shown in the sample. The game ends if Alex comes within 30 pixels of Alice in any direction. See figure 2 to get an idea of how the game will look like.
1 To learn how to generate random numbers in python, look at: https://docs.python.org/3/library/random.html
Alice movement
Alex Movement
20 Pixels
90 Degree
90 Degree
45 Degree
30 Pixels
Figure 1: Alice and Alex movements
Figure 2: Samples of how the game will look like
Marking:
Category 5 Points 4 Points 3 Points 2 Point 1 Point 0 point Setup Turtles are setup correctly (colors, shapes, locations) Turtles are not setup correctly Alice movement Alice moves correctly (distance, angles, 2/3 fwd., 1/3 changing dir.) Alice moves partially correctly Alice does not move correctly Alex movement Arrow keys properly transfer to Alex movement Arrow keys partially transfer to Alex movement Arrow keys does not properly transfer to Alex movement Modularity There is one function for each distinct task Small part of code is not in function Most of the code is developed inside functions Half of the code are in functions Or functions contain unrelated codes Limited use of functions No proper use of functions Detection of catching Correct detection of Alice catching Some reasonable codes for the catching function Alice catch is not detected
Detection & handling of turtles leaving the canvas
Turtles leaving the canvas is detected & handled
Turtles leaving the canvas is partially detected or partially handled
Turtles leaving the canvas is not detected
Showing statistics
The statistic is shown correctly
The statistic is shown partially correctly
Statistics are not shown
Using constants and local variables
Code contains local variables and wellnamed constants Without any magic number or global variables
Code contains magic numbers or global variables
Comments and variable naming
Consistence variable naming, student information at the top of the code + Code is commented well, Program name is correct
Inadequate comments or inconsistent variable naming or variable names are not meaningful
No comments or inconsistent variable naming or variable names are not meaningful, program name is not correct Total 20
Submission requirements
In order to receive a complete grade no global variable or codes outside functions should be in your program. Create a main function and control the program by calling other functions through main. The program starts with calling main() only. Use constants instead of magic numbers. Follow variable name conventions all through your code and be consistence. Use white lines to separate blocks of codes.
Name your program ChasingAlice.py then submit it to the D2L Assignment 2 dropbox by the deadline stated at the top of this document.
Collaboration, Plagiarism, and Cheating
This is an individual assignment and all work that you submit must be your own work. We encourage you to discuss this assignment with other students in the course and discourage you from sharing solutions and code with one another. Sharing solutions and code is a form of plagiarism.
We use automated procedures to detect plagiarism in assignment submissions. Any student who copies all or part of an assignment that belongs to another student or other sources will be reported to the Dean. The Dean enforces penalties, which may include failing the course and expulsion from the faculty and the university. Please refer to Plagiarism/Cheating/Other Academic Misconduct in the university calendar or the university website on plagiarism for more information.