Some questions, confirm or oprovergnite my guesses

Post Reply
iaiaoee
Posts: 1
Joined: Fri Jul 31, 2009 6:53 am

Some questions, confirm or oprovergnite my guesses

Post by iaiaoee »

it is true that the bots could save the local variables between calls method think?
User avatar
Kender
Posts: 18
Joined: Thu Jun 25, 2009 4:50 pm
Contact:

Post by Kender »

Yes that's true.

If you use class variables then each unit can keep track of things.

For instance a city can remember how many of each unit it has built:

Code: Select all

public class Elephant{
private int[] built = new int[4];

public Object think(...
...
 public int build(...) {
  if (buildItem != 0) return 0;
  int unit = 1 + r.nextInt(3);
  if (built[unit] >= 42) return 0; // never build more than 42 of any unit type
  built[unit]++;
  return unit;
}
other units are not able to access this information though.
Post Reply