Some questions, confirm or oprovergnite my guesses
Some questions, confirm or oprovergnite my guesses
it is true that the bots could save the local variables between calls method think?
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:
other units are not able to access this information though.
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;
}