<commit_before>package boardgame.chess.core

import boardgame.core._

object ChessGame {
  def fromString(string: String, rules: ChessRules = ChessRules.default): ChessGame = {
    val (white, black) = (WhiteChessPlayer, BlackChessPlayer)
    val charVector = string.split('\n').mkString.zipWithIndex.toVector
    val grid = charVector map {
      case ('♜', i) ⇒ Some(new ♜(XY.fromI(i), white))
      case ('♞', i) ⇒ Some(new ♞(XY.fromI(i), white))
      case ('♝', i) ⇒ Some(new ♝(XY.fromI(i), white))
      case ('♛', i) ⇒ Some(new ♛(XY.fromI(i), white))
      case ('♚', i) ⇒ Some(new ♚(XY.fromI(i), white))
      case ('♟', i) ⇒ Some(new ♟(XY.fromI(i), white, rules.whitePawnDirection))
      case ('♖', i) ⇒ Some(new ♜(XY.fromI(i), black))
      case ('♘', i) ⇒ Some(new ♞(XY.fromI(i), black))
      case ('♗', i) ⇒ Some(new ♝(XY.fromI(i), black))
      case ('♕', i) ⇒ Some(new ♛(XY.fromI(i), black))
      case ('♔', i) ⇒ Some(new ♚(XY.fromI(i), black))
      case ('♙', i) ⇒ Some(new ♟(XY.fromI(i), black, rules.whitePawnDirection * -1))
      case _        ⇒ None
    }

    val enPassantPawns = charVector flatMap {
      case ('↑', i) ⇒ EnPassantPawn.fromXYD(XY.fromI(i), XY(0, -1), grid)
      case ('↓', i) ⇒ EnPassantPawn.fromXYD(XY.fromI(i), XY(0, 1), grid)
      case _        ⇒ None
    }

    // TODO: headOption means keep only the first; this is incorrect: if there's 2 there's a problem!
    new ChessGame(new ChessBoard(grid, enPassantPawns.headOption), rules)
  }

  val defaultGame: ChessGame = fromString(
    """♜♞♝♛♚♝♞♜
      |♟♟♟♟♟♟♟♟
      |........<commit_msg>Pieces don't need new keyword<commit_after>package boardgame.chess.core

import boardgame.core._

object ChessGame {
  def fromString(string: String, rules: ChessRules = ChessRules.default): ChessGame = {
    val (white, black) = (WhiteChessPlayer, BlackChessPlayer)
    val charVector = string.split('\n').mkString.zipWithIndex.toVector
    val grid = charVector map {
      case ('♜', i) ⇒ Some(♜(XY.fromI(i), white))
      case ('♞', i) ⇒ Some(♞(XY.fromI(i), white))
      case ('♝', i) ⇒ Some(♝(XY.fromI(i), white))
      case ('♛', i) ⇒ Some(♛(XY.fromI(i), white))
      case ('♚', i) ⇒ Some(♚(XY.fromI(i), white))
      case ('♟', i) ⇒ Some(♟(XY.fromI(i), white, rules.whitePawnDirection))
      case ('♖', i) ⇒ Some(♜(XY.fromI(i), black))
      case ('♘', i) ⇒ Some(♞(XY.fromI(i), black))
      case ('♗', i) ⇒ Some(♝(XY.fromI(i), black))
      case ('♕', i) ⇒ Some(♛(XY.fromI(i), black))
      case ('♔', i) ⇒ Some(♚(XY.fromI(i), black))
      case ('♙', i) ⇒ Some(♟(XY.fromI(i), black, rules.whitePawnDirection * -1))
      case _        ⇒ None
    }

    val enPassantPawns = charVector flatMap {
      case ('↑', i) ⇒ EnPassantPawn.fromXYD(XY.fromI(i), XY(0, -1), grid)
      case ('↓', i) ⇒ EnPassantPawn.fromXYD(XY.fromI(i), XY(0, 1), grid)
      case _        ⇒ None
    }

    // TODO: headOption means keep only the first; this is incorrect: if there's 2 there's a problem!
    new ChessGame(new ChessBoard(grid, enPassantPawns.headOption), rules)
  }

  val defaultGame: ChessGame = fromString(
    """♜♞♝♛♚♝♞♜
      |♟♟♟♟♟♟♟♟
      |........
{'fraction_non_alphanumeric': 0.2073015873015873, 'fraction_numerical': 0.0038095238095238095, 'mean_word_length': 3.0449293966623876, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3952547', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1343, 'n_words': 322}