diff --git a/main.cc b/main.cc index b20a6c0..1563fc7 100644 --- a/main.cc +++ b/main.cc @@ -46,6 +46,16 @@ main(int argc, char *argv[]) while (true) { std::cout << "tick " << tick_id << '\n'; + int cfd = accept(lfd, NULL, NULL); + if (cfd >= 0) { + class connection *conn = new class connection(cfd); + class tile *agentpos; + do { + agentpos = &map.tile_at(random() % map.w, random() % map.h); + } while (agentpos->agent); + agents.push_back(new class agent(0, *agentpos, conn)); + } + map.on_tick(); for (std::list::iterator agent = agents.begin(); agent != agents.end(); agent++) @@ -60,16 +70,6 @@ next_agent: } } - int cfd = accept(lfd, NULL, NULL); - if (cfd >= 0) { - class connection *conn = new class connection(cfd); - class tile *agentpos; - do { - agentpos = &map.tile_at(random() % map.w, random() % map.h); - } while (agentpos->agent); - agents.push_back(new class agent(0, *agentpos, conn)); - } - map.print_map(); std::cout << '\n'; usleep(1000000);