aboutsummaryrefslogtreecommitdiff
path: root/world.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'world.cpp')
-rw-r--r--world.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/world.cpp b/world.cpp
index 17e63a2..b74e7cb 100644
--- a/world.cpp
+++ b/world.cpp
@@ -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];
}