ale_ruby_interface 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/ale_ruby_interface.rb +198 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a70d32ca9e6f49df1d6653f6d1f1aa1d7adfd6b3
|
4
|
+
data.tar.gz: 4e412b8e035224e3fa400a762b9a110924286a82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1bffbadbe3212c02f2b604dbfd9985c5fb59d1ba028c1dade462b73428adbf54d61f860dc59f4c0027dde1b9fb047353108b03be237557010b0ca365cb21e252
|
7
|
+
data.tar.gz: 612285d50e96abbcb955a2751434c048314b26df863546b04bfc7c9bde76d5a611a90ccda3bb4e198fa30f424d3ca6dcbf5e53da0aa225736e4143de8e791532
|
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require 'nmatrix'
|
3
|
+
|
4
|
+
module ALELib
|
5
|
+
extend FFI::Library
|
6
|
+
ffi_lib '/Users/happybai/Arcade-Learning-Environment/ale_python_interface/libale_c.so'
|
7
|
+
attach_function :ALE_new, [], :void
|
8
|
+
attach_function :ALE_del, [:void], :void
|
9
|
+
attach_function :getString, [:void, :char], :char
|
10
|
+
attach_function :getInt, [:void, :char], :int
|
11
|
+
attach_function :getBool, [:void, :char], :bool
|
12
|
+
attach_function :getFloat, [:void, :char], :float
|
13
|
+
attach_function :setString, [:void, :char, :char], :void
|
14
|
+
attach_function :setInt, [:void, :char, :int], :void
|
15
|
+
attach_function :setBool, [:void, :char, :bool], :void
|
16
|
+
attach_function :setFloat, [:void, :char, :float], :void
|
17
|
+
attach_function :loadROM, [:void, :char], :void
|
18
|
+
attach_function :act, [:void, :int], :int
|
19
|
+
attach_function :game_over, [:void], :bool
|
20
|
+
attach_function :reset_game, [:void], :void
|
21
|
+
attach_function :getAvailableModes, [:void, :void], :void
|
22
|
+
attach_function :getAvailableModesSize, [:void], :int
|
23
|
+
attach_function :setMode, [:void, :int], :void
|
24
|
+
attach_function :getAvailableDifficulties, [:void, :void], :void
|
25
|
+
attach_function :getAvailableDifficultiesSize, [:void], :int
|
26
|
+
attach_function :setDifficulty, [:void, :int], :void
|
27
|
+
attach_function :getLegalActionSet, [:void, :void], :void
|
28
|
+
attach_function :getLegalActionSize, [:void], :int
|
29
|
+
attach_function :getMinimalActionSet, [:void, :void], :void
|
30
|
+
attach_function :getMinimalActionSize, [:void], :int
|
31
|
+
attach_function :getFrameNumber, [:void], :int
|
32
|
+
attach_function :lives, [:void], :int
|
33
|
+
attach_function :getEpisodeFrameNumber, [:void], :int
|
34
|
+
attach_function :getScreen, [:void, :void], :void
|
35
|
+
attach_function :getRAM, [:void, :void], :void
|
36
|
+
attach_function :getRAMSize, [:void], :int
|
37
|
+
attach_function :getScreenWidth, [:void], :int
|
38
|
+
attach_function :getScreenHeight, [:void], :int
|
39
|
+
attach_function :getScreenRGB, [:void, :void], :void
|
40
|
+
attach_function :getScreenGrayscale, [:void, :void], :void
|
41
|
+
attach_function :saveState, [:void], :void
|
42
|
+
attach_function :loadState, [:void], :void
|
43
|
+
attach_function :cloneState, [:void], :void
|
44
|
+
attach_function :restoreState, [:void, :void], :void
|
45
|
+
attach_function :cloneSystemState, [:void], :void
|
46
|
+
attach_function :restoreSystemState, [:void, :void], :void
|
47
|
+
attach_function :deleteState, [:void], :void
|
48
|
+
attach_function :saveScreenPNG, [:void, :char], :void
|
49
|
+
attach_function :encodeState, [:void, :void, :int], :void
|
50
|
+
attach_function :encodeStateLen, [:void], :int
|
51
|
+
attach_function :decodeState, [:void, :int], :void
|
52
|
+
attach_function :setLoggerMode, [:int], :void
|
53
|
+
end
|
54
|
+
|
55
|
+
class ALEInterface
|
56
|
+
# include ALELib
|
57
|
+
|
58
|
+
def initialize
|
59
|
+
@obj = ALELib.ALE_new
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_string(key)
|
63
|
+
return ALELib.getString(@obj, key)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_int(key)
|
67
|
+
return ALELib.getInt(@obj, key)
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_bool(key)
|
71
|
+
return ALELib.getBool(@obj, key)
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_float(key)
|
75
|
+
return ALELib.getFloat(@obj, key)
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_string(key, value)
|
79
|
+
ALELib.setString(@obj, key, value)
|
80
|
+
end
|
81
|
+
|
82
|
+
def set_int(key, value)
|
83
|
+
ALELib.setInt(@obj, key, value)
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_bool(key, value)
|
87
|
+
ALELib.setBool(@obj, key, value)
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_float(key, value)
|
91
|
+
ALELib.setFloat(@obj, key, value)
|
92
|
+
end
|
93
|
+
|
94
|
+
def load_rom(rom_file)
|
95
|
+
ALELib.loadROM(@obj, rom_file)
|
96
|
+
end
|
97
|
+
|
98
|
+
def act(action)
|
99
|
+
return ALELib.act(@obj, action.to_i)
|
100
|
+
end
|
101
|
+
|
102
|
+
def game_over
|
103
|
+
return ALELib.game_over(@obj)
|
104
|
+
end
|
105
|
+
|
106
|
+
def reset_game
|
107
|
+
ALELib.game_over(@obj)
|
108
|
+
end
|
109
|
+
|
110
|
+
def get_legal_action_set
|
111
|
+
act_size = ALELib.getLegalActionSize(@obj)
|
112
|
+
act = NMatrix.zeros[act_size]
|
113
|
+
ALELib.getLegalActionSet(@obj, act)
|
114
|
+
return act
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_minimal_action_set
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_available_modes
|
121
|
+
end
|
122
|
+
|
123
|
+
def set_mode
|
124
|
+
end
|
125
|
+
|
126
|
+
def get_available_difficuties
|
127
|
+
end
|
128
|
+
|
129
|
+
def set_difficulty
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_legal_action_set
|
133
|
+
end
|
134
|
+
|
135
|
+
def get_minimal_action_set
|
136
|
+
end
|
137
|
+
|
138
|
+
def get_frame_number
|
139
|
+
end
|
140
|
+
|
141
|
+
def lives
|
142
|
+
end
|
143
|
+
|
144
|
+
def get_episode_frame_number
|
145
|
+
end
|
146
|
+
|
147
|
+
def get_screen_dims
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_screen
|
151
|
+
end
|
152
|
+
|
153
|
+
def get_screen_RGB
|
154
|
+
end
|
155
|
+
|
156
|
+
def get_screen_grayscale
|
157
|
+
end
|
158
|
+
|
159
|
+
def get_RAM_size
|
160
|
+
end
|
161
|
+
|
162
|
+
def get_RAM
|
163
|
+
end
|
164
|
+
|
165
|
+
def save_screen_PNG
|
166
|
+
end
|
167
|
+
|
168
|
+
def save_state
|
169
|
+
end
|
170
|
+
|
171
|
+
def load_state
|
172
|
+
end
|
173
|
+
|
174
|
+
def clone_state
|
175
|
+
end
|
176
|
+
|
177
|
+
def restore_state
|
178
|
+
end
|
179
|
+
|
180
|
+
def clone_system_state
|
181
|
+
end
|
182
|
+
|
183
|
+
def restore_system_state
|
184
|
+
end
|
185
|
+
|
186
|
+
def delete_state
|
187
|
+
end
|
188
|
+
|
189
|
+
def encode_state_len
|
190
|
+
end
|
191
|
+
|
192
|
+
def encode_state
|
193
|
+
end
|
194
|
+
|
195
|
+
def decode_state
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ale_ruby_interface
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Byron Bai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.9.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.9'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.9.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: nmatrix
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.2'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.2.3
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.2'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.2.3
|
53
|
+
description: This directly implements a ruby version of the arcade learning environment
|
54
|
+
interface.
|
55
|
+
email: byron.bai@aol.com
|
56
|
+
executables: []
|
57
|
+
extensions: []
|
58
|
+
extra_rdoc_files: []
|
59
|
+
files:
|
60
|
+
- lib/ale_ruby_interface.rb
|
61
|
+
homepage: http://rubygems.org/gems/ale_ruby_interface
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.6.12
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: A ruby version of the arcade learning environment interface.
|
85
|
+
test_files: []
|