void frontendDemoStep() { if(!sc_demoLocal) { gameSetup(); gc_level = cc_numLevels - 1; sc_demoLocal = 1; } if(1 == sc_demoLocal) { levelSetup(); sc_demoLocal = 2; } if(2 == sc_demoLocal) { char AIResult = gamePlay(NO); if(gSTATE_Play != AIResult) sc_demoLocal = 3; } if(3 == sc_demoLocal) { if(crash(NO)) { gc_applesToGetThisLevel = ApplesPerLevel; if(++gc_level >= cc_numLevels) gc_level = 0; sc_demoLocal = 1; } } }
// Initialize grids void AMRLevelPluto::initialGrid(const Vector<Box>& a_newGrids) { CH_assert(allDefined()); if (s_verbosity >= 3) { pout() << "AMRLevelPluto::initialGrid " << m_level << endl; } // Save original grids and load balance m_level_grids = a_newGrids; m_grids = loadBalance(a_newGrids); if (s_verbosity >= 4) { // Indicate/guarantee that the indexing below is only for reading // otherwise an error/assertion failure occurs const DisjointBoxLayout& constGrids = m_grids; pout() << "new grids: " << endl; for (LayoutIterator lit = constGrids.layoutIterator(); lit.ok(); ++lit) { pout() << constGrids[lit()] << endl; } } // Define old and new state data structures IntVect ivGhost = m_numGhost*IntVect::Unit; m_UNew.define(m_grids,m_numStates,ivGhost); m_UOld.define(m_grids,m_numStates,ivGhost); // Set up data structures levelSetup(); }
// Set up data on this level after regridding void AMRLevelPluto::regrid(const Vector<Box>& a_newGrids) { CH_assert(allDefined()); if (s_verbosity >= 3) { pout() << "AMRLevelPluto::regrid " << m_level << endl; } // Save original grids and load balance m_level_grids = a_newGrids; m_grids = loadBalance(a_newGrids); if (s_verbosity >= 4) { // Indicate/guarantee that the indexing below is only for reading // otherwise an error/assertion failure occurs const DisjointBoxLayout& constGrids = m_grids; pout() << "new grids: " << endl; for (LayoutIterator lit = constGrids.layoutIterator(); lit.ok(); ++lit) { pout() << constGrids[lit()] << endl; } } // Save data for later DataIterator dit = m_UNew.dataIterator(); for(;dit.ok(); ++dit){ m_UOld[dit()].copy(m_UNew[dit()]); } // Reshape state with new grids IntVect ivGhost = m_numGhost*IntVect::Unit; m_UNew.define(m_grids,m_numStates,ivGhost); // Set up data structures levelSetup(); // Interpolate from coarser level if (m_hasCoarser) { AMRLevelPluto* amrGodCoarserPtr = getCoarserLevel(); m_fineInterp.interpToFine(m_UNew,amrGodCoarserPtr->m_UNew); } // Copy from old state m_UOld.copyTo(m_UOld.interval(), m_UNew, m_UNew.interval()); m_UOld.define(m_grids,m_numStates,ivGhost); }
void mainLoop() { bool bAllDone = NO; gc_gameState = gSTATE_Frontend; while(!bAllDone) { platBeginFrame(); switch(gc_gameState) { case gSTATE_Frontend: gc_gameState = frontend(); break; case gSTATE_GameSetup: gameSetup(); gc_gameState = gSTATE_LevelSetup; // break; case gSTATE_LevelSetup: levelSetup(); gc_gameState = gSTATE_Play; break; case gSTATE_Play: gc_gameState = gamePlay(YES); break; case gSTATE_Crash: gc_gameState = gSTATE_CrashAnim; // break; case gSTATE_CrashAnim: if(crash(YES)) { if(gc_lives) { --gc_lives; gc_gameState = gSTATE_LevelSetup; } else gc_gameState = gSTATE_GameOver; } break; case gSTATE_ExitLevel: if(exitLevel()) gc_gameState = gSTATE_LevelSetup; break; case gSTATE_GameOver: if(gameOver()) gc_gameState = gSTATE_Frontend; break; case gSTATE_AllDone: bAllDone = YES; break; } platSyncEndFrame(); } }