Project

just_shogi

0.0
No commit activity in last 3 years
No release in over 3 years
Provides a representation of a shogi game complete with rules enforcement and serialisation.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1.4
~> 5.14.0
~> 13.0.1

Runtime

 Project Readme

JustShogi

A shogi engine written in ruby. It provides a representation of a shogi game complete with rules enforcement and serialisation.

Installation

Add this line to your application's Gemfile:

gem 'just_shogi'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install just_shogi

Usage

To start, a new game state can be instantiated with the default state:

  game_state = JustShogi::GameState.default

Moves can be made by passing in the player number and the from and to ids. It will return true if the move is valid, otherwise it will return false. The last argument is optional and if specified to true will attempt to promote the piece.

  game_state.move(1, '77', '78', true)

Drops can be made by passing in the player number, the id of the piece in hand and the id of the square that the piece will be placed on. It will return true if the move is valid. Otherwise it will return false.

  game_state.drop(1, 23, '78')

The last change with all its details are found in the last_change attribute.

  game_state.last_change

If something unexpected happens, errors may be found in the errors attribute.

  game_state.errors

The winner can be gound by calling winner on the object.

  game_state.winner

Also, the game can be serialized into a hash.

  game_state.as_json

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/just_shogi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the JustShogi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.