-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDigliBot.py
82 lines (66 loc) · 2.29 KB
/
DigliBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from utils import output
from strategy import StrategyManager
import boost
import emergency
import car
import ball
'''
Hi! You can use this code as a template to create your own bot.
Also if you don't mind writing a blurb about your bot's strategy
you can put it as a comment here. I'd appreciate it, especially if
I can help debug any runtime issues that occur with your bot.
__insert_later__
'''
# Your real name: Elliot Jalgard
# Contact Email: __insert_later__
# Can this bot's code be shared publicly: Yes
# Can non-tournment gameplay of this bot be displayed publicly: Yes
"""
# runner.py setup
############ DigliBot
import sys
import os
sys.path.insert(0, os.path.abspath("./diglibot"))
from diglibot import DigliBot
from diglibot import PassiveAgent
agent1 = DigliBot.agent('blue')
agent2 = DigliBot.agent("orange")
# agent1 = PassiveAgent.agent('blue')
# agent2 = PassiveAgent.agent('orange')
############ /DigliBot
"""
class agent:
def __init__(self, team):
self.team = team
if team == 'blue':
self.player = car.Blue()
self.opponent = car.Orange()
else:
self.player = car.Orange()
self.opponent = car.Blue()
self.ball = ball.Ball()
self.boost_tracker = boost.BoostTracker(self.player, self.opponent)
self.strategy_manager = StrategyManager(self)
self.previous_output = output()
def get_bot_name(self):
return "DigliBot"
def get_output_vector(self, input):
self.player.read_input(input)
self.opponent.read_input(input)
self.ball.read_input(input)
self.player.update()
self.opponent.update()
self.player.update_cached_calculations(self)
self.opponent.update_cached_calculations(self)
self.ball.update()
self.boost_tracker.update()
self.strategy_manager.update()
self.previous_output = self.strategy_manager.get_output()
return self.previous_output.generate_vector()
def noflip(self):
return self.trigger_emergency(emergency.NoFlip(self))
def dodge(self, target):
return self.trigger_emergency(emergency.DodgeForSpeed(self, target))
def trigger_emergency(self, emergency):
self.strategy_manager.emergency_strategy = emergency
return emergency.get_output()