/// <summary> /// Constructor. /// </summary> /// <param name="maxPositions"></param> /// <param name="inputsRequired"></param> public EncodedPositionBatchBuilder(int maxPositions, NNEvaluator.InputTypes inputsRequired) { MaxPositions = maxPositions; InputsRequired = inputsRequired; pendingPositions = new EncodedPositionWithHistory[MaxPositions]; batch = new EncodedPositionBatchFlat(EncodedPositionType.PositionAndTrainingData, MaxPositions); if (InputsRequired.HasFlag(NNEvaluator.InputTypes.Positions)) { batch.Positions = new MGPosition[MaxPositions]; } if (InputsRequired.HasFlag(NNEvaluator.InputTypes.Hashes)) { batch.PositionHashes = new ulong[MaxPositions]; } if (InputsRequired.HasFlag(NNEvaluator.InputTypes.Moves)) { batch.Moves = new MGMoveList[MaxPositions]; } }
public IEncodedPositionBatchFlat GetSubBatchCopied(int startIndex, int count) { float[] w = null; float[] l = null; if (W != null) { w = new float[count]; Array.Copy(W, startIndex, w, 0, count); } if (L != null) { l = new float[count]; Array.Copy(L, startIndex, l, 0, count); } byte[] posPlaneValuesEncoded = new byte[count * EncodedPositionWithHistory.NUM_PLANES_TOTAL]; Array.Copy(PosPlaneValues, startIndex * EncodedPositionWithHistory.NUM_PLANES_TOTAL, posPlaneValuesEncoded, 0, count * EncodedPositionWithHistory.NUM_PLANES_TOTAL); ulong[] posPlaneBitmaps = new ulong[count * EncodedPositionWithHistory.NUM_PLANES_TOTAL]; Array.Copy(PosPlaneBitmaps, startIndex * EncodedPositionWithHistory.NUM_PLANES_TOTAL, posPlaneBitmaps, 0, count * EncodedPositionWithHistory.NUM_PLANES_TOTAL); EncodedPositionBatchFlat ret = new EncodedPositionBatchFlat(posPlaneBitmaps, posPlaneValuesEncoded, w, l, null, count); if (Positions != null) { ulong[] hashes = new ulong[count]; MGPosition[] positionsMG = new MGPosition[count]; MGMoveList[] moves = new MGMoveList[count]; Array.Copy(PositionHashes, startIndex, hashes, 0, count); Array.Copy(Positions, startIndex, positionsMG, 0, count); Array.Copy(Moves, startIndex, moves, 0, count); ret.PositionHashes = hashes; ret.Positions = positionsMG; ret.Moves = moves; } return(ret); }