예제 #1
0
파일: AIPlayer.cpp 프로젝트: flboudet/flobz
bool dropFlobos(const FloboBinom binom, GridState * const grid)
{
  int x, h, g;

  x = binom.position.x;
  h = columnHeight(x, grid);
  switch (binom.orientation)
  {
  case Above:
    if (h + 1 >= IA_FLOBOBAN_DIMY) return false;
    (*grid)[x][h]   = binom.falling;
    (*grid)[x][h+1] = binom.companion;
    (*grid)[x][HEIGHTS_ROW] = h + 2;
    break;

  case Below:
    if (h + 1 >= IA_FLOBOBAN_DIMY) return false;
    (*grid)[x][h+1] = binom.falling;
    (*grid)[x][h]   = binom.companion;
    (*grid)[x][HEIGHTS_ROW] = h + 2;
    break;

  case Left:
    if (h >= IA_FLOBOBAN_DIMY) return false;
    g = columnHeight(x-1, grid);
    if (g >= IA_FLOBOBAN_DIMY) return false;
    (*grid)[x][h]   = binom.falling;
    (*grid)[x-1][g] = binom.companion;
    ((*grid)[x][HEIGHTS_ROW]) = h + 1;
    ((*grid)[x-1][HEIGHTS_ROW]) = g + 1;
    break;

  case Right:
    if (h >= IA_FLOBOBAN_DIMY) return false;
    g = columnHeight(x+1, grid);
    if (g >= IA_FLOBOBAN_DIMY) return false;
    (*grid)[x][h]   = binom.falling;
    (*grid)[x+1][g] = binom.companion;
    ((*grid)[x][HEIGHTS_ROW]) = h + 1;
    ((*grid)[x+1][HEIGHTS_ROW]) = g + 1;
    break;
  }

  return true;
}
예제 #2
0
void RenderMultiColumnSet::computeLogicalHeight()
{
    // Make sure our column height is up to date.
    RenderMultiColumnBlock* parentBlock = toRenderMultiColumnBlock(parent());
    setColumnHeight(parentBlock->columnHeight()); // FIXME: Once we make more than one column set, this will become variable.
    
    // Our logical height is always just the height of our columns.
    setLogicalHeight(columnHeight());
}
예제 #3
0
파일: AIPlayer.cpp 프로젝트: flboudet/flobz
void evalWith(const GridState * const grid, const GridEvaluation * const originEvaluation, GridEvaluation * const realEvaluation)
{
  GridState tmp;
  GridEvaluation evaluation;

  // Evaluate the potential to destroy more flobos

  // for each flobo except the lower line and the columns top
  evaluation = nullEvaluation;
  for (int x = 0;  x < IA_FLOBOBAN_DIMX; x++)
  {
    int h = columnHeight(x, grid);
    if (h > realEvaluation->height) realEvaluation->height = h;
    
    h = stripedColumnHeight(x, grid);
    for (int y = 1;  y < h-1; y++)
    {
      // if free on the left or free on the right
      if ( ((x > 0) && ((*grid)[x-1][y] == FLOBO_EMPTY)) || ((x < IA_FLOBOBAN_DIMX-1) && ((*grid)[x+1][y] == FLOBO_EMPTY)))
      {
        // then try to remove it and see what happens
        copyGrid(&tmp,grid);
        tmp[x][y] = FLOBO_EMPTY;
        columnCompress(x,&tmp);
        evaluation = nullEvaluation;
        int r;
        for (r=0; suppressGroups(&tmp, &evaluation); r++) {};
        // if we used more than 1 round more neutrals willbe dropped to the ennemy
        if (r>1) evaluation.floboSuppressed += (r-1)*FLOBOBAN_DIMX;
        if (evaluation.floboSuppressed > realEvaluation->floboSuppressedPotential)
        {
          realEvaluation->floboSuppressedPotential = evaluation.floboSuppressed;
        }
      }
    }
  }
  
  // count the groups of more than 1 flobo
  evaluation = nullEvaluation;
  copyGrid(&tmp,grid);
  for (int x = 0;  x < IA_FLOBOBAN_DIMX; x++)
  {
    int h = stripedColumnHeight(x, grid);
    for (int y = 0;  y < h; y++)
    {
      if ((tmp[x][y] != FLOBO_EMPTY) && (tmp[x][y] != FLOBO_NEUTRAL))
      {
        countSameFloboAround(x, y, (FloboState)tmp[x][y], &tmp, &evaluation);
      }
    }
  }
  int d = evaluation.floboSuppressed - originEvaluation->floboSuppressed;
  if (d>0) realEvaluation->floboGrouped = d;
}
예제 #4
0
void RenderMultiColumnBlock::checkForPaginationLogicalHeightChange(LayoutUnit& /*pageLogicalHeight*/, bool& /*pageLogicalHeightChanged*/, bool& /*hasSpecifiedPageLogicalHeight*/)
{
    // We don't actually update any of the variables. We just subclassed to adjust our column height.
    updateLogicalHeight();
    LayoutUnit newContentLogicalHeight = contentLogicalHeight();
    m_requiresBalancing = !newContentLogicalHeight;
    if (!m_requiresBalancing) {
        // The regions will be invalidated when we lay them out and they change size to
        // the new column height.
        if (columnHeight() != newContentLogicalHeight)
            setColumnHeight(newContentLogicalHeight);
    }
    setLogicalHeight(0);
}
예제 #5
0
void RenderMultiColumnBlock::checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight)
{
    // We need to go ahead and set our explicit page height if one exists, so that we can
    // avoid doing multiple layout passes.
    computeLogicalHeight();
    LayoutUnit newContentLogicalHeight = contentLogicalHeight();
    if (newContentLogicalHeight > ZERO_LAYOUT_UNIT) {
        pageLogicalHeight = newContentLogicalHeight;
        hasSpecifiedPageLogicalHeight = true;
    }
    setLogicalHeight(ZERO_LAYOUT_UNIT);

    if (columnHeight() != pageLogicalHeight && everHadLayout()) {
        setColumnHeight(pageLogicalHeight);
        pageLogicalHeightChanged = true;
    }
    
    // Set up our column sets.
    ensureColumnSets();
}