ai_games-parser 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 914377a24244c4c4fb18915e6787001d2f4a9d24
4
+ data.tar.gz: 0472505c4b22095990b92169e7c5c4e452ba1db7
5
+ SHA512:
6
+ metadata.gz: 6edb9cf7cb7c313413c9cf1a5b5d42e88a2c561ddc70b1c29985470ae4d95aff5452ca9d976630acc198b950cd3c12a3c0197e8c8c5cc192fa6962a6a696d732
7
+ data.tar.gz: 6f06f9f58b96cad5c398b8549687ba4b2e686cf4a9958724c02576d2c4270a9416839f619032151d5d4c03039af97e2bf2ea4b911ab0e494e4b59f144b06d03c
data/.gitignore ADDED
@@ -0,0 +1,147 @@
1
+ # Created by https://www.gitignore.io/api/linux,osx,windows,ruby,rubymine
2
+
3
+ ### Linux ###
4
+ *~
5
+
6
+ # KDE directory preferences
7
+ .directory
8
+
9
+ # Linux trash folder which might appear on any partition or disk
10
+ .Trash-*
11
+
12
+
13
+ ### OSX ###
14
+ .DS_Store
15
+ .AppleDouble
16
+ .LSOverride
17
+
18
+ # Icon must end with two \r
19
+ Icon
20
+
21
+
22
+ # Thumbnails
23
+ ._*
24
+
25
+ # Files that might appear in the root of a volume
26
+ .DocumentRevisions-V100
27
+ .fseventsd
28
+ .Spotlight-V100
29
+ .TemporaryItems
30
+ .Trashes
31
+ .VolumeIcon.icns
32
+
33
+ # Directories potentially created on remote AFP share
34
+ .AppleDB
35
+ .AppleDesktop
36
+ Network Trash Folder
37
+ Temporary Items
38
+ .apdisk
39
+
40
+
41
+ ### Windows ###
42
+ # Windows image file caches
43
+ Thumbs.db
44
+ ehthumbs.db
45
+
46
+ # Folder config file
47
+ Desktop.ini
48
+
49
+ # Recycle Bin used on file shares
50
+ $RECYCLE.BIN/
51
+
52
+ # Windows Installer files
53
+ *.cab
54
+ *.msi
55
+ *.msm
56
+ *.msp
57
+
58
+ # Windows shortcuts
59
+ *.lnk
60
+
61
+
62
+ ### Ruby ###
63
+ *.gem
64
+ *.rbc
65
+ /.config
66
+ /coverage/
67
+ /InstalledFiles
68
+ /pkg/
69
+ /spec/reports/
70
+ /spec/examples.txt
71
+ /test/tmp/
72
+ /test/version_tmp/
73
+ /tmp/
74
+
75
+ ## Specific to RubyMotion:
76
+ .dat*
77
+ .repl_history
78
+ build/
79
+
80
+ ## Documentation cache and generated files:
81
+ /.yardoc/
82
+ /_yardoc/
83
+ /doc/
84
+ /rdoc/
85
+
86
+ ## Environment normalisation:
87
+ /.bundle/
88
+ /vendor/bundle
89
+ /lib/bundler/man/
90
+
91
+ # for a library or gem, you might want to ignore these files since the code is
92
+ # intended to run in multiple environments; otherwise, check them in:
93
+ Gemfile.lock
94
+ .ruby-version
95
+ .ruby-gemset
96
+
97
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
98
+ .rvmrc
99
+
100
+
101
+ ### RubyMine ###
102
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
103
+
104
+ *.iml
105
+
106
+ ## Directory-based project format:
107
+ .idea/
108
+ # if you remove the above rule, at least ignore the following:
109
+
110
+ # User-specific stuff:
111
+ # .idea/workspace.xml
112
+ # .idea/tasks.xml
113
+ # .idea/dictionaries
114
+
115
+ # Sensitive or high-churn files:
116
+ # .idea/dataSources.ids
117
+ # .idea/dataSources.xml
118
+ # .idea/sqlDataSources.xml
119
+ # .idea/dynamic.xml
120
+ # .idea/uiDesigner.xml
121
+
122
+ # Gradle:
123
+ # .idea/gradle.xml
124
+ # .idea/libraries
125
+
126
+ # Mongo Explorer plugin:
127
+ # .idea/mongoSettings.xml
128
+
129
+ ## File-based project format:
130
+ *.ipr
131
+ *.iws
132
+
133
+ ## Plugin-specific files:
134
+
135
+ # IntelliJ
136
+ /out/
137
+
138
+ # mpeltonen/sbt-idea plugin
139
+ .idea_modules/
140
+
141
+ # JIRA plugin
142
+ atlassian-ide-plugin.xml
143
+
144
+ # Crashlytics plugin (for Android Studio and IntelliJ)
145
+ com_crashlytics_export_strings.xml
146
+ crashlytics.properties
147
+ crashlytics-build.properties
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'bin/**/*'
4
+
5
+ Style/Documentation:
6
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,27 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people
4
+ who contribute through reporting issues, posting feature requests, updating
5
+ documentation, submitting pull requests or patches, and other activities.
6
+
7
+ We are committed to making participation in this project a harassment-free
8
+ experience for everyone, regardless of level of experience, gender, gender
9
+ identity and expression, sexual orientation, disability, personal appearance,
10
+ body size, race, ethnicity, age, or religion.
11
+
12
+ Examples of unacceptable behavior by participants include the use of sexual
13
+ language or imagery, derogatory comments or personal attacks, trolling, public
14
+ or private harassment, insults, or other unprofessional conduct.
15
+
16
+ Project maintainers have the right and responsibility to remove, edit, or reject
17
+ comments, commits, code, wiki edits, issues, and other contributions that are
18
+ not aligned to this Code of Conduct. Project maintainers who do not follow the
19
+ Code of Conduct may be removed from the project team.
20
+
21
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
22
+ reported by opening an issue or contacting one or more of the project
23
+ maintainers.
24
+
25
+ This Code of Conduct is adapted from the
26
+ [Contributor Covenant](http://contributor-covenant.org), version 1.0.0,
27
+ available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ai_games-parser.gemspec
4
+ gemspec
5
+
6
+ gem 'ai_games-logger', github: 'jdno/ai_games-logger', branch: 'develop'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jan David Nose
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # AIGames::Parser
2
+
3
+ This gem provides a parser that can be used to communicate with the game engine
4
+ in The AI Games' competitions. By extending it, the parser can be customized to
5
+ work in any competition.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your bot's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ai_games-parser'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ai_games-parser
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
30
+ run `rake test` to run the tests. You can also run `bin/console` for an
31
+ interactive prompt that will allow you to experiment.
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at
36
+ https://github.com/jdno/ai_games-parser. This project is intended to be a safe,
37
+ welcoming space for collaboration, and contributors are expected to adhere to
38
+ the [Contributor Covenant](contributor-covenant.org) code of conduct.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the
43
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ai_games/parser/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ai_games-parser'
8
+ spec.version = AIGames::Parser::VERSION
9
+ spec.authors = ['Jan David Nose']
10
+ spec.email = ['jandavid@awesometechnology.de']
11
+
12
+ spec.summary = "Skeleton for a parser for The AI Games' competitions"
13
+ spec.description = <<-EOF
14
+ This gem provides a parser that can be used to communicate with the game engine
15
+ in The AI Games' competitions. By extending it, the parser can be customized to
16
+ work in any competition.
17
+ EOF
18
+ spec.homepage = 'https://github.com/jdno/ai_games-parser'
19
+ spec.license = 'MIT'
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_runtime_dependency 'ai_games-logger'
30
+
31
+ spec.add_development_dependency 'bundler', '~> 1.10'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'minitest'
34
+ spec.add_development_dependency 'rubocop'
35
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ai_games/parser"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,104 @@
1
+ # Copyright (c) 2015 Jan David Nose
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+ require 'ai_games/logger'
21
+
22
+ module AIGames
23
+ module Parser
24
+ # This class provides an abstract parser that can be extended to implement
25
+ # the logic that is required for a specific competition. It provides methods
26
+ # to communicate with the game engine, but does NOT contain any logic how to
27
+ # parse the engine's commands. This is totally up to the implementations of
28
+ # this class.
29
+ class AbstractParser
30
+ # Initializes the parser. Pass in options using a hash structure.
31
+ def initialize(options = nil)
32
+ initialize_streams options if options
33
+ end
34
+
35
+ # Starts the main loop. This loop runs until the game engine closes the
36
+ # console line. During the loop, the parser reads from the game engine,
37
+ # sanitizes the input a little bit, and then passes it to a method that
38
+ # needs to be overwritten by parsers extending this interface.
39
+ def run
40
+ AIGames::Logger.info 'Parser.run : Starting loop'
41
+
42
+ loop do
43
+ command = read_from_engine
44
+ break if command.nil?
45
+
46
+ command.strip!
47
+ next if command.length == 0
48
+
49
+ response = parse split_line command
50
+ write_to_engine response
51
+ end
52
+
53
+ AIGames::Logger.info 'Parser.run : Stopping loop'
54
+ end
55
+
56
+ # Parses the given command array. This method MUST return a valid response
57
+ # string that can be send to the engine.
58
+ # rubocop:disable Lint/UnusedMethodArgument
59
+ def parse(command_array)
60
+ fail 'Method must be overwritten'
61
+ end
62
+ # rubocop:enable Lint/UnusedMethodArgument
63
+
64
+ private
65
+
66
+ # Initializes the input and output streams that the parser uses. The
67
+ # expected format for the options is a hash with the keys `:input` and
68
+ # `:output`. Use this to mock `STDIN` and `STDOUT` for tests.
69
+ def initialize_streams(options)
70
+ @input = options[:input] if options.key? :input
71
+ @output = options[:output] if options.key? :output
72
+ end
73
+
74
+ # Returns the input stream. If no stream has been configured, $stdin is
75
+ # returned.
76
+ def input
77
+ @input ||= $stdin
78
+ end
79
+
80
+ # Returns the output stream. If no stream has been configured, $stdout is
81
+ # returned.
82
+ def output
83
+ @output ||= $stdout
84
+ end
85
+
86
+ # Reads from the input stream.
87
+ def read_from_engine
88
+ input.gets
89
+ end
90
+
91
+ # Writes to the output stream.
92
+ def write_to_engine(string)
93
+ output.puts string
94
+ output.flush
95
+ end
96
+
97
+ # Formats a command line for further processing. The input is split at the
98
+ # whitespace character, and all its parts are converted to downcase.
99
+ def split_line(line)
100
+ line.split(' ').map(&:downcase)
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,5 @@
1
+ module AIGames
2
+ module Parser
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'ai_games/parser/version'
2
+
3
+ module AIGames
4
+ module Parser
5
+ # Your code goes here...
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ai_games-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan David Nose
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ai_games-logger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |
84
+ This gem provides a parser that can be used to communicate with the game engine
85
+ in The AI Games' competitions. By extending it, the parser can be customized to
86
+ work in any competition.
87
+ email:
88
+ - jandavid@awesometechnology.de
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - ".rubocop.yml"
95
+ - ".travis.yml"
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - ai_games-parser.gemspec
102
+ - bin/console
103
+ - bin/setup
104
+ - lib/ai_games/parser.rb
105
+ - lib/ai_games/parser/abstract_parser.rb
106
+ - lib/ai_games/parser/version.rb
107
+ homepage: https://github.com/jdno/ai_games-parser
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.4.6
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Skeleton for a parser for The AI Games' competitions
131
+ test_files: []