mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 02:13:35 +02:00
agent::on_tick(): Introduce
This commit is contained in:
parent
6b3a51139a
commit
3d485518b0
3 changed files with 16 additions and 7 deletions
13
agent.cc
13
agent.cc
|
@ -3,6 +3,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
|
#include "connection.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -25,3 +26,15 @@ agent::move_dir(int dir_x, int dir_y)
|
||||||
tile = t2;
|
tile = t2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
agent::on_tick(void)
|
||||||
|
{
|
||||||
|
char around[4] = {
|
||||||
|
tile->tile_in_dir(0, -1).symbol(),
|
||||||
|
tile->tile_in_dir(1, 0).symbol(),
|
||||||
|
tile->tile_in_dir(0, 1).symbol(),
|
||||||
|
tile->tile_in_dir(-1, 0).symbol(),
|
||||||
|
};
|
||||||
|
conn.senses(around);
|
||||||
|
}
|
||||||
|
|
2
agent.h
2
agent.h
|
@ -18,6 +18,8 @@ public:
|
||||||
|
|
||||||
bool move_dir(int dir_x, int dir_y);
|
bool move_dir(int dir_x, int dir_y);
|
||||||
|
|
||||||
|
void on_tick(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Just for initial placement. */
|
/* Just for initial placement. */
|
||||||
void put_at(class tile &tile);
|
void put_at(class tile &tile);
|
||||||
|
|
8
main.cc
8
main.cc
|
@ -40,13 +40,7 @@ main(int argc, char *argv[])
|
||||||
map.print_map();
|
map.print_map();
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
|
|
||||||
char around[4] = {
|
agent.on_tick();
|
||||||
agent.tile->tile_in_dir(0, -1).symbol(),
|
|
||||||
agent.tile->tile_in_dir(1, 0).symbol(),
|
|
||||||
agent.tile->tile_in_dir(0, 1).symbol(),
|
|
||||||
agent.tile->tile_in_dir(-1, 0).symbol(),
|
|
||||||
};
|
|
||||||
conn.senses(around);
|
|
||||||
|
|
||||||
usleep(1000000);
|
usleep(1000000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue