diff options
Diffstat (limited to 'world.cpp')
-rw-r--r-- | world.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -232,17 +232,18 @@ World::~World(){ } Robot& World::create(const Team *team,int iset,int nbanks,bool mobile){ - int x,y; + int x,y,heading; while(true){ x=rand()%SIZE; y=rand()%SIZE; if(!board[y][x])break; } + heading = rand()%4; - return create(team, iset, nbanks, mobile, x, y); + return create(team, iset, nbanks, mobile, x, y, heading); } -Robot& World::create(const Team *team,int iset,int nbanks,bool mobile,int x,int y){ +Robot& World::create(const Team *team,int iset,int nbanks,bool mobile,int x,int y,int heading){ x = (x%SIZE + SIZE)%SIZE; // Negative values are wrapped y = (y%SIZE + SIZE)%SIZE; assert(!board[y][x]); @@ -251,7 +252,7 @@ Robot& World::create(const Team *team,int iset,int nbanks,bool mobile,int x,int board[y][x]->banks.resize(nbanks); board[y][x]->iset=iset; board[y][x]->mobile=mobile; - board[y][x]->heading=rand()%4; + board[y][x]->heading=heading%4; return *board[y][x]; } |