package sudoku;

import java.util.ArrayList;
import java.util.Arrays;

import org.junit.jupiter.api.Test;

public class TestBlocParticuliers {

    @Test
    public void blocParticuliers() {
        System.out.println("TEST BLOC PARTICULIERS : ");
        System.out.println(new App().getGreeting());
        // Create a new Sudoku
        Sudoku sudoku = new Sudoku(4);

        sudoku.getGrille().setSymbolesPossibles(new ArrayList<>(Arrays.asList(
                Symbole.of(1),
                Symbole.of(2),
                Symbole.of(3),
                Symbole.of(4))));

        sudoku.ajouterContrainte(new ContrainteBloc());
        sudoku.ajouterContrainte(new ContrainteLigne());
        sudoku.ajouterContrainte(new ContrainteColonne());

        sudoku.getGrille().setCase(0, 0, Symbole.of(1));
        sudoku.getGrille().setCase(3, 1, Symbole.of(2));
        sudoku.getGrille().setCase(2, 2, Symbole.of(3));

        sudoku.getGrille().creerBlocPersonnalise(Arrays.asList(
                new int[] { 0, 0 },
                new int[] { 3, 3 },
                new int[] { 0, 1 },
                new int[] { 2, 3 }));
        sudoku.getGrille().creerBlocPersonnalise(Arrays.asList(
                new int[] { 0, 2 },
                new int[] { 1, 3 },
                new int[] { 1, 2 },
                new int[] { 3, 1 }));
        sudoku.getGrille().creerBlocPersonnalise(Arrays.asList(
                new int[] { 1, 1 },
                new int[] { 1, 0 },
                new int[] { 0, 3 },
                new int[] { 3, 0 }));
        sudoku.getGrille().creerBlocPersonnalise(Arrays.asList(
                new int[] { 2, 0 },
                new int[] { 2, 1 },
                new int[] { 2, 2 },
                new int[] { 3, 2 }));

        System.out.println("Sudoku :");
        System.out.println(sudoku.getGrille().toString());

        System.out.println("Blocs :");
        sudoku.getGrille().printBlocs();

        System.out.println("Symboles possibles :");
        sudoku.getGrille().printSymbolesPossibles();

        ResolveurBacktraceSimple resolveur = new ResolveurBacktraceSimple(sudoku);
        resolveur.resoudre(sudoku, true);

        System.out.println("Sudoku résolu :");
        System.out.println(sudoku.getGrille().toString());

        System.out.println("FIN TEST BLOC PARTICULIERS");
    }
}
