[Solved] CmpE150.03 Homework 4- ASCII Atari-like game

$25

File Name: CmpE150.03_Homework_4-_ASCII_Atari-like_game.zip
File Size: 414.48 KB

SKU: [Solved] CmpE150.03 Homework 4- ASCII Atari-like game Category: Tag:
5/5 - (1 vote)

You

You will write a Python script to implement an ASCII Atari-like game where a spaceship navigates and shoots asteroids using three parameters: x as the length of the asteroid cluster, y as the width of the asteroid cluster, and g as the current distance to the asteroid cluster. You will take these parameters from the user at the beginning of the game. The game is played with three actions: left to go one space left, right to go one space right, and fire to shoot a laser to destroy an asteroid in front of the spaceship. There is also an exit action to exit the game. You will take these actions from the user at each step of the game. Full example games are provided as .txt files, both input and output. Please read the assignment description and check out the examples before beginning to write any code or sending emails.

Please make sure you follow these rules in your implementation:

  1. Assume that x >= 0, y > 0, g >= 0 always. We wont be testing for very large numbers, so do not worry about efficiency or timeouts.
  1. Assume that inputs for x, y, and g will always be integers.
  • Assume that the actions fire, left, right, and exit are not case sensitive, they can be given like: Fire, EXIT, RiGhT etc.
  1. You are not allowed to use statements that have not been covered in class as of 24/11/20 (Week 5 of the course on Moodle). For example, you cannot use functions (def).
  1. Do not use any imports!
  1. You can test your code by playing the game yourself and using PyCharms terminal window while in the project.

Follow the format exactly as in the figure below.

Change the .py filename to your own, change the input and output filenames to the one you would like to try. < and > are very important, there should be no empty spaces between them and the file names. There should be a single empty space between python and your filename. This will run your code using the input from the input file and output it to the output file. You can then check the output file and see if it matches.

Note that when doing it this way unlike playing the game yourself, the input file contains the user input in order, and output file does not contain that input, so do not be surprised.

The files should be located under the project exactly as in the figure below for this to work.

Implementation Details:

  • You are expected to print everything to the terminal, do not write to a file.
  • You are given some code at the beginning of the file, to take the inputs x, y, and g. Do not change those lines and use those as your variables.
  • The asteroid cluster is x lines long and y characters wide, and it is g lines away from the spaceship. The spaceship is on another line as well.
  • The spaceship starting position is at the middle of the line if y is odd, and on one space left of the middle of the line if y is even.
  • There are 3 valid play actions: fire, left, right and 1 exit For any other action given, assume that there is a discussion in the ship and no action can be executed that time, although time passes, so print the last board configuration and continue with the next step.
  • When the game starts, the first thing should be to print the board, showing the initial situation to the user. Assume that this is at time 0 and then ask the user for an action with the prompt: Choose your action! Then, execute this action and print the relevant frames, and advance the time by 1.
  • When time is a multiple of 5, that means enough time has passed and asteroids get closer to the spaceship by 1 line.
  • The game ends when the user exits with the exit action, when all the asteroids are destroyed, or when the spaceship is hit by the asteroids when the cluster gets too close. In all these cases, print the score and the relevant messages.
  • Hit by asteroids: If there is at least 1 asteroid in any position on the closest line before the ship, and the time then becomes a multiple of 5 when any of the asteroids are still there, this will cause the game to be over.
  • If the game is over due to hit by asteroids, you need to print GAME OVER, followed by the last board configuration, and then print the score.
  • If the game is over because all the asteroids are destroyed, then the user has won. Then print the current board configuration, followed by YOU WON!
  • If the game is over due to the user choosing the exit action, then print the last board configuration, followed by the score.
  • The score is the number of asteroids destroyed at the end of the game. It should be printed at the end of each game, however the game ends as YOUR SCORE: followed by the value of score after printing the board.
  • Try to consider all possible scenarios. For example, the user starts the game, and the first command is exit. In this case you should print the initial board configuration, then print the last board configuration, then print the score, which is 0.
  • There are 72 separator hyphens (-) at each instance of their use.
  • You can think of the game in terms of actions and frames. See the figures below.
  • Each action corresponds to one or more frames. left action moves the spaceship to the left then prints the updated frame, right action moves the spaceship to the right then prints the updated frame, fire action shoots a laser which travels until either it impacts an asteroid or until it reaches the other end of the frame. If an asteroid is hit by a laser, it should be destroyed.
  • If the ship is already at the leftmost position of the board, left action does nothing but time passes. If the ship is already at the rightmost position of the board, right action does nothing, but time passes.

will write a Python script to implement an ASCII Atari-like game where a spaceship navigates and shoots asteroids using three parameters: x as the length of the asteroid cluster, y as the width of the aste

You will write a Python script to implement an ASCII Atari-like game where a spaceship navigates and shoots asteroids using three parameters: x as the length of the asteroid cluster, y as the width of the asteroid cluster, and g as the current distance to the asteroid cluster. You will take these parameters from the user at the beginning of the game. The game is played with three actions: left to go one space left, right to go one space right, and fire to shoot a laser to destroy an asteroid in front of the spaceship. There is also an exit action to exit the game. You will take these actions from the user at each step of the game. Full example games are provided as .txt files, both input and output. Please read the assignment description and check out the examples before beginning to write any code or sending emails.

Please make sure you follow these rules in your implementation:

  1. Assume that x >= 0, y > 0, g >= 0 always. We wont be testing for very large numbers, so do not worry about efficiency or timeouts.
  1. Assume that inputs for x, y, and g will always be integers.
  • Assume that the actions fire, left, right, and exit are not case sensitive, they can be given like: Fire, EXIT, RiGhT etc.
  1. You are not allowed to use statements that have not been covered in class as of 24/11/20 (Week 5 of the course on Moodle). For example, you cannot use functions (def).
  1. Do not use any imports!
  1. You can test your code by playing the game yourself and using PyCharms terminal window while in the project.

Follow the format exactly as in the figure below.

Change the .py filename to your own, change the input and output filenames to the one you would like to try. < and > are very important, there should be no empty spaces between them and the file names. There should be a single empty space between python and your filename. This will run your code using the input from the input file and output it to the output file. You can then check the output file and see if it matches.

Note that when doing it this way unlike playing the game yourself, the input file contains the user input in order, and output file does not contain that input, so do not be surprised.

The files should be located under the project exactly as in the figure below for this to work.

Implementation Details:

  • You are expected to print everything to the terminal, do not write to a file.
  • You are given some code at the beginning of the file, to take the inputs x, y, and g. Do not change those lines and use those as your variables.
  • The asteroid cluster is x lines long and y characters wide, and it is g lines away from the spaceship. The spaceship is on another line as well.
  • The spaceship starting position is at the middle of the line if y is odd, and on one space left of the middle of the line if y is even.
  • There are 3 valid play actions: fire, left, right and 1 exit For any other action given, assume that there is a discussion in the ship and no action can be executed that time, although time passes, so print the last board configuration and continue with the next step.
  • When the game starts, the first thing should be to print the board, showing the initial situation to the user. Assume that this is at time 0 and then ask the user for an action with the prompt: Choose your action! Then, execute this action and print the relevant frames, and advance the time by 1.
  • When time is a multiple of 5, that means enough time has passed and asteroids get closer to the spaceship by 1 line.
  • The game ends when the user exits with the exit action, when all the asteroids are destroyed, or when the spaceship is hit by the asteroids when the cluster gets too close. In all these cases, print the score and the relevant messages.
  • Hit by asteroids: If there is at least 1 asteroid in any position on the closest line before the ship, and the time then becomes a multiple of 5 when any of the asteroids are still there, this will cause the game to be over.
  • If the game is over due to hit by asteroids, you need to print GAME OVER, followed by the last board configuration, and then print the score.
  • If the game is over because all the asteroids are destroyed, then the user has won. Then print the current board configuration, followed by YOU WON!
  • If the game is over due to the user choosing the exit action, then print the last board configuration, followed by the score.
  • The score is the number of asteroids destroyed at the end of the game. It should be printed at the end of each game, however the game ends as YOUR SCORE: followed by the value of score after printing the board.
  • Try to consider all possible scenarios. For example, the user starts the game, and the first command is exit. In this case you should print the initial board configuration, then print the last board configuration, then print the score, which is 0.
  • There are 72 separator hyphens (-) at each instance of their use.
  • You can think of the game in terms of actions and frames. See the figures below.
  • Each action corresponds to one or more frames. left action moves the spaceship to the left then prints the updated frame, right action moves the spaceship to the right then prints the updated frame, fire action shoots a laser which travels until either it impacts an asteroid or until it reaches the other end of the frame. If an asteroid is hit by a laser, it should be destroyed.
  • If the ship is already at the leftmost position of the board, left action does nothing but time passes. If the ship is already at the rightmost position of the board, right action does nothing, but time passes.

roid cluster, and g as the current distance to the asteroid cluster. You will take these parameters from the user at the beginning of the game. The game is played with three actions: left to go one space left, right to go one space right, and fire to shoot a laser to destroy an asteroid in front of the spaceship. There is also an exit action to exit the game. You will take these actions from the user at each step of the game. Full example games are provided as .txt files, both input and output. Please read the assignment description and check out the examples before beginning to write any code or sending emails.

Please make sure you follow these rules in your implementation:

  1. Assume that x >= 0, y > 0, g >= 0 always. We wont be testing for very large numbers, so do not worry about efficiency or timeouts.
  1. Assume that inputs for x, y, and g will always be integers.
  • Assume that the actions fire, left, right, and exit are not case sensitive, they can be given like: Fire, EXIT, RiGhT etc.
  1. You are not allowed to use statements that have not been covered in class as of 24/11/20 (Week 5 of the course on Moodle). For example, you cannot use functions (def).
  1. Do not use any imports!
  1. You can test your code by playing the game yourself and using PyCharms terminal window while in the project.

Follow the format exactly as in the figure below.

Change the .py filename to your own, change the input and output filenames to the one you would like to try. < and > are very important, there should be no empty spaces between them and the file names. There should be a single empty space between python and your filename. This will run your code using the input from the input file and output it to the output file. You can then check the output file and see if it matches.

Note that when doing it this way unlike playing the game yourself, the input file contains the user input in order, and output file does not contain that input, so do not be surprised.

The files should be located under the project exactly as in the figure below for this to work.

Implementation Details:

  • You are expected to print everything to the terminal, do not write to a file.
  • You are given some code at the beginning of the file, to take the inputs x, y, and g. Do not change those lines and use those as your variables.
  • The asteroid cluster is x lines long and y characters wide, and it is g lines away from the spaceship. The spaceship is on another line as well.
  • The spaceship starting position is at the middle of the line if y is odd, and on one space left of the middle of the line if y is even.
  • There are 3 valid play actions: fire, left, right and 1 exit For any other action given, assume that there is a discussion in the ship and no action can be executed that time, although time passes, so print the last board configuration and continue with the next step.
  • When the game starts, the first thing should be to print the board, showing the initial situation to the user. Assume that this is at time 0 and then ask the user for an action with the prompt: Choose your action! Then, execute this action and print the relevant frames, and advance the time by 1.
  • When time is a multiple of 5, that means enough time has passed and asteroids get closer to the spaceship by 1 line.
  • The game ends when the user exits with the exit action, when all the asteroids are destroyed, or when the spaceship is hit by the asteroids when the cluster gets too close. In all these cases, print the score and the relevant messages.
  • Hit by asteroids: If there is at least 1 asteroid in any position on the closest line before the ship, and the time then becomes a multiple of 5 when any of the asteroids are still there, this will cause the game to be over.
  • If the game is over due to hit by asteroids, you need to print GAME OVER, followed by the last board configuration, and then print the score.
  • If the game is over because all the asteroids are destroyed, then the user has won. Then print the current board configuration, followed by YOU WON!
  • If the game is over due to the user choosing the exit action, then print the last board configuration, followed by the score.
  • The score is the number of asteroids destroyed at the end of the game. It should be printed at the end of each game, however the game ends as YOUR SCORE: followed by the value of score after printing the board.
  • Try to consider all possible scenarios. For example, the user starts the game, and the first command is exit. In this case you should print the initial board configuration, then print the last board configuration, then print the score, which is 0.
  • There are 72 separator hyphens (-) at each instance of their use.
  • You can think of the game in terms of actions and frames. See the figures below.
  • Each action corresponds to one or more frames. left action moves the spaceship to the left then prints the updated frame, right action moves the spaceship to the right then prints the updated frame, fire action shoots a laser which travels until either it impacts an asteroid or until it reaches the other end of the frame. If an asteroid is hit by a laser, it should be destroyed.
  • If the ship is already at the leftmost position of the board, left action does nothing but time passes. If the ship is already at the rightmost position of the board, right action does nothing, but time passes.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CmpE150.03 Homework 4- ASCII Atari-like game
$25