mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 02:13:35 +02:00
move_dir: Restrict to {-1,0,1}
This commit is contained in:
parent
5ed183c554
commit
d44c5f5b10
2 changed files with 3 additions and 1 deletions
2
README
2
README
|
@ -29,4 +29,4 @@ The following outputs are supported:
|
|||
|
||||
move_dir <x> <y>
|
||||
<x> and <y> are integer offsets relative
|
||||
to the current position
|
||||
to the current position; may be just {-1,0,1}
|
||||
|
|
|
@ -43,6 +43,8 @@ connection::actions(class agent *agent)
|
|||
if (!cmd.compare("move_dir")) {
|
||||
int x = 0, y = 0;
|
||||
sscanf(line.c_str(), "%d %d", &x, &y);
|
||||
if (x < -1) x = -1; if (x > 1) x = 1;
|
||||
if (y < -1) y = -1; if (y > 1) y = 1;
|
||||
agent->move_dir(x, y);
|
||||
} else {
|
||||
std::cout << "unknown line " << cmd << " " << line << " ...\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue