1. Homepage
  2. Programming
  3. CS3357A COMPUTER NETWORKING Assignment #3: Server-driven snake game

CS3357A COMPUTER NETWORKING Assignment #3: Server-driven snake game

Engage in a Conversation
UWOCS3357ACOMPUTER NETWORKINGServer-driven snake gamePython

CS3357A COMPUTER NETWORKING CourseNana.COM

Assignment #3: Server-driven snake game. CourseNana.COM

Assignment Purpose CourseNana.COM

The objective of this assignment is to develop a server-based snake game where the server manages the game logic and the client interfaces with the server to interact with the game. The game in focus is the classic Snake game (shown in image below). CourseNana.COM

Figure 1 The snake game Graphical User Interface reconstructed at the client side using the game state sent by the server. CourseNana.COM

Assignment Description CourseNana.COM

Server-based gaming is a popular service provided over the internet nowadays. World of Warcraft, Conflict of Nations, and Clash of Clans are examples of server-based or server-driven games. In this assignment, you will implement a server-based snake game that is played over the network.
A server-based game is composed of a server side and a user side. The game model lives on the server; this is where the game variables are stored and where the rules to update these variables are implemented and executed. The user machine runs an application that connects to the server, sends the user controls inputs, and periodically receives the updated game state from the server, to draw an interface of the game.
CourseNana.COM

You are given the server-side code (snake.py and snake_server.py), and you are required to implement the client side code (snake_client.py). CourseNana.COM

Files description CourseNana.COM

snake.py contains an implementation of the objects that constitute the snake game (e.g. snake, cube, snack) and all the functions that the server needs to run the logic of the game (The snake game is described below). snake_server.py Performs two tasks simultaneously: CourseNana.COM

  1. 1-  Runs the snake game logic including updating snake’s movements, collisions, and scores; and CourseNana.COM

  2. 2-  Waits for a client to connect on a TCP socket port. When a new client connects, a snake is CourseNana.COM

    instantiated and deployed on the board. The state of the game including the position of the snake and the locations of snacks and is sent to the client periodically. And when the client presses any of the defined control keys, the movement command is sent to the server which includes this command while updating the state of the environment before the new state is sent to the client. CourseNana.COM

snake_client.py (You will implement) should connect to the server, receive the state of the game periodically, and send the appropriate control commands when the user presses a control key to control the snake. The exact commands that should be implemented in the snake_client.py are provided in the game controls sub-section of the snake game section, or they could be inferred from the provided snake_server.py file.  CourseNana.COM

The snake game server is responsible for: CourseNana.COM

  1. Accepting a connection from a single client. CourseNana.COM

  2. Receive and parse the controls sent by the client. CourseNana.COM

  3. Managing the game's logic, including recording control inputs, and updating the game state CourseNana.COM

    according to the game rules. CourseNana.COM

  4. Sending the game state to the client. CourseNana.COM

The snake game client is responsible for: CourseNana.COM

  1. Connecting to the server. CourseNana.COM

  2. Sending user inputs (movements) to the server. CourseNana.COM

  3. Receive and parse the game state from the server. CourseNana.COM

  4. Displaying the game interface based on the received game state. CourseNana.COM

Snake game CourseNana.COM

The snake game is a game featuring a snake roaming a squared arena; and snacks dispersed across the map. The arena can be viewed as a grid composed of an equal number of rows and columns. The snake is composed of cubes, and the size of each cell is the same as the size of a single cube. The size of a snack is one cell. Figure 1 shows a screenshot of the game interface that the client you are required to develop should reconstruct from the game state received from the server. It shows five snacks (in green) at random locations, and a snake (in red) which is five cubes long. CourseNana.COM

In the game, the user controls the movement of the snake with the goal of collecting as many snacks as possible. With each snack collected, the snake grows one more cube. In this version of the snake game, the logic of the game runs on the server (implemented in the snake_server.py file) while the interface of the game (shown in figure 1) is displayed on the client side (which you are required to implement). To draw the interface of the game and update it several times each second, the client has to receive the game state (the position and length of the snake, and the location of all snacks). Since the game state is updated each cycle/loop based on the inputs of the user, the server and the user must exchange the controls and the game state each cycle/loop to play the game. CourseNana.COM

Game controls CourseNana.COM

The client script you will implement controls the snake in the game environment handled on the server. For the user/client to be able to influence the state of the game, it has to agree with the server on a set of control inputs each has a specific impact on the game state. CourseNana.COM

There are seven control inputs that the snake game server understands. The client side should implement these seven control inputs to be able to “talk” to the server. These commands are used by the user to control the snake or the game. For example, changing the direction of the snake, reset, or quit the game. The list of control inputs that you should implement is given below: CourseNana.COM

  1. up: changes the direction of the snake to up/north CourseNana.COM

  2. down: changes the direction of the snake to down/south CourseNana.COM

  3. left: changes the direction of the snake to left/west CourseNana.COM

  4. right: changes the direction of the snake to right/east CourseNana.COM

  5. reset: reset the length of the snake and start from a random location. CourseNana.COM

  6. quit: quits the application. CourseNana.COM

  7. get: a default command. Requests the current game state. CourseNana.COM

Upon receiving the control inputs from the client, the server parses the control messages, updates the game state (e.g. change the direction of the snake), and returns the updated game state to the client. CourseNana.COM

Game state CourseNana.COM

The game state is a set of values that work as a snapshot of the game at a certain moment (like figure 1). This snapshot contains all the information needed to reconstruct the game view on the client side. The string representing the game state is generated and returned using the game.get_state() function in the SnakeGame class in the provided snake.py file. The game state contains the position of the snake (the locations of all its body cubes) and the locations of the snacks. CourseNana.COM

The client that you will implement should parse the returned game state to extract the values that represent the locations of the snake and the snacks, to reconstruct the game interface, while at the same time sending game controls to the server to update game state and send it to the client. CourseNana.COM

(2, 17)*(3, 17)*(4, 17)*(5, 17)*(6, 17)*(7, 17)*(8, 17)*(9, 17)*(10, 17)|(18, 1)**(10, 14)**(12, 1)**(4, 1)**(10, 11) CourseNana.COM

The shown game state has two sides, a green side and a blue side separated by a “|” character. The first part (in green) represents the positions of the cubes of the snakes. Snakes are separated by “**” while cubes are separated by “*”. Since we only have one snake, there is no “**” in the first part. The first part has nine “*”- CourseNana.COM

separated positions, which means it represent a single snake with length nine cubes. The second part contains the locations of the snacks separated with a “**”. Each snack is represented by a single position. CourseNana.COM

The client script should receive the game state, parse it to extract the locations of the snake and the snacks, and draw the game interface (like in figure 1). CourseNana.COM

Testing Your Code (Important) CourseNana.COM

After implementing the snake game client-side script, you should use the provide server-side scripts to run the game by running the server (using the command python snake_server.py) and running the client (using the command python snake_client.py). If your implementation is correct, the game window (such as the image in figure 1) will be displayed, and the user will be able to control the snake using keyboard control keys. CourseNana.COM

In addition to the client-side script, you are also required to submit a screenshot of the game window (like figure 1) which pops up if the game is working properly. CourseNana.COM

Deliverables CourseNana.COM

Submit two files: CourseNana.COM

  1. snake_client.py: client-side code of the game which is compatible with the provided CourseNana.COM

    snake_server.py. CourseNana.COM

  2. game_screenshot.png: A screenshot of the game window showing the snake and the CourseNana.COM

    snacks (similar to figure 1). CourseNana.COM

Late submission CourseNana.COM

Late assignments will be accepted for up to two days after the due date, with weekends counting as a single day; the late penalty is 20% of the available marks per day. Lateness is based on the time the assignment is submitted.
Extensions will be granted only by your course instructor. If you have serious medical or compassionate grounds for an extension, you
must take supporting documentation to the Academic Counselling unit of your faculty, who will contact the instructor. CourseNana.COM

Rubric CourseNana.COM

This assignment is out of 40. The assignment marks as follows: CourseNana.COM

  1. Client sends movement commands to the server. 10 marks CourseNana.COM

  2. Client receives the game state and parses it appropriately. 10 marks CourseNana.COM

  3. Client displays the game interface. 20 marks CourseNana.COM

System Requirements CourseNana.COM

For this assignment, you will need to install python 3. You will also need a python package manager like pip or Anaconda to install packages such as: CourseNana.COM

CourseNana.COM

Resources CourseNana.COM

An offline version of the snake game can be found here: CourseNana.COM

https://www.techwithtim.net/tutorials/game-development-with-python/snake-pygame/snake- tutorial-1 CourseNana.COM

Good Luck!  CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
UWO代写,CS3357A代写,COMPUTER NETWORKING代写,Server-driven snake game代写,Python代写,UWO代编,CS3357A代编,COMPUTER NETWORKING代编,Server-driven snake game代编,Python代编,UWO代考,CS3357A代考,COMPUTER NETWORKING代考,Server-driven snake game代考,Python代考,UWOhelp,CS3357Ahelp,COMPUTER NETWORKINGhelp,Server-driven snake gamehelp,Pythonhelp,UWO作业代写,CS3357A作业代写,COMPUTER NETWORKING作业代写,Server-driven snake game作业代写,Python作业代写,UWO编程代写,CS3357A编程代写,COMPUTER NETWORKING编程代写,Server-driven snake game编程代写,Python编程代写,UWOprogramming help,CS3357Aprogramming help,COMPUTER NETWORKINGprogramming help,Server-driven snake gameprogramming help,Pythonprogramming help,UWOassignment help,CS3357Aassignment help,COMPUTER NETWORKINGassignment help,Server-driven snake gameassignment help,Pythonassignment help,UWOsolution,CS3357Asolution,COMPUTER NETWORKINGsolution,Server-driven snake gamesolution,Pythonsolution,