-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.py
51 lines (40 loc) · 1.38 KB
/
demo.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
'''Demo of input making, bot creation, and game start.'''
from livemelee import start_game, Bot, CheckBot, utils
from livemelee.inputs import * # alternative to `from livemelee import Inputs`
# and then using Inputs.down, etc
# one line demo!
# start_game((Bot(), Bot(), None, None)) # two dummy bots will sit in game
# longer demo:
# create a sequence of controller inputs
teabag = [
(down,), # single button input
*wait(5), # unpack list of 5 empty inputs
(center,),
*wait(5)
]
# compose into a longer sequence
toxic_sequence = [ # create another sequence of controller inputs
*repeat(2, *teabag),
*taunt(),
*wait(120)
]
class ReformBot(CheckBot):
# builds on CheckBot funcs and attrs; check them out
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.start()
def stop(self): # replace toxic action with inaction
self.do = lambda:None
def start(self):
self.set_timer(n=150,
do=lambda: self.perform(toxic_sequence),
repeat=True)
dummy = Bot()
bot = ReformBot()
commands = {
# command: function, description
'reform': (bot.stop, 'do nothing'),
'betoxic': (bot.start, 'taunt and teabag'),
}
# run dolphin with bots in ports 2 and 3
start_game((None, dummy, bot, None), commands)