generated from mwc/lab_retro
it felt more foreign, if that makes sense. The code used in this program was not my work hence, I did not feel as though I completely understood how each agent was doing what it was doing. I guess I can see the value of agents because they really do cut things short and functional. But I much prefer the labs and programs that had more original input for the learning experience! At this stage I don't know if I am comfortable or confident going into the game project but I will try to think more about the agents to understand better.
23 lines
684 B
Python
23 lines
684 B
Python
# asteroid.py
|
|
# ------------
|
|
# By MWC Contributors
|
|
# This module defines an asteroid agent class.
|
|
class Asteroid:
|
|
character = 'O'
|
|
|
|
def __init__(self, position):
|
|
self.position = position
|
|
|
|
def play_turn(self, game):
|
|
width, height = game.board_size
|
|
if game.turn_number % 2 == 0:
|
|
x, y = self.position
|
|
if y == height - 1:
|
|
game.remove_agent(self)
|
|
else:
|
|
ship = game.get_agent_by_name('ship')
|
|
new_position = (x, y + 1)
|
|
if new_position == ship.position:
|
|
game.end()
|
|
else:
|
|
self.position = new_position |