ArthurFischel commited on
Commit
352aefb
1 Parent(s): f131872

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +158 -0
README.md CHANGED
@@ -12,6 +12,164 @@ pinned: true
12
 
13
  ![image info](./mlion.png)
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  # 8/3/2023 rsi
17
  Getting RSI in my hands has been the worst experience of my entire life. It is essentially cost me most of my productive years of my late 20s and early 30s. I am continuing to train with plans set by my physical therapist. And I have not lost hope. My hands aren't bad this time but I can feel the familiar pins and pricks. I guess I'll just take two weeks off of doing anything and see what happens.
 
12
 
13
  ![image info](./mlion.png)
14
 
15
+ Here's your content formatted in Markdown:
16
+
17
+ ```markdown
18
+ # 3/14/2024
19
+
20
+ I have to find some way to map the inputs which are in Biz Hawk format to the Mario gym Format which is a discrete integer action set. I don't want to fine-tune the model with only the gym environment because I don't want to change datasets if I want to use the model to play other games. I'd rather have a stupid mapping function here than go back and redo all my data.
21
+
22
+ This is the Mario Jim environment expected input where each index corresponds to an integer action: [GitHub - gym-super-mario-bros](https://github.com/Kautenja/gym-super-mario-bros/blob/bcb8f10c3e3676118a7364a68f5c0eb287116d7a/gym_super_mario_bros/actions.py#L27C1-L40C2)
23
+
24
+ ```python
25
+ COMPLEX_MOVEMENT = [
26
+ ['NOOP'],
27
+ ['right'],
28
+ ['right', 'A'],
29
+ ['right', 'B'],
30
+ ['right', 'A', 'B'],
31
+ ['A'],
32
+ ['left'],
33
+ ['left', 'A'],
34
+ ['left', 'B'],
35
+ ['left', 'A', 'B'],
36
+ ['down'],
37
+ ['up'],
38
+ ]
39
+ ```
40
+
41
+ This is the output from a script that I used to get controller inputs in the Biz Hawk emulator using LUA. There probably is a better JSON object formatter but I just cracked one together. Note that it also includes player two inputs.
42
+
43
+ ```json
44
+ {
45
+ "P1 Start": false,
46
+ "P1 Down": false,
47
+ "P1 Right": false,
48
+ "P2 Right": false,
49
+ "P2 A": false,
50
+ "P2 L": false,
51
+ "P1 X": false,
52
+ "P1 L": false,
53
+ "P1 Left": false,
54
+ "P1 R": false,
55
+ "P2 Left": false,
56
+ "Power": false,
57
+ "Reset": false,
58
+ "P2 R": false,
59
+ "P2 Up": false,
60
+ "P1 Up": false,
61
+ "P1 Select": false,
62
+ "P2 Select": false,
63
+ "P2 Start": false,
64
+ "P2 X": false,
65
+ "P2 B": false,
66
+ "P2 Y": false,
67
+ "P2 Down": false,
68
+ "P1 Y": false,
69
+ "P1 A": false,
70
+ "P1 B": false
71
+ };
72
+ {
73
+ "P1 Start": false,
74
+ "P1 Down": false,
75
+ "P1 Right": false,
76
+ "P2 Right": false,
77
+ "P2 A": false,
78
+ "P2 L": false,
79
+ "P1 X": false,
80
+ "P1 L": false,
81
+ "P1 Left": false,
82
+ "P1 R": false,
83
+ "P2 Left": false,
84
+ "Power": false,
85
+ "Reset": false,
86
+ "P2 R": false,
87
+ "P2 Up": false,
88
+ "P1 Up": false,
89
+ "P1 Select": true,
90
+ "P2 Select": false,
91
+ "P2 Start": false,
92
+ "P2 X": false,
93
+ "P2 B": false,
94
+ "P2 Y": false,
95
+ "P2 Down": false,
96
+ "P1 Y": false,
97
+ "P1 A": false,
98
+ "P1 B": false
99
+ }
100
+ ```
101
+
102
+ This is the format that the model is trained to output. Notice here that there is a Y button because this is coming from a Super Nintendo.
103
+
104
+ ```json
105
+ {
106
+ "P1 Right": true,
107
+ "P1 Y": true
108
+ }
109
+ ```
110
+
111
+ Instead of collecting more data from an NES tool-assisted speedrun or movie, I'm just going to map the Y buttons to be the B button and the B button to be the A button. In other words: The button used to run and shoot fireballs in SMW will be mapped to the button that runs and shoots fireballs in SMB. And the same will happen for the jump button.
112
+
113
+ Controls reference for SMW: [SMW Controls](https://smwspeedruns.com/Controls)
114
+
115
+ It took a little while and a lot of generations of Chechi P T later, I hammered the output into:
116
+
117
+ ```python
118
+ def map_buttons_to_locations(input_dict):
119
+ button_mapping = {
120
+ "P1 Right": "right",
121
+ "P1 Left": "left",
122
+ "P1 A": "A",
123
+ "P1 B": "A",
124
+ "P1 X": "B",
125
+ "P1 Y": "B",
126
+ "P1 Up": "up",
127
+ "P1 Down": "down"
128
+ }
129
+ concatenated_locations = [button_mapping[key] for key, value in input_dict.items() if value and key in button_mapping]
130
+
131
+ def compare(concatenated_locations):
132
+ result = []
133
+ for idx, complex_move in enumerate(COMPLEX_MOVEMENT):
134
+ if concatenated_locations == complex_move:
135
+ result.append(idx)
136
+ return result if result else ['NOOP']
137
+
138
+ return compare(concatenated_locations)
139
+
140
+
141
+ COMPLEX_MOVEMENT = [
142
+ ['NOOP'],
143
+ ['right'],
144
+ ['right', 'A'],
145
+ ['right', 'B'],
146
+ ['right', 'A', 'B'],
147
+ ['A'],
148
+ ['left'],
149
+ ['left', 'A'],
150
+ ['left', 'B'],
151
+ ['left', 'A', 'B'],
152
+ ['down'],
153
+ ['up'],
154
+ ]
155
+
156
+ # Example usage:
157
+ input_data = {
158
+ # "P1 Left": True,
159
+ "P1 Right": True,
160
+ "P1 A": True,
161
+ "P1 Y": True,
162
+ }
163
+ print(map_buttons_to_locations(input_data))
164
+ ```
165
+ ```
166
+
167
+ You can now copy and paste this Markdown into your blog. Let me know if you need further assistance!
168
+
169
+ Which neatly takes a dictionary input and outputs a single numerical output.
170
+
171
+
172
+
173
 
174
  # 8/3/2023 rsi
175
  Getting RSI in my hands has been the worst experience of my entire life. It is essentially cost me most of my productive years of my late 20s and early 30s. I am continuing to train with plans set by my physical therapist. And I have not lost hope. My hands aren't bad this time but I can feel the familiar pins and pricks. I guess I'll just take two weeks off of doing anything and see what happens.