monkeymusic 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +401 -0
- data/bin/monkeymusic +2 -2
- data/bin/monkeymusic-browser +6 -0
- data/levels/demo_level.rb +5 -5
- data/levels/testlevel.rb +6 -6
- data/lib/monkey_music.rb +0 -1
- data/lib/monkey_music/metadata/track.rb +3 -3
- data/lib/monkey_music/player.rb +8 -4
- data/lib/monkey_music/runner.rb +12 -23
- data/lib/monkey_music/ui/browser.rb +5 -3
- data/lib/monkey_music/ui/console.rb +1 -1
- data/lib/monkey_music/units/monkey.rb +2 -2
- data/lib/monkey_music/units/track.rb +5 -5
- data/lib/monkey_music/units/user.rb +3 -3
- data/lib/monkey_music_generate/runner.rb +7 -6
- data/lib/monkey_music_generate/score_system.rb +7 -7
- data/users/demo_user.yaml +162 -162
- metadata +4 -4
- data/README.markdown +0 -38
- data/demo_player +0 -98
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monkeymusic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Soderlund
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -60,15 +60,15 @@ files:
|
|
60
60
|
- levels/testlevel_maze.rb
|
61
61
|
- levels/travelling_salesmonkeys.rb
|
62
62
|
- levels/testmaze_20.rb
|
63
|
+
- bin/monkeymusic-browser
|
63
64
|
- bin/monkeymusic-generate
|
64
65
|
- bin/monkeymusic
|
65
66
|
- users/demo_user.yaml
|
66
67
|
- users/synth.rb
|
67
68
|
- Gemfile.lock
|
68
69
|
- Gemfile
|
69
|
-
- README.
|
70
|
+
- README.md
|
70
71
|
- LICENSE
|
71
|
-
- demo_player
|
72
72
|
homepage: https://github.com/odsod/monkey-music
|
73
73
|
licenses:
|
74
74
|
- MIT
|
data/README.markdown
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
Monkey Music
|
2
|
-
============
|
3
|
-
|
4
|
-
This is the runtime for a programming contest, it's a work in progress.
|
5
|
-
|
6
|
-
To test-drive:
|
7
|
-
|
8
|
-
./bin/monkeymusic --user users/poscar.yaml --level levels/testlevel.rb --player-file p1 --player-name p1 --player-file p1 --player-name p2
|
9
|
-
|
10
|
-
Rules
|
11
|
-
-----
|
12
|
-
|
13
|
-
### Which monkey gets to move first?
|
14
|
-
|
15
|
-
Every round, all monkeys are put into a Fisher-Yates shuffled array, and
|
16
|
-
the monkeys will be allowed to move in order of increasing index.
|
17
|
-
|
18
|
-
Input
|
19
|
-
-----
|
20
|
-
|
21
|
-
One line with one positive integer, id, that identifies your monkey.
|
22
|
-
One line with two positive integers, w, h. The width and the
|
23
|
-
height of the level.
|
24
|
-
h lines with w comma-separated strings each. Each string represents a
|
25
|
-
space in the level.
|
26
|
-
|
27
|
-
A space can contain the following:
|
28
|
-
|
29
|
-
A monkey, on the form M#id, the letter M followed by a hash followed by the id of a monkey.
|
30
|
-
A basket, on the form B#id, the letter B followed by a hash followed by
|
31
|
-
A track URI, on the form spotify:track:XXXXXXXXXXXXXXX.
|
32
|
-
the id of the monkey the basket belongs to.
|
33
|
-
A palm tree, on the form P.
|
34
|
-
|
35
|
-
Output
|
36
|
-
------
|
37
|
-
|
38
|
-
One of the characters ['N','W','E','S'] followed by a line-break '\n'.
|
data/demo_player
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
if RUBY_VERSION =~ /1.9/
|
4
|
-
Encoding.default_external = Encoding::UTF_8
|
5
|
-
Encoding.default_internal = Encoding::UTF_8
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'yaml'
|
9
|
-
|
10
|
-
@type = gets.chomp
|
11
|
-
|
12
|
-
if @type == "INIT"
|
13
|
-
@cache = {}
|
14
|
-
@cache[:monkey] = gets.chomp
|
15
|
-
@cache[:width] = Integer(gets.chomp)
|
16
|
-
@cache[:height] = Integer(gets.chomp)
|
17
|
-
@cache[:turn_limit] = Integer(gets.chomp)
|
18
|
-
[:top_tracks, :top_albums, :top_artists, :disliked_artists].each do |toplist|
|
19
|
-
@cache[toplist] = []
|
20
|
-
n = Integer(gets.chomp)
|
21
|
-
n.times { @cache[toplist] << gets.chomp }
|
22
|
-
@cache[:uris] = {}
|
23
|
-
end
|
24
|
-
File.open(File.join(Dir.getwd, "cache_demo_player"), "w+") {|f| f.write YAML::dump(@cache)}
|
25
|
-
exit
|
26
|
-
end
|
27
|
-
|
28
|
-
@cache = YAML::load(IO.read "cache_demo_player")
|
29
|
-
|
30
|
-
# Read indata
|
31
|
-
@turn = Integer(gets.chomp)
|
32
|
-
@remaining_capacity = Integer(gets.chomp)
|
33
|
-
@remaining_time = Integer(gets.chomp)
|
34
|
-
|
35
|
-
@unknown = []
|
36
|
-
|
37
|
-
# Read level
|
38
|
-
@tracks = []
|
39
|
-
@cache[:height].times do |y|
|
40
|
-
row = gets.chomp.split(',')
|
41
|
-
@cache[:width].times do |x|
|
42
|
-
thing = row[x]
|
43
|
-
if thing == @cache[:monkey]
|
44
|
-
@x, @y = x, y
|
45
|
-
elsif /spotify:track/.match(thing)
|
46
|
-
@unknown << thing unless @cache[:uris][thing]
|
47
|
-
@tracks << [x, y]
|
48
|
-
elsif thing == "U"
|
49
|
-
@user = [x, y]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
#if uri = @unknown.pop
|
55
|
-
#puts uri
|
56
|
-
#$stdout.flush
|
57
|
-
#n = Integer(gets.chomp)
|
58
|
-
#if n == 1
|
59
|
-
#@cache[:uris][uri] = gets.chomp
|
60
|
-
#end
|
61
|
-
#File.open(File.join(Dir.getwd, "cache_p1"), "w+") {|f| f.write YAML::dump(@cache)}
|
62
|
-
#exit
|
63
|
-
#end
|
64
|
-
|
65
|
-
def move_toward(x, y)
|
66
|
-
if @x < x
|
67
|
-
"E"
|
68
|
-
elsif @x > x
|
69
|
-
"W"
|
70
|
-
elsif @y < y
|
71
|
-
"S"
|
72
|
-
elsif @y > y
|
73
|
-
"N"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def closest_track
|
78
|
-
curr_closest = @tracks.pop()
|
79
|
-
curr_smallest_distance = distance_to(*curr_closest)
|
80
|
-
@tracks.each do |track|
|
81
|
-
curr_distance = distance_to(*track)
|
82
|
-
if curr_distance < curr_smallest_distance
|
83
|
-
curr_closest = track
|
84
|
-
curr_smallest_distance = curr_distance
|
85
|
-
end
|
86
|
-
end
|
87
|
-
curr_closest
|
88
|
-
end
|
89
|
-
|
90
|
-
def distance_to(x, y)
|
91
|
-
(@x - x).abs + (@y - y).abs
|
92
|
-
end
|
93
|
-
|
94
|
-
if (@remaining_capacity > 0) && (not @tracks.empty?)
|
95
|
-
puts move_toward(*closest_track())
|
96
|
-
else
|
97
|
-
puts move_toward(*@user)
|
98
|
-
end
|