class Qi::Action
- Qi::Action
- Reference
- Object
Overview
The Action abstraction.
Defined in:
qi/action.crConstructors
-
.new(src_square_id : Int32 | Nil, dst_square_id : Int32, moved_piece_name : String, captured_piece_name : String | Nil = nil)
Initialize an action instance.
Instance Method Summary
-
#call(*, in_hand : Array(String), square : Hash(Int32, String))
Commit an action to the position.
Constructor Detail
Initialize an action instance.
@param src_square_id [Integer, nil] The source square ID. @param dst_square_id [Integer] The target square ID. @param moved_piece_name [String] The moved piece name. @param captured_piece_name [String, nil] The captured piece name.
@example Initialize a promoted bishop action from 43 to 13 new(43, 13, "+B", nil)
@see https://developer.sashite.com/specs/portable-action-notation
Instance Method Detail
Commit an action to the position.
@param in_hand [Array] The list of pieces in hand. @param square [Hash] The index of each piece on the board.
@example Commit a Shogi action to the piece set of a position call( 43, 13, "+B", nil, in_hand: %w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p], square: { 3 => "s", 4 => "k", 5 => "s", 22 => "+P", 43 => "+B" } )
=> {:in_hand=>["S", "r", "r", "b", "g", "g", "g", "g", "s", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p"], :square=>{3=>"s", 4=>"k", 5=>"s", 22=>"+P", 13=>"+B"}}
@return [NamedTuple] The next piece set.