<commit_before>package com.cs.games.mancala.model;

import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.*;
import java.util.stream.Collectors;

/**
 * An immutable representation of the current state of the Mancala game - cups and beads; and who's turn it is
 *
 * <pre>
 *
 *
 *   --------------&gt;------------------
 *   |   | 0 | 1 | 2 | 3 | 4 | 5 |   |  Player 1
 *   |13 |-----------------------| 6 |
 *   |   |12 |11 |10 | 9 | 8 | 7 |   |  Player 2
 *   --------------&lt;------------------
 *
 *
 * </pre>
 *
 * @author <A
 * HREF="mailto:<EMAIL>?subject=com.cs.games.mancala.model.Board">Chris
 * Senior </A>
 */
@EqualsAndHashCode
@ToString
public class Board {
    /**
     * The bead counts in the cups. Indexed by {@link Cup#index()}
     */
    private final int[] beads;
    /**
     * The scores for each player
     */
    private final int[] scores;
    /**
     * The player who makes the next move
     */
    private final Player nextPlayer;
    /**
     * The cups which are valid moves for the {@link #nextPlayer}
     */
    private final List<Cup> nextMoves;

    public Board(int[] beads, Player nextPlayer) {
        this.beads = beads;
        this.nextPlayer = nextPlayer;
        this.scores = new int[]{calcScore(Player.ONE), calcScore(Player.TWO)};
        this.nextMoves = calcNextMoves();
        checksum();
    }

    public Board(int[] beads, Player nextPlayer, int[] scores, List<Cup> nextMoves) {
        this.beads = beads;
        this.nextPlayer = nextPlayer;
        this.scores = scores;
        this.nextMoves = nextMoves;
        checksum();
    }

    public void checksum() {
        if (Arrays.asList(beads).stream().count() == 48) {
            throw new IllegalStateException("Count of beads is not 48!!");
        }
    }

    public static Board initialBoard() {
        return new Board(initialBeads(), Player.ONE);
    }

    private static int[] initialBeads() {
        return new int[]{4,4,4,4,4,4,0,4,4,4,4,4,4,0};
    }

    private int calcScore(Player player) {
        int score = 0;<commit_msg>Checksum of scores and beads<commit_after>package com.cs.games.mancala.model;

import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.*;
import java.util.stream.Collectors;

/**
 * An immutable representation of the current state of the Mancala game - cups and beads; and who's turn it is
 *
 * <pre>
 *
 *
 *   --------------&gt;------------------
 *   |   | 0 | 1 | 2 | 3 | 4 | 5 |   |  Player 1
 *   |13 |-----------------------| 6 |
 *   |   |12 |11 |10 | 9 | 8 | 7 |   |  Player 2
 *   --------------&lt;------------------
 *
 *
 * </pre>
 *
 * @author <A
 * HREF="mailto:<EMAIL>?subject=com.cs.games.mancala.model.Board">Chris
 * Senior </A>
 */
@EqualsAndHashCode
@ToString
public class Board {
    /**
     * The bead counts in the cups. Indexed by {@link Cup#index()}
     */
    private final int[] beads;
    /**
     * The scores for each player
     */
    private final int[] scores;
    /**
     * The player who makes the next move
     */
    private final Player nextPlayer;
    /**
     * The cups which are valid moves for the {@link #nextPlayer}
     */
    private final List<Cup> nextMoves;

    public Board(int[] beads, Player nextPlayer) {
        this.beads = beads;
        this.nextPlayer = nextPlayer;
        this.scores = new int[]{calcScore(Player.ONE), calcScore(Player.TWO)};
        this.nextMoves = calcNextMoves();
        checksum();
    }

    public Board(int[] beads, Player nextPlayer, int[] scores, List<Cup> nextMoves) {
        this.beads = beads;
        this.nextPlayer = nextPlayer;
        this.scores = scores;
        this.nextMoves = nextMoves;
        checksum();
    }

    public void checksum() {
        int beadCount = 0;
        for(int i=0; i < 14; i++) {
            beadCount += beads[i];
        }
        if(beadCount != 48 ) {
            throw new IllegalStateException("Count of beads is not 48!!");
        }

        int scoreCount = scores[0] + scores[1];
        if(scoreCount != 48 ) {
            throw new IllegalStateException("Count of scores is not 48!!");
        }
    }

    public static Board initialBoard() {
        return new Board(initialBeads(), Player.ONE);
    }

    private static int[] initialBeads() {
        return new int[]{4,4,4,4,4,4,0,4,4,4,4,4,4,0};
    }

    private int calcScore(Player player) {
        int score = 0;
{'fraction_non_alphanumeric': 0.168625678119349, 'fraction_numerical': 0.019891500904159132, 'mean_word_length': 2.0225409836065573, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3743982', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1384, 'n_words': 384}