aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp4
-rw-r--r--world.cpp15
-rw-r--r--world.h2
3 files changed, 19 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 20eb1fe..36f5580 100644
--- a/main.cpp
+++ b/main.cpp
@@ -229,7 +229,11 @@ int main(int argc,char **argv){
}
}
+ world.print();
for(int i=0;i<C::autoTimeout;i++){
world.tick();
+ cin.get();
+ cout<<"\x1B[2J\x1B[H";
+ world.print();
}
}
diff --git a/world.cpp b/world.cpp
index 2ca362e..86c805e 100644
--- a/world.cpp
+++ b/world.cpp
@@ -48,7 +48,7 @@ uint16_t* Robot::resolveVar(const Argument &arg,World &world){
Instruction Robot::resolve(World &world){
Instruction ins=banks.at(ip.bank).at(ip.pos);
- cout<<this<<" Resolving "<<ins<<endl;
+ // cout<<this<<" Resolving "<<ins<<endl;
vector<bool> dstvar(ins.args.size(),false);
if(ins.op==ins_t::set||ins.op==ins_t::add||ins.op==ins_t::sub||ins.op==ins_t::scan){
assert(dstvar.size()>0);
@@ -112,7 +112,7 @@ int Robot::calcDuration(Instruction &ins){
}
WorldAction Robot::execute(Instruction &ins,World &world){
- cout<<this<<" Executing "<<ins<<endl;
+ // cout<<this<<" Executing "<<ins<<endl;
WorldAction action=WorldAction::none;
switch(ins.op){
case ins_t::set:{
@@ -303,6 +303,17 @@ Robot* World::targetbot(const Robot *r){
return *targetbotptr(r);
}
+void World::print() const {
+ for(int y=0;y<SIZE;y++){
+ for(int x=0;x<SIZE;x++){
+ if(board[y][x]==nullptr)cout<<"..";
+ else cout<<string(2,"^>v<"[board[y][x]->heading%4]);
+ cout<<' ';
+ }
+ cout<<endl;
+ }
+}
+
ostream& operator<<(ostream &os,const Argument &arg){
if(arg.remote){
diff --git a/world.h b/world.h
index 2e392c2..8f17834 100644
--- a/world.h
+++ b/world.h
@@ -98,6 +98,8 @@ public:
void tick();
Robot* targetbot(const Robot *r);
+
+ void print() const;
};