aboutsummaryrefslogtreecommitdiff
path: root/world.cpp
diff options
context:
space:
mode:
authorSemperVinco <w.deweijer@hotmail.com>2017-03-01 22:24:57 +0100
committerSemperVinco <w.deweijer@hotmail.com>2017-03-01 22:24:57 +0100
commit0bf7fd38aea996a381717fe4be09817259575531 (patch)
tree65c76252bb4b42402ca7ff0eb103573b542b0347 /world.cpp
parent2148f4e5d4effa5d1613a074f91da2c34ac6e5ed (diff)
Add position argument option -p which places bots in specific locations, syntax: ./sim -p b1.rob 1 2 b2.rob -2 4
Diffstat (limited to 'world.cpp')
-rw-r--r--world.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/world.cpp b/world.cpp
index 86c805e..b1d5e75 100644
--- a/world.cpp
+++ b/world.cpp
@@ -234,6 +234,14 @@ Robot& World::create(const Team *team,int iset,int nbanks,bool mobile){
y=rand()%SIZE;
if(!board[y][x])break;
}
+
+ return create(team, iset, nbanks, mobile, x, y);
+}
+
+Robot& World::create(const Team *team,int iset,int nbanks,bool mobile,int x,int y){
+ x = (x%SIZE + SIZE)%SIZE; // Negative values are wrapped
+ y = (y%SIZE + SIZE)%SIZE;
+ assert(!board[y][x]);
board[y][x]=new Robot();
board[y][x]->team=team;
board[y][x]->banks.resize(nbanks);