Example #1
0
void AStar::addCellsRook(int x, int y, double cc)
{
   addCell(x-1, y, getCostRook(cc, x-1, y), LEFT);
   addCell(x+1, y, getCostRook(cc, x+1, y), RIGHT);
   addCell(x, y-1, getCostRook(cc, x, y-1), TOP);
   addCell(x, y+1, getCostRook(cc, x, y+1), BOTTOM);
}
Example #2
0
Bed::Bed(PPoint point, bool rotate):TileCell()
{
	std::string path1 = PATH_OBJECT "bed1";
	std::string path2 = PATH_OBJECT "bed2";

	setPosition(point);
	addCell(path1, !rotate, false);
	addCell(PPoint(1, 0), path2, !rotate, false);
}
Example #3
0
void Board::landPiece()
{
	m_shift_timer->stop();

	int type = m_piece->type();
	int top_cell_y = 19; // Y-coordinate of top-most cell.
	const Cell* cells = m_piece->cells();
	for (int i = 0; i < 4; ++i) {
		addCell(cells[i].x, cells[i].y, type);
		top_cell_y = qMin(top_cell_y, cells[i].y);
	}
	delete m_piece;
	m_piece = 0;

	findFullLines();
	if (m_full_lines[0] != -1) {
		m_flash_timer->start();
	} else {
		if (top_cell_y < m_topCellY) {
			// Height of stack increased.
			m_topCellY = top_cell_y;
		}
		createPiece();
	}
}
Example #4
0
void DiamondAoE::extrapole()
{
	if (_center && _len > 0)
	{
		int centerX = _center->getPosX();
		int centerY = _center->getPosY();
		for (int i = centerX - _len; i <= centerX + _len; i++)
		{
			for (int j = centerY - _len; j <= centerY + _len; j++)
			{
				Cell* cell = GAMEINST->getGrid()->getCellAt(i, j);
				if (cell)
					if (_center->getDistance(*cell) <= _len)
						addCell(cell);
			}
		}
		/*for (int i = -_len / 2 + 1; i < _center->getPosX() + _len / 2 + 1; i++)
		{
			for (int j = -_len / 2 + 1; j < _center->getPosY() + _len / 2 + 1; j++)
			{
				Cell* cell = GAMEINST->getGrid()->getCellAt(_center->getPosX() + i, _center->getPosY() + j);
				if (cell)
					if(_center->getDistance(*cell) <= _len)
						addCell(cell);
			}
		}*/
	}
}
Example #5
0
bool Map::Generate(Geology* RegionGeology)
{
    CellSizeX = 3;
    CellSizeY = 3;

    MapSizeX = CellSizeX * CELLEDGESIZE;
    MapSizeY = CellSizeY * CELLEDGESIZE;
    //MapSizeZ = CellSizeZ;

    // Create and add Cells with shape and material data
    for (uint16_t X = 0; X < CellSizeX; X++)
    {
        for (uint16_t Y = 0; Y < CellSizeX; Y++)
        {
            int Z = 0; //get From Geology

            CellCoordinates TargetCellCoordinates = CellCoordinates(X, Y, Z);
            Cell* NewCell = new Cell();
            NewCell->setPosition(TargetCellCoordinates);

            addCell(NewCell, TargetCellCoordinates);
            NewCell->LoadCellData(MapGeology);
        }
    }

    // Initialize Faces for the cells
    for(std::map<uint64_t, Cell*>::iterator CellIterator = Cells.begin() ; CellIterator != Cells.end(); ++CellIterator )
    {
        CellIterator->second->Init();
    }

    return true;
}
Example #6
0
int isCrashed(int coord_x, int coord_y, int Field[SIZE_FIELD_SQUARE][SIZE_FIELD_SQUARE], QGraphicsScene *scene)
{
    int x_up = coord_x;
    int y_up = coord_y;
    int x_down = coord_x;
    int y_down = coord_y;

    while ((Field[coord_y][x_up] == HIT) && (x_up > 0))     //can`t shoot around the crushed ship
        if(Field[coord_y][--x_up] == BUSY)
            return 0;

    while ((Field[y_up][coord_x] == HIT) && (y_up > 0))
        if(Field[--y_up][coord_x] == BUSY)
            return 0;

    while ((Field[coord_y][x_down] == HIT) && (x_down < SIZE_FIELD_SQUARE - 1))
        if(Field[coord_y][++x_down] == BUSY)
            return 0;

    while ((Field[y_down][coord_x] == HIT) && (y_down < SIZE_FIELD_SQUARE - 1))
        if(Field[++y_down][coord_x] == BUSY)
            return 0;

    for(int i = y_up; i < y_down + 1; i++)
        for(int j = x_up; j < x_down + 1; j++)
            if((Field[i][j] != HIT) && (Field[i][j] != MISS))
            {
                Field[i][j] = MISS;
                addCell(j, i, scene);
            }
    return 1;
}
Example #7
0
/**
 * @brief Subdivides all of the Cells within this Universe into rings
 *        and angular sectors.
 */
void Universe::subdivideCells() {

  log_printf(DEBUG, "Subdividing Cells for Universe %d", _id);

  std::map<int, Cell*>::iterator iter1;

  while (iter1 != _cells.end()) {

    for (iter1 = _cells.begin(); iter1 != _cells.end(); ++iter1) {

      if ((*iter1).second->getType() == MATERIAL) {
        CellBasic* cell = static_cast<CellBasic*>((*iter1).second);

        if (cell->getNumRings() > 0 || cell->getNumSectors() > 0) {
          std::vector<CellBasic*> newcells = cell->subdivideCell();

          log_printf(DEBUG, "Cell %d in Universe %d has %d subcells",
                     cell->getId(), _id, newcells.size());

          std::vector<CellBasic*>::iterator iter2;
          for (iter2=newcells.begin(); iter2!=newcells.end(); ++iter2)
            addCell((*iter2));

          _cells.erase(iter1);
          break;
        }
      }
    }
  }
}
/*!
    \fn k9CellCopyList::fill()
 */
void k9CellCopyList::fill() {
//    k9Ifo2 kifo(dvdHandle) ,kifoZero(dvdHandle);
    ifo_handle_t *hifo,*hifoZero;
    k9Ifo2 *kifo,*kifoZero;
    kifoZero=dvdHandle->getIfo(0);
    hifoZero=kifoZero->getIFO();

//    kifoZero.openIFO( 0);

    int nrTS= hifoZero->vmgi_mat->vmg_nr_of_title_sets;

    for (int iTS=1 ; iTS<=nrTS; iTS++) {
        //kifo.openIFO( iTS);
        kifo=dvdHandle->getIfo(iTS);
        hifo=kifo->getIFO();
        c_adt_t *c_adt = hifo->vts_c_adt;
        uint32_t length = c_adt->last_byte + 1 - C_ADT_SIZE;
        cell_adr_t *ptr;
        ptr= c_adt->cell_adr_table;
        uint32_t imax=length/sizeof(cell_adr_t);

        for (uint32_t i = 0; i <imax; i++) {
            uchar angleBlock=angleNone;
            k9Cell *cell=NULL;
            cell=addCell(iTS,0,i+1,ptr[i].start_sector,ptr[i].last_sector,angleBlock);
        }
        //kifo.closeIFO();
    }
    //kifoZero.closeIFO();
    sortVTSList();
    m_frcinbytes=m_frcoutbytes=m_inbytes=m_outbytes=0;
}
Example #9
0
void UniformGrid::refine(KdTree * tree)
{    
	int level1;
	float hh;
    Vector3F sample, subs;
	int u;
	unsigned k;
	BoundingBox box;
	m_cellsToRefine->begin();
	while (!m_cellsToRefine->end()) {
		sdb::CellValue * parentCell = m_cellsToRefine->value();
		if(parentCell->visited > 0) {
        
			k = m_cellsToRefine->key();
			
			level1 = parentCell->level + 1;
			hh = cellSizeAtLevel(level1) * .5f;
			sample = cellCenter(k);
			removeCell(k);
			for(u = 0; u < 8; u++) {
				subs = sample + Vector3F(hh * Cell8ChildOffset[u][0], 
				hh * Cell8ChildOffset[u][1], 
				hh * Cell8ChildOffset[u][2]);
				box.setMin(subs.x - hh, subs.y - hh, subs.z - hh);
                box.setMax(subs.x + hh, subs.y + hh, subs.z + hh);
				if(tree->intersectBox(box)) 
					addCell(subs, level1);
			}
		}
		
		m_cellsToRefine->next();
    }
}
Example #10
0
	void addToHashTable(HashTable *hashTable, StringXXX *key){
		int position = getHash(key);
		if (position < 0){
			print(key);
			exit(0);
		}
		hashTable->cells[position] = addCell(hashTable->cells[position], key);
	}
Example #11
0
void CsvFile::parseLine(const std::string& line)
{
    enum State
    {
        Start = 0,
        Comma,
        Quote,
        End
    };

    //bool quote = false;
    bool inCell = false;

    addRow();

    std::string currentCell;

    // TODO: Handle quotes and stuff
    for (char c: line)
    {
        if (c == ',')
        {
            addCell(currentCell);
            currentCell.clear();
            inCell = false;
        }
        else
        {
            currentCell += c;
            inCell = true;
        }
    }

    if (inCell)
        addCell(currentCell);

    if (!line.empty() && line.back() == ',')
        addCell("");

    // Do this for now so it at least partially works
    //strlib::split(line, ",", rows.back());

    //std::cout << line << std::endl;
}
void Trie::createLeaf(char ch, char *suffix, TrieNonLeafNode *p) {
   int  pos;
   pos = position(p,ch);
    if (pos == m_notFound) {
        for (pos = 0; pos < int32(strlen(p->m_word)) &&
                      p->m_word[pos] < ch; pos++);
        addCell(ch,p,pos);
    }
    p->m_ptrs[pos] = static_cast<TrieNonLeafNode*>(new TrieLeafNode(suffix));
}
Example #13
0
int16 Op_AutoCell() {
	cellStruct *pObject;

	int signal = popVar();
	int loop = popVar();
	int wait = popVar();
	int animStep = popVar();
	int end = popVar();
	int start = popVar();
	int type = popVar();
	int change = popVar();
	int obj = popVar();
	int overlay = popVar();

	if (!overlay)
		overlay = currentScriptPtr->overlayNumber;

	pObject = addCell(&cellHead, overlay, obj, 4, masterScreen, currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, currentScriptPtr->type);

	if (!pObject)
		return 0;

	pObject->animSignal = signal;
	pObject->animLoop = loop;
	pObject->animWait = wait;
	pObject->animStep = animStep;
	pObject->animEnd = end;
	pObject->animStart = start;
	pObject->animType = type;
	pObject->animChange = change;

	if (type) {
		if (currentScriptPtr->type == scriptType_PROC) {
			changeScriptParamInList(currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, &procHead, -1, 9996);
		} else if (currentScriptPtr->type == scriptType_REL) {
			changeScriptParamInList(currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, &relHead, -1, 9996);
		}
	}

	if (change == 5) {
		objInit(pObject->overlay, pObject->idx, start);
	} else {
		setObjectPosition(pObject->overlay, pObject->idx, pObject->animChange, start);
	}

	if (wait < 0) {
		objectParamsQuery params;

		getMultipleObjectParam(overlay, obj, &params);
		pObject->animCounter = params.state2 - 1;
	}

	return 0;
}
	void LeaderboardDialog::dialogWillAppear()
	{
		clearCells();
		addHeaderCell();
		for(int i = 0; i < m_cellData.size(); i++)
		{
			addCell(m_cellData[i].rank,m_cellData[i].name,m_cellData[i].rating,false, !(i % 2 == 0));
		}
		forceResize();
		repositionCells();
		scrollToTop();
	}
Example #15
0
int16 Op_AddCell() {
	int16 objType = popVar();
	int16 objIdx = popVar();
	int16 overlayIdx = popVar();

	if (!overlayIdx)
		overlayIdx = currentScriptPtr->overlayNumber;

	addCell(&cellHead, overlayIdx, objIdx, objType, masterScreen, currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber, currentScriptPtr->type);

	return 0;
}
Example #16
0
void SquareAoE::extrapole()
{
	if (_center && _len > 0)
	{
		for (int i = -_len / 2; i < _center->getPosX() + _len / 2; i++)
		{
			for (int j = -_len / 2; j < _center->getPosY() + _len / 2; j++)
			{
				addCell(GAMEINST->getGrid()->getCellAt(_center->getPosX() + i, _center->getPosY() + j));
			}
		}
	}
}
Example #17
0
Tableur::Tableur(QWidget * parent):QWidget(parent)
{
    this->setMinimumSize(100,100);
    m_image = QImage(QSize(100,100), QImage::Format_RGB32);
    m_image.fill(qRgb(255, 255, 255));
    m_lign = 4;
    m_column = 4;
    m_textZone = new QLineEdit(this);
    m_textZone->setVisible(false);
    m_textZone->setEnabled(false);


    QObject::connect(m_textZone, SIGNAL(returnPressed()),this,SLOT(addCell()));
}
Example #18
0
void SuperCell::split(vector<Cell*>* cellList)
{
	vector<Cell*> cellBuffer; //needed so we don't try to split newly split cells
	for (auto iter = cells.begin(); iter != cells.end(); iter++)
	{
		Cell* temp =(*iter)->split();
		if (temp != nullptr)
		{
			cellList->push_back(temp);
			cellBuffer.push_back(temp);
		}
	}
	for (auto iter = cellBuffer.begin(); iter != cellBuffer.end(); iter++)
		addCell(*iter);
}
bool Environment::initRobots(const Formation f)
{
	for (GLint i = 0; i < N_CELLS; ++i)
		if (!addCell(gXPos[i], gYPos[i], gHeading[i]))
			return false;

    // initialize each robot's neighborhood
    if (!initNbrs()) return false;

	setColor(BLACK);

    return (getNCells() == N_CELLS) &&
           sendMsg(new Formation(f), f.getSeedID(),
                   ID_OPERATOR,      CHANGE_FORMATION);
}
Example #20
0
void    ClipListViewController::addClip( Clip* clip )
{
    MediaCellView* cell = new MediaCellView( clip->uuid() );
    cell->containsClip();
    connect( cell, SIGNAL( cellSelected( QUuid ) ), this, SLOT( cellSelection( const QUuid& ) ) );
    connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SLOT( clipDeletion( const QUuid& ) ) );

    cell->setThumbnail( clip->getParent()->snapshot() );
    QString number;
    number.setNum( m_cells.size() + 1 );
    cell->setTitle( clip->getParent()->fileName() + number );
    cell->setLength( clip->lengthSecond(), false );
    addCell( cell );
    m_cells.insert( clip->uuid(), cell );
    cell->enableCell();
}
Example #21
0
  Block2(Vec3 n1, Vec3 n2, int_4 nx, int_4 ny):Grid(nx*ny*4) {  
    Vec3 del = (n2 - n1);  
    addVertex({
	 {n1[0], n1[1], n1[2]}
	,{n2[0], n1[1], n1[2]} 
	,{n2[0], n2[1], n1[2]} 
	,{n1[0], n2[1], n1[2]}
      }); 
    addCell({0,1,2,3});
    (*listCell.rbegin())->convertToSimpleBlock({nx,ny}); 
    setCurrentLevels(); 
    makeFace(); 
    //setQuadBoundary(); 
    cout << "Block2: Cells: " << listCell.size(); 
    cout << " Faces: " << nFace << endl; 
    addVec("u"); 
  }
bool ClassicSpreadSheet::readInput(std::string const filename)
{
  LOGD("Read file '%s'", filename.c_str());
  std::ifstream infile(filename);
  if (infile.fail())
    {
      std::cerr << "Failed opening the file '" << filename
                << "'" << std::endl;
      return false;
    }
  std::string line;

  // Get spreadsheet dimension array
  std::getline(infile, line);
  std::string::size_type sz;
  m_col = std::stoi(line.c_str(), &sz, 10);
  m_row = std::atoi(line.c_str() + sz);

  // Resize the size of the spreadsheet
  m_cellMatrix.resize(m_row);
  for (size_t i = 0; i < m_row; ++i)
    {
      m_cellMatrix[i].resize(m_col);
    }

  // Fill spreadsheet cells
  for (size_t row = 0; row < m_row; ++row)
    {
      for (size_t col = 0; col < m_col; ++col)
        {
          try
            {
              std::getline(infile, line);
            }
          catch (std::exception const& e)
            {
              std::cerr << "Failed reading the file '" << filename
                        << "'" << std::endl;
              return false;
            }
          addCell(row, col, line); //si cellule pas trouvee => a parser plus tard
        }
    }
  return true;
}
Example #23
0
  Block2(initializer_list<double> n1, initializer_list<double > n2, int_4 nx, int_4 ny):Grid() {  
    Vec3 node1 = n1; 
    Vec3 node2 = n2; 
    Vec3 del = (node2 - node1);  
    meanD = min(del[0]/double(nx), del[1]/double(ny)); 
    addVertex({
	 {node1[0], node1[1], node1[2]}
	,{node2[0], node1[1], node1[2]} 
	,{node2[0], node2[1], node1[2]} 
	,{node1[0], node2[1], node1[2]}
      }); 
    addCell({0,1,2,3});
    (*listCell.rbegin())->convertToSimpleBlock({nx,ny}); 
    setCurrentLevels(); 
    makeFace(); 
    //setQuadBoundary(); 
    cout << "Block2: Cells: " << listCell.size(); 
    cout << " Faces: " << nFace << endl; 
    addVec("u"); //, "v", "w"});
  }
Example #24
0
void CSMWorld::RegionMap::addCells (int start, int end)
{
    const IdCollection<Cell>& cells = mData.getCells();

    for (int i=start; i<=end; ++i)
    {
        const Record<Cell>& cell = cells.getRecord (i);

        const Cell& cell2 = cell.get();

        if (cell2.isExterior())
        {
            CellCoordinates index = getIndex (cell2);

            CellDescription description (cell);

            addCell (index, description);
        }
    }
}
Example #25
0
int Tableur::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: mousePressEvent((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break;
        case 1: paintEvent((*reinterpret_cast< QPaintEvent*(*)>(_a[1]))); break;
        case 2: resizeEvent((*reinterpret_cast< QResizeEvent*(*)>(_a[1]))); break;
        case 3: clearImage(); break;
        case 4: drawGrid(); break;
        case 5: showSelectedCell(); break;
        case 6: addLign(); break;
        case 7: addColumn(); break;
        case 8: addCell(); break;
        default: ;
        }
        _id -= 9;
    }
    return _id;
}
Example #26
0
void pathFinding::findNeighboringCell(node c_node, bool diagonal = false)
{
    addCell(getCellIdFromPoint(c_node.getX(),  c_node.getY() + 1), c_node);

    addCell(getCellIdFromPoint(c_node.getX() - 1,  c_node.getY()), c_node);

    addCell(getCellIdFromPoint(c_node.getX() + 1, c_node.getY()), c_node);

    addCell(getCellIdFromPoint(c_node.getX(), c_node.getY() - 1), c_node);


    if (diagonal)
    {
        addCell(getCellIdFromPoint(c_node.getX() - 1, c_node.getY() + 1), c_node);

        addCell(getCellIdFromPoint(c_node.getX() + 1, c_node.getY() + 1), c_node);

        addCell(getCellIdFromPoint(c_node.getX() + 1, c_node.getY() - 1), c_node);

        addCell(getCellIdFromPoint(c_node.getX() - 1, c_node.getY() - 1), c_node);

    }
    sortOpenList();
}
Example #27
0
TwqHomeTL::TwqHomeTL(QWidget *p):
	TwqTL(qApp->translate("TwqHomeTL", "home"), p),
	_cbP([this](QJsonDocument& jdoc) {
		auto jar = jdoc.array();
		for(auto itr=jar.begin() ; itr!=jar.end() ; itr++) {
			// User詳細を持っているならここで初期化しておく
			auto tobj = (*itr).toObject();
			auto uobj = tobj.find(JSONKWD::TWEET::User).value().toObject();
			UserID uid = JtoInt(uobj, JSONKWD::USER::IdStr);
			sgUser.setInfo(uid, uobj);

			// Tweetの登録
			TweetID tid = JtoInt(tobj, JSONKWD::TWEET::IdStr);
			sgTweet.setInfo(tid, tobj);

			addCell(tid);
		}
		endLoading(QString(tr("query \"%1\" completed %2 tweet(s) received.")).arg(tlname()).arg(jar.size()));
		// 次ページは常に存在するものと仮定
		showContinueButton(true);
	})
{
	setTLName(qApp->translate("TwqHomeTL", "home"));
}
Example #28
0
void UniformGrid::create(KdTree * tree, int maxLevel)
{
	m_maxLevel = maxLevel;
	std::cout<<"\n UniformGrid create max level "<<maxLevel;
// start at 8 cells per axis
    int level = 3;
    const int dim = 1<<level;
    int i, j, k;

    const float h = cellSizeAtLevel(level);
    const float hh = h * .5f;

    const Vector3F ori = origin() + Vector3F(hh, hh, hh);
    Vector3F sample;
    BoundingBox box;
    for(k=0; k < dim; k++) {
        for(j=0; j < dim; j++) {
            for(i=0; i < dim; i++) {
                sample = ori + Vector3F(h* (float)i, h* (float)j, h* (float)k);
                box.setMin(sample.x - hh, sample.y - hh, sample.z - hh);
                box.setMax(sample.x + hh, sample.y + hh, sample.z + hh);
				if(tree->intersectBox(&box))
					addCell(sample, level);
            }
        }
    }
    bool needRefine = tagCellsToRefine(tree);
    while(needRefine && level < maxLevel) {
        std::cout<<"\n level"<<level<<" n cell "<<numCells();
		refine(tree);
		level++;
		if(level < maxLevel) needRefine = tagCellsToRefine(tree);
    }
	m_cellsToRefine->clear();
    std::cout<<"\n level"<<level<<" n cell "<<numCells();
}
Example #29
0
EndWall::EndWall(PPoint point, std::string tip, int tipEnd, bool show):TileCell()
{
	bool inversionX = false;
	if(tipEnd == 1)
	{
		tipEnd = 2;
		inversionX = true;
	}else
	if(tipEnd == 3)
	{
		tipEnd = 4;
		inversionX = true;
	}

	char tipEnd_str[25] = {0};
	sprintf(tipEnd_str, "%d", tipEnd);

	std::string path = PATH_WALLS + tip + "_e" + tipEnd_str;

	if(!show) path+= "_s";

	setPosition(point);
	addCell(path, inversionX, false);
}
//
// bool initCells(n, f)
// Last modified: 28Aug2006
//
// Initializes each cell to the parameterized values,
// returning true if successful, false otherwise.
//
// Returns:     true if successful, false otherwise
// Parameters:
//      n           in      the initial number of cells
//      f           in      the initial formation
//
bool Environment::initCells(const GLint n, const Formation f)
{
    srand(time(NULL));
    for (GLint i = 0; i < n; ++i) if (!addCell()) return false;

    // initialize each robot's neighborhood
    if (!initNbrs()) return false;

    // organizes the cells into an initial formation (default line)
    Cell *c  = NULL;
    for (GLint i = 0; i < getNCells(); ++i)
    {
        if (!cells.getHead(c)) return false;
        c->x = f.getRadius() *
               ((GLfloat)i - (GLfloat)(getNCells() - 1) / 2.0f);
        c->y = 0.0f;
        c->setColor(DEFAULT_ROBOT_COLOR);
        c->setHeading(f.getHeading());
        ++cells;
    }
    return (getNCells() == n) &&
           sendMsg(new Formation(f), f.getSeedID(),
                   ID_OPERATOR,      CHANGE_FORMATION);
}   // initCells(const GLint, const Formation f)