package net.woodyfolsom.msproj;

import java.math.BigInteger;
import java.security.SecureRandom;

public class ZobristHashGenerator {
	private long[] randomBitFields;

	private ZobristHashGenerator() {
	}

	public static ZobristHashGenerator getInstance(int boardSize) {
		int nRandomFields = 3 * boardSize * boardSize;
		ZobristHashGenerator zobHashGen = new ZobristHashGenerator();
		SecureRandom secureRandom = new SecureRandom();
		zobHashGen.randomBitFields = new long[nRandomFields];
		byte[] nextBytes = new byte[8];
		for (int i = 0; i < nRandomFields; i++) {
			secureRandom.nextBytes(nextBytes);
			zobHashGen.randomBitFields[i] = new BigInteger(nextBytes)
					.longValue();
		}
		// TODO add check for minimum hamming distance/colinearity check
		return zobHashGen;
	}

}
