<commit_before># Copyright (C) 2016 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the
# terms of the three-clause BSD license. See LICENSE.txt

PERFORM_CASTLING = ->(old_board, from, to, last_from, last_to) {
  ->(is_moving_left) {
    ->(rook_from, not_in_check, nop) {
      IF[
        AND[
          AND[
            # Moving an unmoved king
            IS_EQUAL[
              GET_POSITION[old_board, from],
              IS_BLACK_AT[old_board, from][BLACK_KING, WHITE_KING]
            ],
            # Moving an unmoved rook
            IS_EQUAL[
              GET_POSITION[old_board, rook_from],
              IS_BLACK_AT[old_board, rook_from][BLACK_ROOK, WHITE_ROOK]
            ]
          ],
          # The path is free
          FREE_PATH[old_board, from, rook_from, DECREMENT]
        ]
      ][
        ->() {
          IF[
            AND[
              AND[
                IS_NOT_IN_CHECK[old_board, from, from],
                IS_NOT_IN_CHECK[old_board, from, to],
              ],
              IS_NOT_IN_CHECK[
                old_board,
                from,
                PAIR[
                  is_moving_left[DECREMENT, INCREMENT][LEFT[from]],
                  RIGHT[from]
                ]
              ]
            ]
          ][
            -> {
              MOVE[
                MOVE[old_board, from, to],
                rook_from,
                PAIR[
                  is_moving_left[THREE, FIVE],
                  RIGHT[from]
                ]
              ]
            },
            nop
          ]
        },
        nop
      ]
    }[
      # "rook_from"
      PAIR[
        is_moving_left[ZERO, SEVEN],
        RIGHT[from]
      ],
      # "not_in_check"
      FIRST,
      # "nop"
      -> { old_board }
    ]
  }[
    # "is_moving_left"
    IS_GREATER_OR_EQUAL[LEFT[from], LEFT[to]]
  ]
}<commit_msg>Optimize PEFORM_CASTLING<commit_after># Copyright (C) 2016 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the
# terms of the three-clause BSD license. See LICENSE.txt

PERFORM_CASTLING = ->(old_board, from, to, last_from, last_to) {
  ->(is_moving_left) {
    ->(rook_from, nop, mid_to) {
      IF[
        AND[
          AND[
            # Moving an unmoved king
            IS_EQUAL[
              GET_POSITION[old_board, from],
              IS_BLACK_AT[old_board, from][BLACK_KING, WHITE_KING]
            ],
            # Moving an unmoved rook
            IS_EQUAL[
              GET_POSITION[old_board, rook_from],
              IS_BLACK_AT[old_board, rook_from][BLACK_ROOK, WHITE_ROOK]
            ]
          ],
          # The path is free
          FREE_PATH[old_board, from, rook_from, DECREMENT]
        ]
      ][
        ->() {
          IF[IS_NOT_IN_CHECK[old_board, from, from],][
            -> {
              IF[IS_NOT_IN_CHECK[old_board, from, mid_to]][
                -> {
                  IF[IS_NOT_IN_CHECK[old_board, from, to]][
                    -> {
                      MOVE[
                        MOVE[old_board, from, to],
                        rook_from,
                        PAIR[
                          is_moving_left[THREE, FIVE],
                          RIGHT[from]
                        ]
                      ]
                    },
                    nop
                  ]
                },
                nop
              ]
            },
            nop
          ]
        },
        nop
      ]
    }[
      # "rook_from"
      PAIR[
        is_moving_left[ZERO, SEVEN],
        RIGHT[from]
      ],
      # "nop"
      -> { old_board },
      # "mid_to"
      PAIR[
        is_moving_left[DECREMENT, INCREMENT][LEFT[from]],
        RIGHT[from]
      ]
    ]
  }[
    # "is_moving_left"
    IS_GREATER_OR_EQUAL[LEFT[from], LEFT[to]]
  ]
}
{'fraction_non_alphanumeric': 0.09848879624804585, 'fraction_numerical': 0.0020844189682126106, 'mean_word_length': 1.1422991071428572, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6896177', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1169, 'n_words': 209}