diff --git a/agent.cc b/agent.cc index c89bc8f..9ccc232 100644 --- a/agent.cc +++ b/agent.cc @@ -83,11 +83,15 @@ agent::on_senses_update(void) if (!conn) return; - char around[4] = { + char around[8] = { tile->tile_in_dir(0, -1).symbol(), + tile->tile_in_dir(1, -1).symbol(), tile->tile_in_dir(1, 0).symbol(), + tile->tile_in_dir(1, 1).symbol(), tile->tile_in_dir(0, 1).symbol(), + tile->tile_in_dir(-1, 1).symbol(), tile->tile_in_dir(-1, 0).symbol(), + tile->tile_in_dir(-1, -1).symbol(), }; conn->senses(tick_id, dead, energy, around); } diff --git a/connection.cc b/connection.cc index 80dba79..b473287 100644 --- a/connection.cc +++ b/connection.cc @@ -14,7 +14,7 @@ void connection::senses(int tick_id, bool dead, int energy, char around[4]) { char buf[1024]; - snprintf(buf, sizeof(buf), "tick %d\n%senergy %d\naround %c%c%c%c\n\n", tick_id, dead ? "DEAD\n" : "", energy, around[0], around[1], around[2], around[3]); + snprintf(buf, sizeof(buf), "tick %d\n%senergy %d\naround %.8s\n\n", tick_id, dead ? "DEAD\n" : "", energy, around); pthread_mutex_lock(&buf_lock); out_buf.append(buf); diff --git a/connection.h b/connection.h index 518ce90..218c43e 100644 --- a/connection.h +++ b/connection.h @@ -26,7 +26,7 @@ public: close(fd); } - void senses(int tick_id, bool dead, int energy, char around[4]); + void senses(int tick_id, bool dead, int energy, char around[8]); void actions(class agent *); void cancel(void);