Exemplo n.º 1
0
/**
 * Konstruktor siatki danych.
 */
SDataGrid::SDataGrid()
{
	debug("CONSTRUCTOR data-grid START\n");
	max_index = 0;
	size_x = 100;
	size_y = 1;
	constructGrid();
	zeroGrid();
	debug("CONSTRUCTOR data-grid END\n");
}
Exemplo n.º 2
0
//**********************************************************************
// void CWorldSquare::build()
// Build
//**********************************************************************
void CWorldSquare::build() {
#ifndef OPTIMIZE
  try {
#endif

    // Get our Values From World
    CWorld *pWorld = CWorld::Instance();
    iNumberOfCategories = pWorld->getCategoryCount();
    iMinAge             = pWorld->getMinAge();
    iMaxAge             = pWorld->getMaxAge();
    bAgePlus            = pWorld->getAgePlusGroup();

#ifndef OPTIMIZE
    if (iNumberOfCategories <= 0)
      CError::errorMissing(PARAM_CATEGORIES);
    if (iMinAge < 0)
      CError::errorMissing(PARAM_MIN_AGE);
    if (iMaxAge <= 0)
      CError::errorMissing(PARAM_MAX_AGE);
    if (iMaxAge < iMinAge)
      CError::errorLessThan(PARAM_MAX_AGE, PARAM_MIN_AGE);
#endif

    // Build our Grid
    iHeight = iNumberOfCategories;
    iWidth  = (iMaxAge+1)-iMinAge;

    pGrid = new double*[iHeight];
    for (int i = 0; i < iHeight; ++i)
      pGrid[i] = new double[iWidth];

    // Zero it
    zeroGrid();

#ifndef OPTIMIZE
  } catch (string &Ex) {
    Ex = "CWorldSquare.build()->" + Ex;
    throw Ex;
  }
#endif
}
Exemplo n.º 3
0
/**
 * Czyści komórki siatki danych.
 */
void SDataGrid::clear()
{
	zeroGrid();
}
Exemplo n.º 4
0
bool removeSameFloboAround(int X, int Y, const FloboState color, GridState * const tab, GridEvaluation * const evaluation)
{
  GridState marked;
  unsigned char mx[IA_FLOBOBAN_DIMY*IA_FLOBOBAN_DIMX];
  unsigned char my[IA_FLOBOBAN_DIMX*IA_FLOBOBAN_DIMY];
  int  nFound = 1;

  mx[0] = X;
  my[0] = Y;

  zeroGrid(&marked);
  marked[X][Y] = 1;

  for (int i=0; i<nFound; i++) {

    X = mx[i];
    Y = my[i];

    if (Y+1<IA_FLOBOBAN_DIMY) {
      if (marked[X][Y+1] == 0) {
        if ((*tab)[X][Y+1] == color) {
          mx[nFound] = X;
          my[nFound] = Y+1;
          nFound++;
        }
        marked[X][Y+1] = 1;
      }
    }
    if (Y>0) {
      if (marked[X][Y-1] == 0) {
        if ((*tab)[X][Y-1] == color) {
          mx[nFound] = X;
          my[nFound] = Y-1;
          nFound++;
        }
        marked[X][Y-1] = 1;
      }
    }
    if (X+1<IA_FLOBOBAN_DIMX) {
      if (marked[X+1][Y] == 0) {
        if ((*tab)[X+1][Y] == color) {
          mx[nFound] = X+1;
          my[nFound] = Y;
          nFound++;
        }
        marked[X+1][Y] = 1;
      }
    }
    if (X>0) {
      if (marked[X-1][Y] == 0) {
        if ((*tab)[X-1][Y] == color) {
          mx[nFound] = X-1;
          my[nFound] = Y;
          nFound++;
        }
        marked[X-1][Y] = 1;
      }
    }
  }

  if (nFound < 4)
  {
    return false;
  }

  evaluation->floboSuppressed += nFound;

  for (int i = 0; i < nFound; i++)
  {
    X = mx[i];
    Y = my[i];

    (*tab)[X][Y] = FLOBO_EMPTY;

    if ((Y+1<IA_FLOBOBAN_DIMY) && ((*tab)[X][Y+1] == FLOBO_NEUTRAL)) {
        (*tab)[X][Y+1] = FLOBO_EMPTY;
        evaluation->neutralSuppressed++;
    }
    if ((Y>0) && ((*tab)[X][Y-1] == FLOBO_NEUTRAL)) {
        (*tab)[X][Y-1] = FLOBO_EMPTY;
        evaluation->neutralSuppressed++;
    }
    if ((X+1<IA_FLOBOBAN_DIMX) && ((*tab)[X+1][Y] == FLOBO_NEUTRAL)) {
        (*tab)[X+1][Y] = FLOBO_EMPTY;
        evaluation->neutralSuppressed++;
    }
    if ((X>0) && ((*tab)[X-1][Y] == FLOBO_NEUTRAL)) {
        (*tab)[X-1][Y] = FLOBO_EMPTY;
        evaluation->neutralSuppressed++;
    }
  }

  return true;
}