monkeymusic 0.0.14 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGZlYTI2NDg2MWViM2MwNjM2MzgwMWIxZjgxZWQxNDEwNzNhNzAxNg==
4
+ OGIwZjAyMDZjNTgxZjc3NzQzZGM0ZjYzOWRkZmE5YjJjYTYwNzJkMA==
5
5
  data.tar.gz: !binary |-
6
- YzU5YWI1NGM4ZDQyNjQxNzk5NWQ2M2M4MTU1MWYzNjg2MzA5YmNjOA==
6
+ NjkwYjEzMjU4ODNhZjAyMGE2ZjJmZjBhOThlMTYxMjI4MDk4NDQ0NA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzIxNGE3NDdmMDBlYzhiZTdjYjViMmIzMDU5NTM2MmMxNDgwMWVlYzk5NGU1
10
- NDhmNjU0NWYzNTc0NGRmZGVkOTcwZjRiYjlmZTg1MDM2MGE5ZmY0MGI4Y2Mw
11
- YmVmZjM2MTRkZGI5MzhlOTA1ZTZlZjViMGQ3ODJmMDQ3OTg1YjM=
9
+ ZTlhN2E1ZGFkZWNkNDI1YjEyZjYwNmJmNWI5NjdkYzUxNThmYjE1NTE0MWJk
10
+ ZDc2ZWU3NzkyOGI0NWUwM2RkZGMzOTBjOWQxMDMxMTYyYjRiZmE2M2NjMDk2
11
+ YjRmMDRlMTAyMmE0ODZhYTc4ZTU5MjFiMzJhZjgzNzhmZjFjMTY=
12
12
  data.tar.gz: !binary |-
13
- NjY3NDllMDI3MTc1YzM4OTVhODI4NDE0OTY1MjMyOTQxMzQ5MmZmOTU1NmM1
14
- ZDhiMTE1Mzk0NjgzZjY3ZWIxZTcyNWY2NmNhMGIwMjI1MjRiMGFiNzJhMmJk
15
- YTNmM2ExYTI0ODg1ZTVlMjE3MTY1NmNmZjU4Zjc3MjgyMjI4Yjg=
13
+ NzE0YzRmYTllNjA0MzgyMTVlMzVjMjk0MzMwZDU0MWY1NjJkYmMwNTI4NmVj
14
+ NGQwNzY0YjkwMTY5MmRlOGE3YzkzMDUwNjY3ODYyNTA2N2VlMDQyMGEzZGNj
15
+ ZjA1NzIwMjNmMDMyODBiNWUzNGY5YjhjN2RiODE4MWU4ZTk3YTQ=
data/Gemfile CHANGED
@@ -8,4 +8,3 @@ end
8
8
  gem 'hallon'
9
9
  gem 'em-websocket'
10
10
  gem 'json'
11
- gem 'rack'
data/README.md CHANGED
@@ -5,7 +5,7 @@ Monkey Music Challenge
5
5
  Introduction
6
6
  ------------
7
7
 
8
- The Spotify backend is consists of a multitude of individual services. One such service is the music recommendation service, which is responsible for finding and recommending new tracks to Spotify users, according to their music taste.
8
+ The Spotify backend consists of a multitude of individual services. One such service is the music recommendation service, which is responsible for finding and recommending new tracks to Spotify users, according to their music taste.
9
9
 
10
10
  The music recommendation service has lately been getting some pretty negative feedback from users. The word out on Twitter is that even monkeys could find better music recommendations!
11
11
 
@@ -13,37 +13,43 @@ Therefore, upper management has made an informed decision that the next version
13
13
 
14
14
  You have therefore decided to write a computer program that helps monkeys find good track recommendations for Spotify users.
15
15
 
16
- This is all entirely fictional of course.
16
+ This is all entirely fictional of course. :)
17
17
  {: .tip}
18
18
 
19
19
  Task summary
20
20
  ------------
21
21
 
22
- The task consists of implementing a program to play the Monkey Music game. The goal of the game is to score points by gathering track recommendations and giving them to a Spotify user.
22
+ The task consists of implementing a program to play the Monkey Music game.
23
+ The goal of the game is to score points by gathering track recommendations
24
+ for a Spotify user.
23
25
 
24
26
  The game
25
27
  --------
26
28
 
27
- Every game of Monkey Music is broken up into a number of turns.
29
+ The game takes place in a two dimensional level. The level is a rectangular
30
+ grid of cells.
28
31
 
29
- Every turn, your program will be executed and fed information about the current state of the level by reading from `stdin`. Your program responds by printing one command to `stdout`. The command decides what your monkey does during the current turn.
32
+ Your program will move a monkey around the level by printing commands
33
+ to `stdout`. Before every command, your program will be fed information about the current state
34
+ of the game and level through `stdin`.
30
35
 
31
- Fate decides the order in which monkeys execute their commands in a turn.
32
- {: .tip}
36
+ The game is divided into turns. Upon each turn, every monkey on the level gets
37
+ to execute one command.
33
38
 
34
39
  Before every turn, execution of your program starts. After every turn, execution of your program stops.
40
+ {: .tip}
35
41
 
36
42
  Rules
37
43
  -----
38
44
 
39
45
  ### Scoring
40
46
 
41
- Your monkey will pick up tracks and deliver them to a user.
47
+ Your mission is to move around the level, pick up tracks, and deliver them
48
+ to a Spotify user.
42
49
 
43
- When a track is delivered, you will recieve a score according to how well the track fits the music taste of the user. The player with the highest score at the end of the game will be the winner.
44
-
45
- You should try to get as high a score as possible.
46
- {. tip}
50
+ Each track is worth a certain amount of points. Every time you deliver a
51
+ track, these points are added to your score. The player with the highest score
52
+ at the end of the game is the winner.
47
53
 
48
54
  ### Turn limit
49
55
 
@@ -53,134 +59,113 @@ The game ends when the turn limit is reached.
53
59
 
54
60
  ### Time limit
55
61
 
56
- Every time your program is executed, the execution time will be measured. Every level has a total time limit, that your program should not exceed.
62
+ Every time your program is executed, the execution time will be measured. Every level has a total time limit that your program should not exceed.
57
63
 
58
- If your execution time reaches the time limit, your monkey will run out of energy and fall asleep for `5` turns. Afte sleeping for `5` turns, the remaining execution time of your program will be replenished.
64
+ If your execution time reaches the time limit, your monkey will run out of
65
+ energy and fall asleep for `5` turns, after which your execution time will
66
+ be replenished.
59
67
 
60
68
  ### Carrying capacity
61
69
 
62
- The number of tracks your monkey can pick up and hold at any given time is called carrying capacity.
70
+ Your monkey must pick up tracks and carry them to a user. The number of
71
+ tracks your monkey can carry at any given time is called the carrying capacity.
72
+
73
+ When you have picked up enough tracks, you must deliver them to a user
74
+ before picking up more.
63
75
 
64
76
  The carrying capacity of your monkey is different for every level.
77
+ {: .tip}
65
78
 
66
79
  Level layout
67
80
  ------------
68
81
 
69
- The level is a `n x m` grid of cells. It is sent to the standard input of your program.
82
+ The level is a `n x m` grid of cells.
83
+
84
+ It is sent to the standard input of your program as `m` lines, with `n`
85
+ comma-separated cells each.
86
+
87
+ Each cell contains an ASCII string, which can be one of the following
88
+ things:
70
89
 
71
- Each cell contains one of the following things:
72
90
 
73
91
  ### Monkeys
74
92
 
75
- * ASCII: `M[id]`
93
+ **ASCII:** `M[id]`
76
94
 
77
95
  You, and your competitors each have your own monkey to control.
78
96
  Every monkey is identified by a unique numerical id.
79
97
 
80
98
  ### Walls
81
99
 
82
- * ASCII: `#`
100
+ **ASCII:** `#`
83
101
 
84
102
  Walls are inanimate objects that monkeys cannot pass through.
85
103
 
86
104
  ### Tracks
87
105
 
88
- * ASCII: `[URI]`
106
+ **ASCII:** `spotify:track:[hash]`
89
107
 
90
- Tracks are identified by their unique Spotify URI. Every track URI starts with `spotify:track:`, followed by `22` alphanumerical characters.
108
+ Tracks are identified by their unique Spotify URI.
91
109
 
92
- Example: `spotify:track:5H85hOp2oMlhMh9JlkdJP2`.
110
+ Every track URI starts with `spotify:track:`, followed by `22`
111
+ alphanumerical characters:
112
+
113
+ spotify:track:5H85hOp2oMlhMh9JlkdJP2
93
114
 
94
115
  Tracks can be picked up and carried around by monkeys.
95
116
 
96
- ### The User
117
+ ### User
97
118
 
98
- * ASCII: `U`
119
+ **ASCII:** `U`
99
120
 
100
- The user is where monkeys deliver their track recommendations. Monkeys are
101
- scored for every track delivered to the user, according to how well the track fits the user's music taste.
121
+ The Spotify user is where monkeys deliver their track recommendations. Monkeys are
122
+ scored for every track delivered to the user, according to how well the track fits
123
+ the user's music taste.
102
124
 
103
125
  ### Empty
104
126
 
105
- * ASCII: `[SPACE]`
127
+ **ASCII:** `_`
106
128
 
107
- Nothing to do here.
129
+ Empty cells are represented by an underscore.
108
130
 
109
131
  A cell can only contain one thing at any time.
110
132
  {: .tip}
111
133
 
112
- User toplists
113
- -------------
114
-
115
- How well tracks match the music taste of a user is decided by the user's toplists.
116
-
117
- Every Spotify user has a track toplist, an album toplist and an artist toplist. Every entry in a toplist is a comma-separated string of metadata.
118
-
119
- The toplists are sent to the standard input of your program on the following formats:
120
-
121
- ### Track toplist
122
-
123
- First an integer `n`, followed by `n` lines of track metadata entries.
124
-
125
- n
126
- track,album,artist,year
127
- track,album,artist,year
128
- ...
129
-
130
- ### Album toplist
131
-
132
- First an integer `n`, followed by `n` lines of album metadata entries.
133
-
134
- [n]
135
- album,artist,year
136
- album,artist,year
137
- ...
138
-
139
- ### Artist toplist
140
-
141
- First an integer `n`, followed by `n` lines of artist metadata entries.
142
-
143
- n
144
- artist
145
- artist
146
- ...
147
-
148
- ### Disliked artist toplist
134
+ Score system
135
+ ------------
149
136
 
150
- You will also receive a list of artists that the user does not like.
137
+ Every Spotify user has a number of toplists:
151
138
 
152
- First an integer `n`, followed by `n` lines of artist entries.
139
+ * Top tracks
140
+ * Top albums
141
+ * Top artists
153
142
 
154
- n
155
- artist
156
- artist
157
- ...
143
+ In the Monkey Music game, every user also has another toplist:
158
144
 
159
- Spotify does not actually keep toplists of disliked artists. ;)
160
- {: .tip}
145
+ * Top disliked artists
161
146
 
162
- Score system
163
- ------------
147
+ How well tracks match the music taste of a user is decided by the user's toplists.
164
148
 
165
- Each track is scored according to the user toplists by placing it into 1 out of 5 score tiers.
149
+ Each track belongs to one of 5 score tiers. There are three positive
150
+ tiers: `1`, `2` and `3`. There are two negative tiers, `-1` and `-2`.
166
151
 
167
- There are three positive tiers: `1`, `2` and `3`. There are two negative tiers, `-1` and `-2`
152
+ If a track fulfills a negative criteria, it is immediately
153
+ placed into the corresponding tier. This differs from the positive tiers.
154
+ For every positive criteria that matches, the track climbs one tier.
168
155
 
169
156
  The following criteria decide which tier a track belongs to:
170
157
 
171
158
  ### Tier -2: Disliked artist
172
159
 
173
- The track artist is in the user's disliked artist toplist. To recommend one of
174
- these tracks is an epic fail.
160
+ The track artist is among the users's top disliked artists.
175
161
 
176
162
  ### Tier -1: Played to death
177
163
 
178
- The track is already in the user's track toplist. There is not much point
179
- in recommending it.
164
+ The track is already among the user's top tracks.
180
165
 
181
166
  ### Tier += 1: Favorite artist
182
167
 
183
- The track artist is in the user's artist toplist.
168
+ The track artist is among the user's top artists.
184
169
 
185
170
  ### Tier += 1: Favorite album
186
171
 
@@ -190,98 +175,92 @@ If track album in the user's album toplist.
190
175
 
191
176
  The year of the track belongs to the user's top decade.
192
177
 
193
- This is an interesting one. Every user has a top decade, which is the decade that is most prominent in the user's track toplist and album toplist.
178
+ Every user has a top decade, which is the decade that is most prominent in the user's track toplist and album toplist.
194
179
 
195
180
  ### Tally
196
181
 
197
182
  Your track will be scored according to it's tier:
198
183
 
199
- **Tier -2:** -16 points
200
-
201
- **Tier -1:** -4 points
202
-
203
- **Tier 1:** 4 points
204
-
205
- **Tier 2:** 16 points
184
+ * **Tier -2:** -16 points
185
+ * **Tier -1:** -4 points
186
+ * **Tier 1:** 4 points
187
+ * **Tier 2:** 16 points
188
+ * **Tier 3:** 64 points
206
189
 
207
- **Tier 3:** 64 points
208
-
209
- Tier 3 tracks are obviously very valuable, so be on the lookout for these.
190
+ Tier 3 tracks are obviously very valuable. Be on the lookout for these.
210
191
  {: .tip}
211
192
 
212
193
  Game progression
213
194
  ----------------
214
195
 
215
- ### Initialization phase
216
-
217
- The game consists of two different phases.
196
+ ### Init phase
218
197
 
219
- The first phase is the initialization phase, it occurs once every game.
198
+ The first phase of the game is the init phase, which occurs once every game.
220
199
 
221
- During the initialization phase, your program will be given information about the level that will be useful during the entire course of the game.
200
+ During the init phase, your program will be given information about the level that will be useful during the entire course of the game.
222
201
 
223
202
  The information that can be read from `stdin` during the `init` phase is:
224
203
 
225
204
  INIT\n
226
- M[id]\n
227
- [WIDTH]\n
228
- [HEIGHT]\n
229
- [TURN LIMIT]\n
230
- [n]\n
231
- [TRACK],[ALBUM],[ARTIST],[YEAR]\n
232
- [n]\n
233
- [ALBUM],[ARTIST],[YEAR]\n
234
- [n]\n
235
- [ARTIST]\n
236
- [n]\n
237
- [ARTIST]\n
238
-
239
- * The string `"INIT"`
240
- * The id of your monkey
241
- * The `width` of the map
242
- * The `height` of the map
243
- * The `turn limit` of the game
244
- * The number of entries in the user's track toplist
245
- * The track toplist entries
246
- * The number of entries in the user's album toplist
247
- * The album toplist
248
- * The number of entries in the user's artist toplist
249
- * The artist toplist
250
- * The number of entries in the user's disliked artist toplist
251
- * The disliked artist toplist
252
-
253
- After the initialization phase, execution of your program will stop until the next phase.
254
-
255
- Make sure to keep the data from the initialization phase in a persistent cache!
205
+ M[id]\n // id of your monkey
206
+ [WIDTH]\n // width of the level
207
+ [HEIGHT]\n // height of the level
208
+ [TURN LIMIT]\n // turn limit of the game
209
+ [n]\n // the number of entries in the track toplist
210
+ [TRACK],[ALBUM],[ARTIST],[YEAR]\n // n rows of track metadata
211
+ [n]\n // the number of entries in the album toplist
212
+ [ALBUM],[ARTIST],[YEAR]\n // n rows of album metadata
213
+ [n]\n // the number of entries in the artist toplist
214
+ [ARTIST]\n // n rows of artist metadata
215
+ [n]\n // the number of entries in the disliked artist toplist
216
+ [ARTIST]\n // n rows of disliked artist metadata
217
+
218
+ After the init phase, execution of your program will stop. Make sure
219
+ to keep the data from the init phase in a persistent cache!
256
220
  {: .tip}
257
221
 
258
- ### Turn phases
222
+ ### Turns
223
+
224
+ After the init phase, a number of turns will follow.
259
225
 
260
- After the initialization phase, a number of turn phases will follow.
226
+ The total number of turns is decided by the turn limit of the level.
261
227
 
262
- The total number of turn phases is decided by the turn limit of the level.
228
+ Every turn, your program will issue one command, but first it will read
229
+ the current state of the game.
263
230
 
264
- The information that can be read from `stdin` during a turn phase is:
231
+ The information that can be read from `stdin` during a turn is:
265
232
 
266
233
  TURN\n
267
- M[ID]\n
234
+ M[ID]\n // id of your monkey
268
235
  [TURN NUMBER]\n
269
236
  [REMAINING CAPACITY]\n
270
- [REMAINING TIME]\n
271
- [n]\n
272
- [URI],[TRACK],[ALBUM],[ARTIST],[YEAR]\n
273
- [LEVEL]\n
274
-
275
- * The string `"TURN"`
276
- * The id of your monkey
277
- * The turn number
278
- * The remaining carrying capacity of your monkey
279
- * The remaining execution time of your program
280
- * The number of available metadata lookup results
281
- * Your metadata lookup results from the previous turn
282
- * The current state of the level
283
-
284
- After reading the turn information from `stdin`, your program will print a command for your monkey to `stdout`.
237
+ [REMAINING TIME]\n // milliseconds
238
+ [BOOST COOLDOWN]\n // number of turns until boost ready
239
+ [n]\n // amount of metadata lookup results
240
+ [URI],[TRACK],[ALBUM],[ARTIST],[YEAR]\n // n rows of metadata lookup results
241
+ [CELL],[CELL],..,[CELL]\n // [height] rows of comma separated level cells
242
+
243
+ An example turn could look like:
244
+
245
+ TURN\n
246
+ M2\n
247
+ 1\n
248
+ 3\n
249
+ 4503\n
250
+ 0\n
251
+ 1\n
252
+ spotify:track:5H85hOp2oMlhMh9JlkdJP2,Condemnation,Depeche Mode,Songs Of Faith And Devotion,1993\n
253
+ _,_,_,_,_,_\n
254
+ _,#,#,_,_,_\n
255
+ _,#,spotify:track:5H85hOp2oMlhMh9JlkdJP2,_,_,_\n
256
+ _,_,_,_,_,U\n
257
+ M2,_,_,_,_,_\n
258
+ _,_,_,spotify:track:4CARtDIJS87fOmWb1RxLKK,_,_\n
259
+ #,_,_,_,_,_\n
260
+ _,_,_,_,_,_\n
261
+ _,#,spotify:track:0S8LgLoseDB6W2HWd1ym6P,_,_,_\n
262
+ _,#,#,#,#,_\n
263
+ _,_,_,_,_,_\n
285
264
 
286
265
  Monkey commands
287
266
  ---------------
@@ -291,52 +270,52 @@ In each turn of the game, every monkey executes one command.
291
270
 
292
271
  Commands which the monkeys can execute are:
293
272
 
294
- [MOVE] | [METADATA LOOKUP] | B,[COMMAND],[COMMAND],[COMMAND]
273
+ [MOVE] | [URI LOOKUP] | B,[COMMAND],[COMMAND],[COMMAND]
295
274
 
296
- ### Move
275
+ Fate decides the order in which monkeys execute their commands during a
276
+ turn.
277
+ {: .tip}
278
+
279
+ ### Movement
297
280
 
298
281
  You can command the monkey to move in the four cardinal directions using
299
282
  the commands:
300
283
 
301
- W
302
-
303
- Moves the monkey one cell to the left.
304
-
305
- E
306
-
307
- Moves the monkey one cell to the right.
308
-
309
- N
284
+ * **North:** `N`
285
+ * **West:** `W`
286
+ * **East:** `E`
287
+ * **South:** `S`
310
288
 
311
- Moves the monkey one cell up.
312
-
313
- S
314
-
315
- Moves the monkey one cell down.
289
+ Each of the above command causes the monkey to attempt to move one cell in
290
+ the specified direction.
316
291
 
317
292
  Trying to move to an already occupied cell will casue the monkey to stand
318
293
  still for the duration of the round.
319
294
  {: .tip}
320
295
 
321
- ### Metadata lookup
296
+ ### URI lookup
322
297
 
323
- You can lookup the metadata of a track on the level by issuing a metadata
298
+ You can lookup the metadata of a track on the level by issuing a URI
324
299
  lookup command:
325
300
 
326
- spotify:track:......................
301
+ spotify:track:[hash]
327
302
 
328
- You will recieve the result of the metadata lookup the following turn.
303
+ You will recieve the result of the URI lookup in the next turn input.
329
304
 
330
- Your monkey must every turn choose between moving and looking up the metadata of a track!
305
+ Your monkey must every turn choose between moving and looking up the
306
+ metadata of a track.
331
307
  {: .tip}
332
308
 
333
309
  ### Boost
334
310
 
335
311
  B,[COMMAND],[COMMAND],[COMMAND]
336
312
 
337
- Once every game, the monkey can issue a boost command and then issue three other comma separated commands during the same turn.
313
+ You can issue a boost command and then issue three other comma separated commands during the same turn.
314
+
315
+ After using boost, the command will be on cooldown before being available
316
+ for use again.
338
317
 
339
- You can only issue the boost command once every game. Choose wisely!
318
+ Keep a close watch on the boost cooldown, use your boost wisely!
340
319
  {: .tip}
341
320
 
342
321
  The turn input after having issued this command:
@@ -351,8 +330,9 @@ could look like:
351
330
  1
352
331
  4529
353
332
  2
354
- spotify:track:5H85hOp2oMlhMh9JlkdJP2,TODO,TODO,TODO,TODO
355
- spotify:track:5H85hOp2oMlhMh9JlkdJP2,TODO,TODO,TODO,TODO
333
+ spotify:track:5H85hOp2oMlhMh9JlkdJP2,Condemnation,Depeche Mode,Songs Of Faith And Devotion,1993
334
+ spotify:track:spotify:track:3NYCaxkggl0Hh8vQptSUvV,Enola Gay - 2003 - Remaster,Orchestral Manoeuvres In The Dark
335
+ ,Organisation,2003
356
336
 
357
337
  ### Picking up tracks
358
338
 
@@ -382,15 +362,21 @@ To install the challenge runtime:
382
362
 
383
363
  > gem install monkeymusic
384
364
 
385
- To get started quickly:
365
+ To get some demo code to start from:
386
366
 
387
367
  > monkeymusic demo
388
368
 
389
369
  To see something on the screen:
390
370
 
391
- > monkeymusic -p demo_player
371
+ > monkeymusic -p demo_players/ruby/runme
392
372
 
393
- You can probably learn a lot about the game from reading the `demo_player`.
373
+ For more info:
374
+
375
+ > monkeymusic --help
376
+
377
+ You can probably reuse some of the code from the demo players.
378
+ Specifically if you do not want to spend too much time on parsing and
379
+ persisting data between rounds.
394
380
 
395
381
  Handing in
396
382
  ----------
@@ -398,4 +384,7 @@ Handing in
398
384
  Your competition entry is to be handed in as a zip archive containing
399
385
  everything needed to run your program.
400
386
 
401
- When unpacked, your program should be runned through an executable file called `runme`.
387
+ When unpacked, your program should be runned through an runnable file called `runme`.
388
+
389
+ If your program requires some sort of installation, such as compilation,
390
+ this should be encoded in another runnable file called `install`.