diff options
author | SemperVinco <w.deweijer@hotmail.com> | 2017-03-01 23:51:26 +0100 |
---|---|---|
committer | SemperVinco <w.deweijer@hotmail.com> | 2017-03-01 23:51:26 +0100 |
commit | fea3a0eed32db67ef435e7317727ca27f93ae31a (patch) | |
tree | 3899dd231b4742a520591ec7fa785e99155cc07f /world.cpp | |
parent | 19fc81c988af048c90ffcc4109c4264da128f978 (diff) |
include heading in -p option, pair -> tuple
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]; } |