Placement Assignment for Games 101

This is an assignment which is designed to help understand your general level of comfort and familiarity with Python so that a tutor can start working with you from the correct part of the course.

You can also use it as a way to review or test your skills as it covers all the material from the course!

There are three questions in the assignment and it's designed to take an hour to complete for an experienced developer. If you don't finish, don't worry - finishing with a perfect or near-perfect score means you don't need to take this course! The questions have extensions to test additional concepts, which should be completed.

Question 1 (10 minutes)

Write a short program which prints the numbers 1 to 100. However, for numbers which are multiples of 3, such as 3, 6, or 12, it should instead print Fizz. For numbers which are multiples of 5, such as 5 or 20, it should print Buzz. For numbers which are multiples of both 3 and 5, it should print FizzBuzz.

Extension 1: Change the function fizzbuzz such that it can operate over any given range of numbers, with a variable step size. For example, if given start=100, end=0, step=-1, the function should go from 100 to 1.

Extension 2: Change the function fizzbuzz such that it takes an arbitrary number of pairs of words and numbers. For example, if given Fizz, 3, Buzz, 5 and Pop, 10, it will print FizzBuzzPop on the number 10.

You can use the following code to start with.

def fizzbuzz():
  pass

if __name__ == "__main__":
  fizzbuzz()

Question 2 (20 minutes)

Make a simple game of rock-paper-scissors. The game should work as follows:

  • The player is prompted for a choice of rock-paper-scissors.
  • The computer logs their choice.
  • The winner is declared and logged out.
  • The game prints out how many points the player and the computer have.
  • The game gives players a choice whether to continue with the game or quit.

You can use this code as the basis of the assignment:

import random

def main():
  pass

if __name__ == "main":
  main()

Question 3 (30 minutes)

A level of a game is a 10x10 grid, represented as follows:

----------
----------
----------
----------
----------
----------
----------
----------
----------
----------

The player in this game should be represented as an @ glyph. We will move the player around the map from a list of instructions given in a file with the following format:

0,0
left
right
down
up

The first line is a header, which tells us the initial position of the player on the map as x and y coordinates, where 0,0 is the top-left character of the map. The subsequent lines are instructions which say how the player should move. There are a couple of rules:

  • The player always moves 1 square at a time.
  • If a move would take a player off the edge of the map, it is not made.

Your task is to print out the final state of the map with the player's position marked with an @ sign. You can choose whether or not to print out intermediary steps.

Extension: Let there be more than one player on the grid. The file format changes slightly:

0,0
1,0
0,left
0,right
1,up

All header lines which represent positions create a new player with the next id available, starting from 0. I.e. the first player created is 0, the second is 1, and so on.

If a move would cause a player to collide with another player, it is not taken, just like if they'd go off the edge of the map.

Once again your task is to print out the final state of the grid.