<commit_before>package de.movope.game

import spock.lang.Specification

class ChessGameTest extends Specification {

    def "white player has to make first move"() {
        when:
        ChessGame game = ChessGame.createNew("ben")

        then:
        game.nextPlayerToMove() == Color.WHITE
    }

    def "the color if the winning player is undefined in a new game "() {
        when:
        ChessGame game = ChessGame.createNew("ben")

        then:
        game.colorOfWinningPlayer() == Color.UNDEFINED
    }


    def "after move of white player, black player has to execute next move"() {
        given:
        ChessGame game = ChessGame.createNew("ben")

        when:
        game.execute(Move.create("A2", "A4"))

        then:
        game.nextPlayerToMove() == Color.BLACK
    }

    def "you can activate the computer for a color"() {
        given:
        ChessGame game = ChessGame.createNew("ben")

        when:
        game.activateComputeForColor(Color.BLACK)
        game.execute(Move.create("A2", "A4"))
        game.executeNextMoveForComputer();

        then:
        game.nextPlayerToMove() == Color.WHITE
    }

    def "a player can be game over"() {
        given:
        ChessGame game = ChessGame.createNew("ben")
        List<Move> movesToGameOver = createGameOverMoves()

        when:
        for (Move m : movesToGameOver) {
            game.execute(m)
        }
        ChessGameUtils.print(game.board)

        then:
        game.colorOfWinningPlayer() == Color.WHITE
    }

    def createGameOverMoves() {
        List<Move> moves = new ArrayList<>();
        moves.add(Move.create("E2", "E4"))
        moves.add(Move.create("F7", "F6"))
        moves.add(Move.create("D2", "D3"))<commit_msg>check if computer executes move<commit_after>package de.movope.game

import spock.lang.Specification

class ChessGameTest extends Specification {

    def "white player has to make first move"() {
        when:
        ChessGame game = ChessGame.createNew("ben")

        then:
        game.nextPlayerToMove() == Color.WHITE
    }

    def "the color if the winning player is undefined in a new game "() {
        when:
        ChessGame game = ChessGame.createNew("ben")

        then:
        game.colorOfWinningPlayer() == Color.UNDEFINED
    }


    def "after move of white player, black player has to execute next move"() {
        given:
        ChessGame game = ChessGame.createNew("ben")

        when:
        game.execute(Move.create("A2", "A4"))

        then:
        game.nextPlayerToMove() == Color.BLACK
    }

    def "you can activate the computer for a color and execute moves"() {
        given:
        ChessGame game = ChessGame.createNew("ben")
        def move = Move.create("A2", "A4")

        when:
        game.activateComputeForColor(Color.BLACK)
        game.execute(move)
        game.executeNextMoveForComputer();

        then:
        game.nextPlayerToMove() == Color.WHITE
        def boardWithMove = ChessBoard.createNew("ben")
        boardWithMove.execute(move)
        game.board.getSquaresWithPiece(Color.WHITE) == boardWithMove.getSquaresWithPiece(Color.WHITE)
        game.board.getSquaresWithPiece(Color.BLACK) != boardWithMove.getSquaresWithPiece(Color.BLACK)

    }

    def "a player can be game over"() {
        given:
        ChessGame game = ChessGame.createNew("ben")
        List<Move> movesToGameOver = createGameOverMoves()

        when:
        for (Move m : movesToGameOver) {
            game.execute(m)
        }
        ChessGameUtils.print(game.board)

        then:
        game.colorOfWinningPlayer() == Color.WHITE
    }

    def createGameOverMoves() {
        List<Move> moves = new ArrayList<>();
        moves.add(Move.create("E2", "E4"))
        moves.add(Move.create("F7", "F6"))
        moves.add(Move.create("D2", "D3"))
{'fraction_non_alphanumeric': 0.11444996080480795, 'fraction_numerical': 0.005226025607525477, 'mean_word_length': 2.3229166666666665, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6032343', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1160, 'n_words': 263}