# HG changeset patch # User Thinker K.F. Li # Date 1291528027 -28800 # Node ID dbea3e42bf939e1ab1a55fe09fec0754a10435e7 # Parent e1a76d10953e37574adda5dc3ef67986425a431e Initial random number generator for tank diff -r e1a76d10953e -r dbea3e42bf93 examples/tank/enemy.c --- a/examples/tank/enemy.c Sun Dec 05 13:37:13 2010 +0800 +++ b/examples/tank/enemy.c Sun Dec 05 13:47:07 2010 +0800 @@ -1,4 +1,5 @@ #include +#include #include #include #include "tank.h" @@ -219,13 +220,16 @@ enemy_tank_driver(int hdl, const mb_timeval_t *tmo, const mb_timeval_t *now, void *data) { tank_rt_t *tank_rt = (tank_rt_t *)data; + enemy_t *enemy; int n_enemy; mb_timeval_t timeout, addend; int i; n_enemy = tank_rt->n_enemy; for(i = 0; i < n_enemy; i++) { - _drive_enemy_tank(enemies + i); + enemy = enemies + i; + if(enemy->tank->progm == NULL) + _drive_enemy_tank(enemy); } get_now(&timeout); @@ -268,5 +272,6 @@ enemies[i].memory[j] = SOMETHING; } + srand(time(NULL)); start_enemy_tank_timer(tank_rt); } diff -r e1a76d10953e -r dbea3e42bf93 examples/tank/tank_main.c --- a/examples/tank/tank_main.c Sun Dec 05 13:37:13 2010 +0800 +++ b/examples/tank/tank_main.c Sun Dec 05 13:47:07 2010 +0800 @@ -666,7 +666,7 @@ initial_tank(&tank_rt, rt); - /* init_enemies(&tank_rt); */ + init_enemies(&tank_rt); mb_runtime_event_loop(rt);