-
Notifications
You must be signed in to change notification settings - Fork 7
/
data_collection_recording.py
180 lines (137 loc) · 5.47 KB
/
data_collection_recording.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env python3
#
# data_collection_recording.py
# Main entrypoint for datacollection (for recording videos with different videos)
#
import os
from recording import play_and_record_episodes
from time import sleep
import random
AGREEMENT = """
Machine learning versus machine learning: Case of aimbots.
Organizer: Anssi Kanervisto ([email protected])
School of Computing, University of Eastern Finland
------------------------------------------------------------------------------
BACKGROUND
Terms:
"Cheating": When a video-game player uses software ("cheat") to gain
an unfair advantage over other players.
"Aimbot": Particular cheat which assists player with aiming at
enemy players.
Purpose of this study is two-fold:
1) Detecting aimbot software from player's mouse
movement using machine learning techniques
2) Applying machine learning techniques to create
aimbot that is not distinguishable from human players.
Goal is to obtain public knowledge on such cheats, which can then
be used to create better anti-cheating software.
What data will be collected and how:
In these experiments, you will play a game of Doom (1993)
against computer-players. In some of the games, your aim
will be assisted by software ("aimbot").
The software will record your keypresses and mouse movement
in the game.
A hardware identifier of your machine will be included in the data.
All data will be anonymous and no private information will be
collected.
How this data will be used:
The recorded data will be used to...
1) ... evaluate the quality of the aimbots against human judges.
The (anonymous) recorded gameplay will be shown to experienced
game server admins and they will judge if gameplay should be
considered suspicious (i.e. player is using a cheat) or not.
This data may be released to the public.
This data may be used in future research.
Requirements:
- A separate mouse (not a trackpad/mousepad)
- 20 minutes of uninterrupted time (you can not pause the experiment)
------------------------------------------------------------------------------
AGREEMENT
By agreeing you:
- ... confirm you recognize what data will be collected and how
it will be used (scroll up).
- ... are 18 years old or above.
- ... fulfil the requirements (see above).
- ... acknowledge there is no compensation.
- ... acknowledge your participation is voluntary and you may withdraw at
any point before end of the experiment.
Input 'I agree' to continue, "quit" to close this software."""
INSTRUCTIONS = """
INSTRUCTIONS
This experiment will take 20 minutes, and consists
of four 5-minute games of Doom (1993).
Your goal is to score frags by shooting the enemies.
You will find different weapons on the map, as well
ammo for them and health/armor kits.
For each game you will aimbot on or off, automatically
set by this software. If aimbot is enabled, your aim will
"home in" in to enemy targets once they are close enough
to your crosshair.
Try to appear as innocent as possible. That is: even with
aimbot enabled, try to appear as if no aimbot were enabled.
Pretend you are playing against other human players and
you are cheating with the aimbot, and you have to avoid
getting caught for using a cheat.
Once all games are finished, you will have to provide
the host of the experiment with the files this records.
NOTE: Avoid opening the menu (ESC) and unfocusing the window
(clicking outside the game window or changing window)
BUTTONS
WASD: Forward, left, backward and right
SHIFT: Run (hold down to move faster)
Mouse: Aim
Left-mouse click: Shoot
Scroll up/down: Change weapon
Note that you can also aim up/down.
Press ENTER to start the game"""
AFTER_GAMES = """
Games finished.
[NOTE] There is no data uploading in shared code.
Thank you for participating!
"""
NUMBER_OF_EPISODES = 4
# 5 minutes
EPISODE_LENGTH = 35 * 60 * 5
MAPS = ["map03"] * NUMBER_OF_EPISODES
AIMBOTS = [None, "ease_light", "ease_strong", "gan_group0"]
# Shuffle the aimbots so the ordering is not known
random.shuffle(AIMBOTS)
def main_data_collection():
os.system("cls")
print(AGREEMENT)
agreement = ""
while agreement != "i agree" and agreement != "quit":
agreement = input(" >>> ").lower()
if agreement == "quit":
exit(0)
# Continue to instrunctions etc
os.system("cls")
print(INSTRUCTIONS)
input()
# Play games to create recordings
play_and_record_episodes(
NUMBER_OF_EPISODES,
MAPS,
AIMBOTS,
"recording",
timeout=EPISODE_LENGTH,
record_video=True
)
print(AFTER_GAMES)
if __name__ == '__main__':
import sys
import glob
import shutil
original_dir = os.path.abspath(os.curdir)
# Workaround for pyinstaller:
# Some of the local files are in
# the temp folder used by pyinstaller,
# so we need to navigate there.
# Stackoverflow #57480958
if hasattr(sys, "_MEIPASS"):
os.chdir(sys._MEIPASS)
main_data_collection()
# Move all data back to original location
recordings = glob.glob("*_episode*")
for recording in recordings:
shutil.move(recording, os.path.join(original_dir, os.path.basename(recording)))