<commit_before>package Minesweeper;

import game.CharBoard;
import game.Coordinate;
import game.PieceType;

public class MinesweeperBoard extends CharBoard {

	/** This character represents a bomb */
	public static final PieceType BOMB = PieceType.X;
	/** This character represents a revealed square */
	public static final PieceType OPEN = PieceType.O;

	/** This 2d array shows the user the number of bombs around each square */
	private final int[][] visibleBoard;
	/**
	 * This board keeps track of the size of the board because the value is used
	 * often
	 */
	private final int size;
	/** This is the number of bombs that should be on the board */
	private final int numOfBombs;

	// The previous board tracks the revealed squares and the squares with bombs
	// on them

	public MinesweeperBoard(int size) {
		super(size);
		visibleBoard = new int[size][size];
		this.size = size;
		numOfBombs = (size * size + 4) / 5;
		generateVisibleBoard();
	}

	/**
	 * This method gives an initial value to every integer inside of the array
	 * corresponding to the number surrounding that square.
	 */
	public void generateVisibleBoard() {
		for (int j = 0; j < size; j++) {
			for (int i = 0; i < size; i++) {

				if (getBoard()[j][i] == BOMB.getChar())
					visibleBoard[j][i] = 9; // a value of 9 means that the
											// square has a bomb on it
				else
					visibleBoard[j][i] = numOfSurroundingBombs(j, i);
			}
		}
	}
<commit_msg>add randomly place bombs method<commit_after>package Minesweeper;

import game.CharBoard;
import game.Coordinate;
import game.PieceType;

public class MinesweeperBoard extends CharBoard {

	/** This character represents a bomb */
	public static final PieceType BOMB = PieceType.X;
	/** This character represents a revealed square */
	public static final PieceType OPEN = PieceType.O;

	/** This 2d array shows the user the number of bombs around each square */
	private final int[][] visibleBoard;
	/**
	 * This board keeps track of the size of the board because the value is used
	 * often
	 */
	private final int size;
	/** This is the number of bombs that should be on the board */
	private final int numOfBombs;

	// The previous board tracks the revealed squares and the squares with bombs
	// on them

	public MinesweeperBoard(int size) {
		super(size);
		visibleBoard = new int[size][size];
		this.size = size;
		numOfBombs = (size * size + 4) / 5;
		randomlyPlaceBombs();
		generateVisibleBoard();
		
		// debugging purposes
		System.out.println(numOfBombs);
		System.out.println("Debugging:");
		super.toString();
	}
	
	public void randomlyPlaceBombs() {
		int x, y;
		Coordinate c;
		
		for(int i = numOfBombs; i > 0; i--) {
			x = (int)(Math.random() * size);
			y = (int)(Math.random() * size);
			c = new Coordinate (x, y);
			while(!isEmpty(c)) {
				x = (int)(Math.random() * size);
				y = (int)(Math.random() * size);
				
				c = new Coordinate(x, y);
			}
			getBoard()[y][x] = BOMB.getChar();
		}
	}

	/**
	 * This method gives an initial value to every integer inside of the array
	 * corresponding to the number surrounding that square.
	 */
	public void generateVisibleBoard() {
		for (int j = 0; j < size; j++) {
			for (int i = 0; i < size; i++) {

				if (getBoard()[j][i] == BOMB.getChar())
					visibleBoard[j][i] = 9; // a value of 9 means that the
											// square has a bomb on it
				else
					visibleBoard[j][i] = numOfSurroundingBombs(j, i);
			}
		}
	}

{'fraction_non_alphanumeric': 0.11570970562518217, 'fraction_numerical': 0.004371903235208394, 'mean_word_length': 3.19559902200489, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '2486440', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1075, 'n_words': 402}