Skip to content

Commit 5e96b0f

Browse files
committed
Extend the abilities of the fashion test
1 parent 5c428b1 commit 5e96b0f

File tree

2 files changed

+7795
-2
lines changed

2 files changed

+7795
-2
lines changed

tests/fashion/bot.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from __future__ import annotations
1+
import csv
2+
from random import choice, randint
23

34
from rlbot import flat
45
from rlbot.config import load_player_loadout
@@ -7,13 +8,53 @@
78

89
class Fashion(Bot):
910
standard_loadout: flat.PlayerLoadout
11+
last_tick = 0
12+
items: dict[str, list[int]] = {}
1013

1114
def initialize(self):
15+
with open("./items.csv") as f:
16+
reader = csv.reader(f)
17+
for row in reader:
18+
if row[1] not in self.items:
19+
self.items[row[1]] = []
20+
21+
self.items[row[1]].append(int(row[0]))
22+
1223
self.standard_loadout = load_player_loadout("../necto/loadout.toml", self.team)
1324
self.set_loadout(self.standard_loadout)
1425

1526
def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
16-
return flat.ControllerState()
27+
if packet.match_info.match_phase != flat.MatchPhase.Active:
28+
return flat.ControllerState()
29+
30+
if packet.match_info.frame_num - self.last_tick >= 2 * 120:
31+
loadout = flat.PlayerLoadout(
32+
team_color_id=randint(0, 69),
33+
custom_color_id=randint(0, 104),
34+
car_id=choice(self.items["Body"]),
35+
wheels_id=choice(self.items["Wheels"]),
36+
decal_id=0,
37+
boost_id=choice(self.items["Boost"]),
38+
antenna_id=choice(self.items["Antenna"]),
39+
hat_id=choice(self.items["Hat"]),
40+
paint_finish_id=choice(self.items["PaintFinish"]),
41+
loadout_paint=flat.LoadoutPaint(
42+
randint(0, 18),
43+
randint(0, 18),
44+
randint(0, 18),
45+
randint(0, 18),
46+
randint(0, 18),
47+
randint(0, 18),
48+
randint(0, 18),
49+
randint(0, 18),
50+
),
51+
)
52+
53+
self.logger.info(f"State setting new loadout")
54+
self.set_loadout(loadout)
55+
self.last_tick = packet.match_info.frame_num
56+
57+
return flat.ControllerState(throttle=1, steer=1)
1758

1859

1960
if __name__ == "__main__":

0 commit comments

Comments
 (0)