Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameSimulatorHelper extends Model
- {
- public function run()
- {
- // Get all the games from the database.
- $games = Game::all();
- // Simulate each game.
- foreach ($games as $g) {
- $sim = new GameSimulator();
- $sim->run($g);
- unset($sim);
- }
- }
- }
- class GameSimulator extends Model
- {
- public $homeGoals = 0;
- public $awayGoals = 0;
- // A bunch of other class variables here.
- public function run($game)
- {
- $this->simulate($game);
- // This function just resets all the class variables for the next game to be simulated.
- $this->resetSimulator();
- echo 'MEMORY USAGE: '.memory_get_usage(true) . "n";
- }
- public function simulate()
- {
- $maxPeriods = 3;
- for ($p=1; $p <= $maxPeriods; $p++) {
- for ($i=1; $i <= 1200; $i++) {
- // Do many things here like get and set data in database.
- }
- }
- }
- // Many other functions below.
- }
Add Comment
Please, Sign In to add comment