private void setBoard(DetectedField detectedField, List <int[]> puppetList) //Tábla tartalmának beállítása a nem megfelelő bábú elhelyezkedések figyelésére. { int[,] puppetMatrix = new int[detectedField.rowCount, detectedField.colCount]; setLocation(detectedField); //Miután megvan hogy mely mezők hol vannak, végignézem az xoListet. int xe = detectedField.rowCount; int ye = detectedField.colCount; //Kezdetben -1 értéket vesz fel az összes mező (ott nincs bábu). for (int x = 0; x < xe; x++) { for (int y = 0; y < ye; y++) { puppetMatrix[x, y] = -1; } } //Mátrix adott pozíciójára a megfelelő bábú érték beállítása. for (int col = 0; col < xe; col++) { for (int row = 0; row < ye; row++) { foreach (int[] xo in puppetList) //foreach (DetectedPuppet xo in puppetList) { byte errorBit = 0; //if (isRectInRect(xo.puppetRect, boxBounds[col, row], out errorBit)) if (isRectInRect(new Rectangle(xo[0], xo[1], xo[2], xo[3]), boxBounds[col, row], out errorBit)) { //if (xo.puppetValue.Equals("O")) if (xo[4] == 0) { if (puppetMatrix[col, row] > -1) { puppetMatrix[col, row] = 3; //Több bábú egy mezőben. board.setPieces(col, row, Piece._MoreThan1); } else { puppetMatrix[col, row] = 0; //O board.setPieces(col, row, Piece.O); } } else { if (puppetMatrix[col, row] > -1) { puppetMatrix[col, row] = 3; //Több bábú egy mezőben. board.setPieces(col, row, Piece._MoreThan1); } else { puppetMatrix[col, row] = 1; //X board.setPieces(col, row, Piece.X); } } if (errorBit == 1 && puppetMatrix[col, row] < 3) { puppetMatrix[col, row] = 2; //Bábú kilógás. board.setPieces(col, row, Piece._OutOfField); } } } } } //Üres mező értékek felvitele. for (int i = 0; i < detectedField.rowCount; i++) { for (int j = 0; j < detectedField.colCount; j++) { if (puppetMatrix[i, j] == -1) { board.setPieces(i, j, Piece._Empty); } } } }
private void setBoard(DetectedField detectedField, List <DetectedPuppet> puppetList) { int[,] puppetMatrix = new int[detectedField.rowCount, detectedField.colCount]; setLocation(detectedField); //miután megvan hogy mely mezők hol vannak, végignézem az xoListet int xe = detectedField.rowCount; int ye = detectedField.colCount; //kezdetben -1 értéket vesz fel az összes mező (ott nincs bábu) for (int x = 0; x < xe; x++) { for (int y = 0; y < ye; y++) { puppetMatrix[x, y] = -1; } } for (int col = 0; col < xe; col++) { for (int row = 0; row < ye; row++) { foreach (DetectedPuppet xo in puppetList) { byte errorBit = 0; if (isRectInRect(xo.puppetRect, boxBounds[col, row], out errorBit)) { if (xo.puppetValue.Equals("O")) { if (puppetMatrix[col, row] > -1) { puppetMatrix[col, row] = 3; //two puppets in one box board.setPieces(col, row, Piece._MoreThan1); } else { puppetMatrix[col, row] = 0; //O board.setPieces(col, row, Piece.O); } } else { if (puppetMatrix[col, row] > -1) { puppetMatrix[col, row] = 3; //two puppets in one box board.setPieces(col, row, Piece._MoreThan1); } else { puppetMatrix[col, row] = 1; //X board.setPieces(col, row, Piece.X); } } if (errorBit == 1 && puppetMatrix[col, row] < 3) { puppetMatrix[col, row] = 2; //outOfBox board.setPieces(col, row, Piece._OutOfField); } } } } } }