#!/usr/bin/env python # Project outline based on that by David Smallberg used within CS31 at # UCLA. import os import random class Player(): def __init__(self, arena, start_row, start_col): """Create a player within an arena. Each player occupies an arena. Within the arena the player is located at a location indexed by the row and column. The player begins with an age of zero. At the end of each turn the player ages one unit. """ self.arena = arena self.row = start_row self.col = start_col self.age = 0 self.alive = True return def get_row(self): raise Exception("TODO: Trivial.") def get_col(self): raise Exception("TODO: Trivial.") def get_age(self): raise Exception("TODO: Trivial.") def is_alive(self): raise Exception("TODO: Trivial.") def move(self, direction): """Move the player. Valid values for direction are: - 'u' to move up one row - 'd' to move down one row - 'l' to move left one column - 'r' to move right one column """ raise Exception("TODO") def stand(self): raise Exception("TODO: Trivial.") def shoot(self, direction): """Shoot in the specified direction. Each shot travels in a strait line. The first robot in the line of the bullet has a 1/3 chance of being destroyed. Only the first robot line can be effected. """ raise Exception("TODO") def computer_choose_move(self): """Allow the computer to select the move taken by the player.""" raise Exception("TODO") class Robot(): def __init__(self, arena, start_row, start_col): """Create a new robot. Each robot occupies a point within the arena specified by a row and column.""" raise Exception("TODO") def get_row(self): raise Exception("TODO: Trivial.") def get_col(self): raise Exception("TODO: Trivial.") def move(self): """Randomly move the robot up, down, left, or right.""" raise Exception("TODO") class Arena(): def __init__(self, rows, cols): """Create an arena. The arena has the specified number of rows and columns. The upper left corner of the arena has index row 1 and column 1. In an arena with 10 rows and 15 columns, the bottom right corner has index row 10 and column 15. An arena also contains a player and one or more robots.""" raise Exception("TODO") def get_rows(self): raise Exception("TODO: Trivial.") def get_cols(self): raise Exception("TODO: Trivial.") def get_player(self): raise Exception("TODO: Trivial.") def get_num_robots(self): raise Exception("TODO: Trivial.") def get_num_robots_at(self, row, col): """Return the number of robots currently in the arena.""" raise Exception("TODO") def add_robot(self, row, col): """Add a new robot into the arena.""" raise Exception("TODO") def add_player(self, row, col): """Add a player into the arena.""" raise Exception("TODO") def destroy_robot(self, row, col): """Attempt to destroy robot at specified location. Return True if a robot was destroyed. Otherwise return false.""" raise Exception("TODO") def move_robots(self): """Move all robots located in the arena.""" raise Exception("TODO") def display(self, message): """Display the arena. At each cell print: - 'p' if the player is at that location, - number between 1 and 9 specifying number of robots in that cell (if more than 9 robots are in one cell print 9), and - space if nothing is located in the cell. Also display the specified message.""" raise Exception("TODO") class Game(): def __init__(self, rows, cols, num_robots): """Create a new game. Game will take place in an arena with the specified size. Populate the arena with num_robots randomly placed robots and a randomly placed player. """ raise Exception("TODO") def play(self): """Play the game!""" raise Exception("TODO") if __name__ == '__main__': g = Game(10, 10, 3) g.play()