<commit_before>import uucki.game.reversi.Board;
import uucki.game.reversi.PossibleMoves;
import uucki.algorithm.Algorithm;
import uucki.algorithm.Minimax;
import uucki.type.FieldValue;
import uucki.type.Move;
import uucki.type.Position;
import uucki.heuristic.reversi.Basic;
import uucki.graphics.reversi.Window;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        try {
            System.out.println("Board position, is black top left? (y/n)");
            boolean blackTopLeft = br.readLine().equals("y");

            System.out.println("Am I starting? (y/n)");
            boolean imStarting = br.readLine().equals("y");

            System.out.println("Am I black? (y/n)");
            FieldValue myColor = br.readLine().equals("y") ? FieldValue.BLACK : FieldValue.WHITE;

            Board board = initialBoard(blackTopLeft);
            game(board, imStarting, myColor);
        } catch (IOException e) {
            System.out.println("IO error, start again");
        }
    }

    public static void game(Board board, boolean imStarting, FieldValue color) {
        FieldValue opponentColor = FieldValue.WHITE == color ? FieldValue.BLACK : FieldValue.WHITE;
        board.print();

        Window window = new Window();
        window.update(board);

        Algorithm minimax = new Minimax();

        if(imStarting) {
            Move move = minimax.run(board, color);
            board = board.makeMove(move);
            window.update(board);
        }
        while(!board.isFinished()) {
            if(PossibleMoves.getValidPositions(board, opponentColor).size() > 0) {
                List<Position> validPositions = PossibleMoves.getValidPositions(board, opponentColor);
                Position newPosition = null;
                while(newPosition == null) {
                    System.out.println("Make your move");
                    newPosition = window.getPosition();
                    if(!validPositions.contains(newPosition)) {
                        newPosition = null;
                    }
                }
                board = board.makeMove(new Move(newPosition, opponentColor));
                window.update(board);
            }

            //Computer move
            Move move = minimax.run(board, color);
            board = board.makeMove(move);
            window.update(board);
        }
    }

    public static Board initialBoard(boolean blackTopLeft) {
        Board board = new Board();

        if(blackTopLeft) {
            board = board.makeMove(new Move(3,3,FieldValue.BLACK));
            board = board.makeMove(new Move(4,4,FieldValue.BLACK));
            board = board.makeMove(new Move(3,4,FieldValue.WHITE));
            board = board.makeMove(new Move(4,3,FieldValue.WHITE));
        } else {
            board = board.makeMove(new Move(3,3,FieldValue.WHITE));
            board = board.makeMove(new Move(4,4,FieldValue.WHITE));
            board = board.makeMove(new Move(3,4,FieldValue.BLACK));
            board = board.makeMove(new Move(4,3,FieldValue.BLACK));
        }
        return board;
    }
}<commit_msg>if the computer have no moves, skip over it<commit_after>import uucki.game.reversi.Board;
import uucki.game.reversi.PossibleMoves;
import uucki.algorithm.Algorithm;
import uucki.algorithm.Minimax;
import uucki.type.FieldValue;
import uucki.type.Move;
import uucki.type.Position;
import uucki.heuristic.reversi.Basic;
import uucki.graphics.reversi.Window;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        try {
            System.out.println("Board position, is black top left? (y/n)");
            boolean blackTopLeft = br.readLine().equals("y");

            System.out.println("Am I starting? (y/n)");
            boolean imStarting = br.readLine().equals("y");

            System.out.println("Am I black? (y/n)");
            FieldValue myColor = br.readLine().equals("y") ? FieldValue.BLACK : FieldValue.WHITE;

            Board board = initialBoard(blackTopLeft);
            game(board, imStarting, myColor);
        } catch (IOException e) {
            System.out.println("IO error, start again");
        }
    }

    public static void game(Board board, boolean imStarting, FieldValue color) {
        FieldValue opponentColor = FieldValue.WHITE == color ? FieldValue.BLACK : FieldValue.WHITE;
        board.print();

        Window window = new Window();
        window.update(board);

        Algorithm minimax = new Minimax();

        if(imStarting) {
            Move move = minimax.run(board, color);
            board = board.makeMove(move);
            window.update(board);
        }
        while(!board.isFinished()) {
            if(PossibleMoves.getValidPositions(board, opponentColor).size() > 0) {
                List<Position> validPositions = PossibleMoves.getValidPositions(board, opponentColor);
                Position newPosition = null;
                while(newPosition == null) {
                    System.out.println("Make your move");
                    newPosition = window.getPosition();
                    if(!validPositions.contains(newPosition)) {
                        newPosition = null;
                    }
                }
                board = board.makeMove(new Move(newPosition, opponentColor));
                window.update(board);
            }

            //Computer move
            Move move = minimax.run(board, color);
            if(move != null) {
                board = board.makeMove(move);
                window.update(board);
            }
        }
    }

    public static Board initialBoard(boolean blackTopLeft) {
        Board board = new Board();

        if(blackTopLeft) {
            board = board.makeMove(new Move(3,3,FieldValue.BLACK));
            board = board.makeMove(new Move(4,4,FieldValue.BLACK));
            board = board.makeMove(new Move(3,4,FieldValue.WHITE));
            board = board.makeMove(new Move(4,3,FieldValue.WHITE));
        } else {
            board = board.makeMove(new Move(3,3,FieldValue.WHITE));
            board = board.makeMove(new Move(4,4,FieldValue.WHITE));
            board = board.makeMove(new Move(3,4,FieldValue.BLACK));
            board = board.makeMove(new Move(4,3,FieldValue.BLACK));
        }
        return board;
    }
}
{'fraction_non_alphanumeric': 0.11740394918108067, 'fraction_numerical': 0.005204347160569417, 'mean_word_length': 2.14436958614052, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6374578', 'n_tokens_mistral': 1874, 'n_tokens_neox': 1810, 'n_words': 370}