Class: Egd::FenDifferenceDiscerner
- Inherits:
-
Object
- Object
- Egd::FenDifferenceDiscerner
- Defined in:
- lib/egd/fen_difference_discerner.rb
Instance Attribute Summary collapse
-
#end_fen ⇒ Object
readonly
Theoretically a start and end fen would suffice, but having move in SAN, which we do, allows skipping some hard procesing parts.
-
#move ⇒ Object
readonly
Theoretically a start and end fen would suffice, but having move in SAN, which we do, allows skipping some hard procesing parts.
-
#start_fen ⇒ Object
readonly
Theoretically a start and end fen would suffice, but having move in SAN, which we do, allows skipping some hard procesing parts.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(start_fen: nil, move:, end_fen:) ⇒ FenDifferenceDiscerner
constructor
Egd::FenDifferenceDiscerner.new(start_fen:, end_fen:).call.
Constructor Details
#initialize(start_fen: nil, move:, end_fen:) ⇒ FenDifferenceDiscerner
Egd::FenDifferenceDiscerner.new(start_fen:, end_fen:).call
13 14 15 16 17 |
# File 'lib/egd/fen_difference_discerner.rb', line 13 def initialize(start_fen: nil, move:, end_fen:) @start_fen = start_fen || Egd::FenBuilder::NULL_FEN @move = move @end_fen = end_fen end |
Instance Attribute Details
#end_fen ⇒ Object (readonly)
Theoretically a start and end fen would suffice, but having move in SAN, which we do, allows skipping some hard procesing parts.
10 11 12 |
# File 'lib/egd/fen_difference_discerner.rb', line 10 def end_fen @end_fen end |
#move ⇒ Object (readonly)
Theoretically a start and end fen would suffice, but having move in SAN, which we do, allows skipping some hard procesing parts.
10 11 12 |
# File 'lib/egd/fen_difference_discerner.rb', line 10 def move @move end |
#start_fen ⇒ Object (readonly)
Theoretically a start and end fen would suffice, but having move in SAN, which we do, allows skipping some hard procesing parts.
10 11 12 |
# File 'lib/egd/fen_difference_discerner.rb', line 10 def start_fen @start_fen end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/egd/fen_difference_discerner.rb', line 19 def call # quickreturn with possible special cases case move when "O-O" return special_case_short_castle(Egd::Procedures.parse_fen(start_fen)[:to_move]) when "O-O-O" return special_case_long_castle(Egd::Procedures.parse_fen(start_fen)[:to_move]) when %r'\A[a-h]x[a-h]\d' # pawn x pawn, possible en-passant return special_case_ep_capture if special_case_ep_capture end # entering long processing of regular moves changes = { "lran" => lran, # FEN "from_square" => from_square, # FEN # b2 "to_square" => to_square, # move b3 "piece" => piece, # move p "move_type" => move_type, } changes.merge!("captured_piece" => captured_piece) if captured_piece changes.merge!("promotion" => promotion) if promotion changes end |