Skip to content

Instantly share code, notes, and snippets.

@udit-saxena
Last active December 20, 2018 18:54
Show Gist options
  • Save udit-saxena/c90b13b15a992e45ccb3e408ef0a1e6c to your computer and use it in GitHub Desktop.
Save udit-saxena/c90b13b15a992e45ccb3e408ef0a1e6c to your computer and use it in GitHub Desktop.
Describe some data schema
%spark.pyspark
class team_data_vector():
def __init__(self):
self.num_minion_bots = 0
self.is_queen_bot = 0 # 1 if true, 0 if false
self.num_berries_deposited = 0
self.num_kills = 0
self.num_speed_players = 0
self.num_warriors = 0
self.num_gates = 0
self.num_queen_lives_left = 3
def to_data_vector(self):
return "{}, {}, {}, {}, {}, {}, {}, {}".format(self.num_minion_bots, self.is_queen_bot,
self.num_berries_deposited,
self.num_kills, self.num_speed_players, self.num_warriors,
self.num_gates,
self.num_queen_lives_left)
class game_data_vector():
def __init__(self, blue_team_vector, gold_team_vector, game_won_by, win_type):
# self.blue_team = team_data_vector()
self.blue_team = blue_team_vector
# self.gold_team = team_data_vector()
self.gold_team = gold_team_vector
# self.game_won_by = 0 # 0 for blue, 1 for gold
self.game_won_by = game_won_by # 0 for blue, 1 for gold
# self.win_type = 0 # 0 for economy, 1 for military, 2 for gold
self.win_type = win_type # 0 for economy, 1 for military, 2 for gold
def to_data_vector(self):
blue_team_data_vector = self.blue_team.to_data_vector().split(", ")
gold_team_data_vector = self.gold_team.to_data_vector().split(", ")
game_state_data_vector = ", ".join(blue_team_data_vector) + ", " + ", ".join(gold_team_data_vector)
game_state_data_vector += ", {}, {}".format(self.game_won_by, self.win_type)
return game_state_data_vector
class gate_vector():
def __init__(self, x, y, team):
self.x = x
self.y = y
self.team = team # 0 for blue, 1 for gold
def check(self, x, y):
if self.x == x and self.y == y:
return True
else:
return False
def flip_team(self, team):
self.team = team
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment