chess_engine 0.0.1
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 +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +21 -0
- data/README.md +26 -0
- data/chess_engine.gemspec +14 -0
- data/lib/chess_engine/board.rb +95 -0
- data/lib/chess_engine/cli.rb +105 -0
- data/lib/chess_engine/game.rb +148 -0
- data/lib/chess_engine/input.rb +19 -0
- data/lib/chess_engine/move.rb +35 -0
- data/lib/chess_engine/piece.rb +97 -0
- data/lib/chess_engine/validator.rb +87 -0
- data/lib/chess_engine.rb +1 -0
- data/spec/board_spec.rb +70 -0
- data/spec/game_helper.rb +5 -0
- data/spec/game_spec.rb +79 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/validator_spec.rb +26 -0
- data/vendor/bundle/bin/coderay +27 -0
- data/vendor/bundle/bin/pry +27 -0
- data/vendor/bundle/cache/coderay-1.1.2.gem +0 -0
- data/vendor/bundle/cache/colorize-0.8.1.gem +0 -0
- data/vendor/bundle/cache/method_source-0.9.2.gem +0 -0
- data/vendor/bundle/cache/pry-0.12.2.gem +0 -0
- data/vendor/bundle/cache/rb-readline-0.5.5.gem +0 -0
- data/vendor/bundle/gems/coderay-1.1.2/MIT-LICENSE +22 -0
- data/vendor/bundle/gems/coderay-1.1.2/README_INDEX.rdoc +123 -0
- data/vendor/bundle/gems/coderay-1.1.2/bin/coderay +215 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/duo.rb +81 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/_map.rb +17 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/comment_filter.rb +25 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/count.rb +39 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug.rb +49 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug_lint.rb +63 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/div.rb +23 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb +190 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/filter.rb +58 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/css.rb +65 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/numbering.rb +108 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/output.rb +166 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html.rb +333 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/json.rb +83 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lines_of_code.rb +45 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lint.rb +59 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/null.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/page.rb +24 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/span.rb +23 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/statistic.rb +95 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/terminal.rb +195 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/text.rb +46 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/token_kind_filter.rb +111 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/xml.rb +72 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/yaml.rb +50 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/for_redcloth.rb +95 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/file_type.rb +151 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb +55 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin_host.rb +221 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/word_list.rb +72 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/_map.rb +24 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/c.rb +189 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/clojure.rb +217 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/cpp.rb +217 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/css.rb +196 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/debug.rb +75 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/delphi.rb +144 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/diff.rb +221 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/erb.rb +81 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/go.rb +208 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/groovy.rb +268 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/haml.rb +168 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/html.rb +275 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java/builtin_types.rb +421 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java.rb +174 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java_script.rb +237 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/json.rb +98 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/lua.rb +280 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/php.rb +527 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/python.rb +287 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/raydebug.rb +75 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/patterns.rb +178 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/string_state.rb +79 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby.rb +477 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sass.rb +232 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb +337 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sql.rb +169 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/taskpaper.rb +36 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/text.rb +26 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/xml.rb +17 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/yaml.rb +140 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners.rb +27 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/_map.rb +7 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/alpha.rb +153 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/style.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles.rb +15 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/token_kinds.rb +85 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens.rb +161 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens_proxy.rb +55 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/version.rb +3 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay.rb +284 -0
- data/vendor/bundle/gems/colorize-0.8.1/CHANGELOG +65 -0
- data/vendor/bundle/gems/colorize-0.8.1/LICENSE +339 -0
- data/vendor/bundle/gems/colorize-0.8.1/README.md +105 -0
- data/vendor/bundle/gems/colorize-0.8.1/Rakefile +13 -0
- data/vendor/bundle/gems/colorize-0.8.1/colorize.gemspec +36 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/class_methods.rb +120 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/instance_methods.rb +132 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize.rb +12 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorized_string.rb +19 -0
- data/vendor/bundle/gems/colorize-0.8.1/test/test_colorize.rb +164 -0
- data/vendor/bundle/gems/method_source-0.9.2/Gemfile +2 -0
- data/vendor/bundle/gems/method_source-0.9.2/LICENSE +25 -0
- data/vendor/bundle/gems/method_source-0.9.2/README.markdown +91 -0
- data/vendor/bundle/gems/method_source-0.9.2/Rakefile +81 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/code_helpers.rb +154 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/source_location.rb +138 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/version.rb +3 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source.rb +141 -0
- data/vendor/bundle/gems/method_source-0.9.2/method_source.gemspec +35 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/method_source/code_helpers_spec.rb +43 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/method_source_spec.rb +143 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb +101 -0
- data/vendor/bundle/gems/pry-0.12.2/CHANGELOG.md +953 -0
- data/vendor/bundle/gems/pry-0.12.2/LICENSE +25 -0
- data/vendor/bundle/gems/pry-0.12.2/README.md +390 -0
- data/vendor/bundle/gems/pry-0.12.2/bin/pry +8 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/basic_object.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/cli.rb +218 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_file.rb +110 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_range.rb +71 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/loc.rb +98 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code.rb +353 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code_object.rb +195 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/color_printer.rb +65 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/command.rb +723 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/command_set.rb +415 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/amend_line.rb +98 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang.rb +20 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang_pry.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/abstract_formatter.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/exception_formatter.rb +79 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/file_formatter.rb +71 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat.rb +63 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cd.rb +41 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_inspector.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_prompt.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/clear_screen.rb +14 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/code_collector.rb +167 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disable_pry.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disabled_commands.rb +2 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/easter_eggs.rb +112 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/exception_patcher.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit.rb +200 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit.rb +43 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_all.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_program.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/find_method.rb +191 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/fix_indent.rb +19 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_cd.rb +26 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_install.rb +32 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_list.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_open.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_readme.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_search.rb +40 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_stats.rb +83 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gist.rb +102 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/help.rb +164 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/hist.rb +181 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/import_set.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/install_command.rb +54 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/jump_to.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/list_inspectors.rb +35 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/constants.rb +58 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/formatter.rb +51 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/globals.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/grep.rb +19 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/instance_vars.rb +38 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_names.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_vars.rb +37 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/ls_entity.rb +69 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods.rb +54 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/self_methods.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls.rb +113 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/nesting.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/play.rb +102 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_backtrace.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_version.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/raise_up.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reload_code.rb +62 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reset.rb +18 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ri.rb +65 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/save_file.rb +61 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_command.rb +75 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_mode.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_doc.rb +81 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_info.rb +216 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_input.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_source.rb +53 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/stat.rb +40 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/switch_to.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/toggle_color.rb +24 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression.rb +107 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/whereami.rb +197 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/wtf.rb +70 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/behavior.rb +255 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/convenience.rb +28 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/default.rb +159 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/memoization.rb +48 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config.rb +35 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/core_extensions.rb +142 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/editor.rb +128 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/exceptions.rb +76 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/forwardable.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/base_helpers.rb +200 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/command_helpers.rb +157 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/documentation_helpers.rb +76 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/options_helpers.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/platform.rb +58 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/table.rb +114 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/text.rb +115 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/history.rb +161 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/hooks.rb +171 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/indent.rb +408 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_completer.rb +265 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_lock.rb +130 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/inspector.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/last_exception.rb +61 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/disowned.rb +55 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/patcher.rb +122 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/weird_method_locator.rb +198 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method.rb +552 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/object_path.rb +83 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/output.rb +50 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pager.rb +250 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/platform.rb +91 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/plugins.rb +122 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/prompt.rb +145 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_class.rb +425 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_instance.rb +699 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl.rb +261 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl_file_loader.rb +73 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/ring.rb +84 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/rubygem.rb +84 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/LICENSE +20 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/commands.rb +195 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/option.rb +206 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop.rb +661 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/terminal.rb +91 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/evalable.rb +15 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/mockable.rb +14 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/pry_tester.rb +73 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/utility.rb +26 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/variables.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable.rb +70 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/version.rb +3 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module/candidate.rb +131 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module.rb +378 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry.rb +132 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/CHANGES +94 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/LICENSE +25 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/README.md +81 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/Rakefile +25 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/bench/_rl_adjust_point.rb +26 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline.rb +8 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline_with_completion.rb +18 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/tinyirb.rb +11 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rb-readline.rb +18 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline/version.rb +3 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline.rb +8920 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/readline.rb +539 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/rb-readline.gemspec +51 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/setup.rb +1585 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/support/filesystem_completion_helper.rb +53 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_completion.rb +100 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_filename_completion_proc.rb +88 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_history.rb +29 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_rbreadline.rb +23 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_readline.rb +221 -0
- data/vendor/bundle/specifications/coderay-1.1.2.gemspec +26 -0
- data/vendor/bundle/specifications/colorize-0.8.1.gemspec +38 -0
- data/vendor/bundle/specifications/method_source-0.9.2.gemspec +35 -0
- data/vendor/bundle/specifications/pry-0.12.2.gemspec +38 -0
- data/vendor/bundle/specifications/rb-readline-0.5.5.gemspec +39 -0
- metadata +363 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
module ChessEngine
|
2
|
+
class Move
|
3
|
+
def initialize(board, from, to)
|
4
|
+
@board = board
|
5
|
+
@from = from
|
6
|
+
@to = to
|
7
|
+
@original_squares = []
|
8
|
+
@original_squares << {coord: from, piece: board.at(from)}
|
9
|
+
@original_squares << {coord: to, piece: board.at(to)}
|
10
|
+
if en_passant?
|
11
|
+
@en_passant_coord = [to[0], from[1]]
|
12
|
+
@original_squares << {coord: @en_passant_coord, piece: board.at(@en_passant_coord)}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def commit
|
17
|
+
if en_passant?
|
18
|
+
@board.set_at(@en_passant_coord, nil)
|
19
|
+
end
|
20
|
+
@board.move_piece(@from, @to)
|
21
|
+
end
|
22
|
+
|
23
|
+
def rollback
|
24
|
+
@original_squares.each do |square|
|
25
|
+
@board.set_at(square[:coord], square[:piece])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def en_passant?
|
32
|
+
@board.at(@from).pawn? && @from[0] != @to[0] && @board.at(@to).nil?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module ChessEngine
|
2
|
+
class Piece
|
3
|
+
attr_reader :symbol, :color
|
4
|
+
attr_accessor :moves_count
|
5
|
+
|
6
|
+
def initialize(color)
|
7
|
+
@color = color
|
8
|
+
@moves_count = 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect
|
12
|
+
"#{self.class}:#{@color}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def beats_diagonally?
|
16
|
+
elephant? || queen?
|
17
|
+
end
|
18
|
+
|
19
|
+
def beats_straight?
|
20
|
+
rook? || queen?
|
21
|
+
end
|
22
|
+
|
23
|
+
["knight", "king", "pawn", "rook", "queen", "elephant"].each do |piece|
|
24
|
+
define_method(:"#{piece}?") do
|
25
|
+
self.class.to_s == "ChessEngine::#{piece.capitalize}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Elephant < Piece
|
31
|
+
def initialize(color)
|
32
|
+
super
|
33
|
+
@symbol = (@color == :black) ? "\u25B2" : "\u25B3"
|
34
|
+
end
|
35
|
+
|
36
|
+
def moves
|
37
|
+
[[1, 1], [1, -1], [-1, 1], [-1, -1]]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class King < Piece
|
42
|
+
def initialize(color)
|
43
|
+
super
|
44
|
+
@symbol = (@color == :black) ? "\u265A" : "\u2654"
|
45
|
+
end
|
46
|
+
|
47
|
+
def moves
|
48
|
+
[[0, 1], [0, -1], [1, 0], [-1, 0],
|
49
|
+
[1, 1], [1, -1], [-1, 1], [-1, -1]]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Knight < Piece
|
54
|
+
def initialize(color)
|
55
|
+
super
|
56
|
+
@symbol = (@color == :black) ? "\u265E" : "\u2658"
|
57
|
+
end
|
58
|
+
|
59
|
+
def moves
|
60
|
+
[[1, 2], [2, 1], [1, -2], [-2, 1],
|
61
|
+
[-1, 2], [2, -1], [-1, -2], [-2, -1]]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Pawn < Piece
|
66
|
+
attr_reader :direction
|
67
|
+
|
68
|
+
def initialize(color)
|
69
|
+
super
|
70
|
+
@symbol = (@color == :black) ? "\u265F" : "\u2659"
|
71
|
+
@direction = (@color == :white) ? 1 : -1
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class Queen < Piece
|
76
|
+
def initialize(color)
|
77
|
+
super
|
78
|
+
@symbol = (@color == :black) ? "\u265B" : "\u2655"
|
79
|
+
end
|
80
|
+
|
81
|
+
def moves
|
82
|
+
[[0, 1], [0, -1], [1, 0], [-1, 0],
|
83
|
+
[1, 1], [1, -1], [-1, 1], [-1, -1]]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class Rook < Piece
|
88
|
+
def initialize(color)
|
89
|
+
super
|
90
|
+
@symbol = (@color == :black) ? "\u265C" : "\u2656"
|
91
|
+
end
|
92
|
+
|
93
|
+
def moves
|
94
|
+
[[1, 0], [0, 1], [-1, 0], [0, -1]]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module ChessEngine
|
2
|
+
module MoveValidator
|
3
|
+
def safe_moves(from)
|
4
|
+
valid_moves(from).reject { |move| fatal_move?(from, move) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def valid_moves(from)
|
8
|
+
piece = @board.at(from)
|
9
|
+
if piece.king? || piece.knight?
|
10
|
+
piece.moves.map do |move|
|
11
|
+
to = relative_coords(from, move)
|
12
|
+
to if valid_move?(to)
|
13
|
+
end.compact
|
14
|
+
elsif piece.pawn?
|
15
|
+
pawn_valid_moves(from)
|
16
|
+
else
|
17
|
+
valid_moves_recursive(from)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid_moves_recursive(from)
|
22
|
+
piece = @board.at(from)
|
23
|
+
piece.moves.inject([]) do |valid_moves, move|
|
24
|
+
valid_moves.push(*repeated_move(from, move))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def repeated_move(from, move, valid_moves = [])
|
29
|
+
coordinates = relative_coords(from, move)
|
30
|
+
return valid_moves unless valid_move?(coordinates)
|
31
|
+
return valid_moves << coordinates unless @board.at(coordinates).nil?
|
32
|
+
repeated_move(coordinates, move, valid_moves << coordinates)
|
33
|
+
end
|
34
|
+
|
35
|
+
def relative_coords(from, move)
|
36
|
+
[from[0] + move[0], from[1] + move[1]]
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid_move?(coordinates)
|
40
|
+
if @board.exists_at?(coordinates)
|
41
|
+
piece = @board.at(coordinates)
|
42
|
+
return (piece.nil? || piece.color != @current_color)
|
43
|
+
end
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
|
47
|
+
def fatal_move?(from, to)
|
48
|
+
is_fatal = false
|
49
|
+
move = Move.new(@board, from, to)
|
50
|
+
move.commit
|
51
|
+
is_fatal = true if king_attacked?
|
52
|
+
move.rollback
|
53
|
+
is_fatal
|
54
|
+
end
|
55
|
+
|
56
|
+
def pawn_valid_moves(from)
|
57
|
+
pawn = @board.at(from)
|
58
|
+
direction = pawn.direction
|
59
|
+
moves = []
|
60
|
+
next_coords = relative_coords(from, [0, direction])
|
61
|
+
jump_coords = relative_coords(from, [0, direction * 2])
|
62
|
+
take_coords = [relative_coords(from, [1, direction]),
|
63
|
+
relative_coords(from, [-1, direction])]
|
64
|
+
if @board.exists_at?(next_coords) && @board.at(next_coords).nil?
|
65
|
+
moves << next_coords
|
66
|
+
moves << jump_coords unless pawn.moves_count > 0 || @board.at(jump_coords)
|
67
|
+
end
|
68
|
+
take_coords.each do |coords|
|
69
|
+
moves << coords if @board.at(coords) && @board.at(coords).color != pawn.color
|
70
|
+
end
|
71
|
+
en_passant_coords(from) ? moves << en_passant_coords(from) : moves
|
72
|
+
end
|
73
|
+
|
74
|
+
def en_passant_coords(from)
|
75
|
+
pawn = @board.at(from)
|
76
|
+
[1, -1].each do |x|
|
77
|
+
next_coords = [from[0] + x, from[1]]
|
78
|
+
next_piece = @board.at(next_coords)
|
79
|
+
if next_piece.class == Pawn && next_piece == @last_piece &&
|
80
|
+
next_piece.moves_count == 1 && from[1].between?(3, 4)
|
81
|
+
return [from[0] + x, from[1] + pawn.direction]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/chess_engine.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "chess_engine/game.rb"
|
data/spec/board_spec.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require "./lib/chess_engine/board.rb"
|
2
|
+
|
3
|
+
describe ChessEngine::Board do
|
4
|
+
before(:each) do
|
5
|
+
@board = ChessEngine::Board.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#initialize" do
|
9
|
+
it "creates empty board" do
|
10
|
+
expect(@board.instance_variable_get(:@board)).to eq(
|
11
|
+
[[nil, nil, nil, nil, nil, nil, nil, nil],
|
12
|
+
[nil, nil, nil, nil, nil, nil, nil, nil],
|
13
|
+
[nil, nil, nil, nil, nil, nil, nil, nil],
|
14
|
+
[nil, nil, nil, nil, nil, nil, nil, nil],
|
15
|
+
[nil, nil, nil, nil, nil, nil, nil, nil],
|
16
|
+
[nil, nil, nil, nil, nil, nil, nil, nil],
|
17
|
+
[nil, nil, nil, nil, nil, nil, nil, nil],
|
18
|
+
[nil, nil, nil, nil, nil, nil, nil, nil]])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#to_s" do
|
23
|
+
it "converts empty board into string" do
|
24
|
+
expect(@board.to_s).to eq(
|
25
|
+
"8 \e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\n7 \e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\n6 \e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\n5 \e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\n4 \e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\n3 \e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\n2 \e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\n1 \e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\n a b c d e f g h"
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "converts default board into string" do
|
30
|
+
@board.set_default
|
31
|
+
expect(@board.to_s).to eq(
|
32
|
+
"8 \e[0;39;49m♜ \e[0m\e[0;39;107m♞ \e[0m\e[0;39;49m▲ \e[0m\e[0;39;107m♛ \e[0m\e[0;39;49m♚ \e[0m\e[0;39;107m▲ \e[0m\e[0;39;49m♞ \e[0m\e[0;39;107m♜ \e[0m\n7 \e[0;39;107m♟ \e[0m\e[0;39;49m♟ \e[0m\e[0;39;107m♟ \e[0m\e[0;39;49m♟ \e[0m\e[0;39;107m♟ \e[0m\e[0;39;49m♟ \e[0m\e[0;39;107m♟ \e[0m\e[0;39;49m♟ \e[0m\n6 \e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\n5 \e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\n4 \e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\n3 \e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\e[0;39;107m \e[0m\e[0;39;49m \e[0m\n2 \e[0;39;49m♙ \e[0m\e[0;39;107m♙ \e[0m\e[0;39;49m♙ \e[0m\e[0;39;107m♙ \e[0m\e[0;39;49m♙ \e[0m\e[0;39;107m♙ \e[0m\e[0;39;49m♙ \e[0m\e[0;39;107m♙ \e[0m\n1 \e[0;39;107m♖ \e[0m\e[0;39;49m♘ \e[0m\e[0;39;107m△ \e[0m\e[0;39;49m♕ \e[0m\e[0;39;107m♔ \e[0m\e[0;39;49m△ \e[0m\e[0;39;107m♘ \e[0m\e[0;39;49m♖ \e[0m\n a b c d e f g h"
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#move_piece" do
|
38
|
+
before(:each) do
|
39
|
+
@board.set_default
|
40
|
+
@board.move_piece([4, 1], [4, 3])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "moves piece between two points" do
|
44
|
+
expect(@board[4, 1]).to be_nil
|
45
|
+
expect(@board[4, 3].pawn?).to eq(true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#exists_at?" do
|
50
|
+
it "returns true on valid positions" do
|
51
|
+
coord = []
|
52
|
+
(0..7).to_a.each { |x| coord += (0..7).to_a.map { |y| [x, y] } }
|
53
|
+
coord.each do |coordinates|
|
54
|
+
expect(@board.exists_at?(coordinates)).to eq(true)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns false on negative values" do
|
59
|
+
[[-1, 5], [0, -2], [-1, 0], [-1, -1]].each do |coordinates|
|
60
|
+
expect(@board.exists_at?(coordinates)).to eq(false)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns false on too big values" do
|
65
|
+
[[0, 8], [8, 3], [-1, 9], [8, 8]].each do |coordinates|
|
66
|
+
expect(@board.exists_at?(coordinates)).to eq(false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/spec/game_helper.rb
ADDED
data/spec/game_spec.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require "./lib/chess_engine/game.rb"
|
2
|
+
require "./spec/game_helper.rb"
|
3
|
+
|
4
|
+
describe ChessEngine::Game do
|
5
|
+
before :each do
|
6
|
+
@game = ChessEngine::Game.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#move" do
|
10
|
+
it "raises an error if the empty square is chosen" do
|
11
|
+
expect { @game.move("e3e4") }.to raise_error(ChessEngine::InvalidMove, "Empty square is chosen")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises an error if a player choses not his own piece" do
|
15
|
+
expect { @game.move("c7c6") }.to raise_error(ChessEngine::InvalidMove, "This is not your piece")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "raises an error if invalid move is made" do
|
19
|
+
expect { @game.move("e2e5") }.to raise_error(ChessEngine::InvalidMove, "Invalid move")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "raises an error if the move is fatal" do
|
23
|
+
execute_game(%w{a2a3 e7e6 a3a4 d8h4})
|
24
|
+
expect { @game.move("f2f3") }.to raise_error(ChessEngine::InvalidMove, "Fatal move")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "makes correct moves" do
|
28
|
+
@game.move("e2e4")
|
29
|
+
expect(@game["e4"].pawn?).to eq(true)
|
30
|
+
expect(@game["e2"]).to be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "makes en passant" do
|
34
|
+
execute_game(%w{a2a4 h7h5 a4a5 b7b5 a5b6})
|
35
|
+
expect(@game["a5"]).to be_nil
|
36
|
+
expect(@game["b5"]).to be_nil
|
37
|
+
expect(@game["b6"].pawn?).to eq(true)
|
38
|
+
expect(@game["b6"].color).to eq(:white)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#over?" do
|
43
|
+
it "recognizes the checkmate" do
|
44
|
+
execute_game(%w{f2f3 e7e6 g2g4 d8h4})
|
45
|
+
expect(@game.over?).to eq(true)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "recognizes the stalemate" do
|
49
|
+
execute_game(%w{c2c4 h7h5 h2h4 a7a5 d1a4 a8a6 a4a5 a6h6 a5c7 f7f6 c7d7 e8f7 d7b7 d8d3 b7b8 d3h7 b8c8 f7g6 c8e6})
|
50
|
+
expect(@game.over?).to eq(true)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#castling" do
|
55
|
+
it "plays with short and long castling" do
|
56
|
+
execute_game(%w{g1f3 b8a6 g2g3 b7b6 f1g2 c8b7 h2h3 c7c6})
|
57
|
+
@game.castling(:short)
|
58
|
+
expect(@game["g1"].king?).to eq(true)
|
59
|
+
expect(@game["f1"].rook?).to eq(true)
|
60
|
+
execute_game(%w{d8c7 h3h4})
|
61
|
+
@game.castling(:long)
|
62
|
+
expect(@game["c8"].king?).to eq(true)
|
63
|
+
expect(@game["d8"].rook?).to eq(true)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#promotion" do
|
68
|
+
it "plays with promotion" do
|
69
|
+
expect(@game.needs_promotion?).to eq(false)
|
70
|
+
execute_game(%w{g2g4 h7h5 g1f3 h5g4 h2h4 g4g3 f1h3 g3g2 h1h2 g2g1})
|
71
|
+
expect(@game.needs_promotion?).to eq(true)
|
72
|
+
expect(@game.current_color).to eq(:black)
|
73
|
+
expect { @game.move("e2e4") }.to raise_error(ChessEngine::InvalidMove)
|
74
|
+
@game.promotion("Queen")
|
75
|
+
expect(@game["g1"].queen?).to eq(true)
|
76
|
+
expect(@game["g1"].color).to eq(:black)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
65
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
70
|
+
# be too noisy due to issues in dependencies.
|
71
|
+
config.warnings = true
|
72
|
+
|
73
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
74
|
+
# file, and it's useful to allow more verbose output when running an
|
75
|
+
# individual spec file.
|
76
|
+
if config.files_to_run.one?
|
77
|
+
# Use the documentation formatter for detailed output,
|
78
|
+
# unless a formatter has already been configured
|
79
|
+
# (e.g. via a command-line flag).
|
80
|
+
config.default_formatter = "doc"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Print the 10 slowest examples and example groups at the
|
84
|
+
# end of the spec run, to help surface which specs are running
|
85
|
+
# particularly slow.
|
86
|
+
config.profile_examples = 10
|
87
|
+
|
88
|
+
# Run specs in random order to surface order dependencies. If you find an
|
89
|
+
# order dependency and want to debug it, you can fix the order by providing
|
90
|
+
# the seed, which is printed after each run.
|
91
|
+
# --seed 1234
|
92
|
+
config.order = :random
|
93
|
+
|
94
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
95
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
96
|
+
# test failures related to randomization by passing the same `--seed` value
|
97
|
+
# as the one that triggered the failure.
|
98
|
+
Kernel.srand config.seed
|
99
|
+
=end
|
100
|
+
end
|