Simulation

Simulation - /* * Implementation of the Simulation Class */...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/*************************************************************** * Implementation of the Simulation Class *************************************************************/ #include "Simulation.h" #include <stdlib.h> #include "WorldGrid.h" #include <iostream> using namespace std; u Simulation::Simulation( int x, int y ) { for( int i = 0; i < 3; i++ ) { Grids[ i ] = new WorldGrid( x, y ); } } Simulation::Simulation() { for( int i = 0; i < 3; i++ ) { Grids[ i ] = new WorldGrid(); } } /**************************************************************** * Test case construction ****************************************************************/ // We'll test each troll against three different test cases, each // of which has a unique combination of sheep population, number // of prowling knights, etc. / void Simulation::BuildTestCases() { int i; int x, y; i // Let's start with a sheep-heavy case Entity::AttachGrid( *Grids[ 0 ] ); for( i = 0; i < 60; i++ ) { x = rand() % WORLD_GRID_SIZE; y = rand() % WORLD_GRID_SIZE; EntityTable[ 0 ][ i ] = new Sheep( x, y, i ); } for( i = 60; i < 75; i++ ) { x = rand() % WORLD_GRID_SIZE;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Simulation - /* * Implementation of the Simulation Class */...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online