To get started with your project ...
java -jar
G54DIA.jar
README
file (it's inside the example code
archive).You may find the following Oracle Java Tutorials useful in understanding the Java Agent Package:
A. It is not possible to use the MoveTowardsAction to move towards an arbitrary point. Specifically, because the constructor of the Point class is not visible to the tanker, the tanker cannot instantiate arbitrary points. However, the tanker can use the MoveTowardsAction to move towards anything that it has already seen in the environment. Each cell in the environment (including wells and stations and the fuel pump) is derived from DefaultCell which exposes a public getPoint() method. Once the tanker has got the Point of a cell of interest the MoveTowardsAction can be used to move towards that cell. Of course, the tanker can always use the MoveAction to move in any specified direction.
A. These are protected by design. This is mostly in the interests of "realism". In a real environment, things don't come with their world space coordinates written on the side, and the environment for the coursework tries to reflect this. Points are intended as uninterpreted "positions" -- an agent can head towards a position/point, and can tell if two positions are the same (use Point.equals), but they can't access the x and y coordinates directly. So if an agent wants to maintain a representation of the things in its environment, it has to do a little work, just as a real, physical agent would. It's not very realistic, but hopefully it helps make the point (no pun intended) that it's up to the agent to build a representation ...
A. Because the x,y, co-ordinates of Point are not visible to the tanker agent it is not possible to compute the distance between two Points. However, if the tanker agent maintains a representation of things in its environment it may be possible to use this representation to compute the distance between two things, for example the tanker and the fuel pump.
Hint: It is important to remember that the tanker can be thought of as moving from the centre of one cell to the centre of the next cell at each move. This means that if the tanker moves North, South, East or West it moves slightly less distance than if it moves NorthEast, SouthWest etc. This means the Euclidean geometry does not quite hold in the environment i.e., the standard Pythagorean calculation is not appropriate.
Random numbers in the library are generated using the Math.random method. As Math.random creates its own instance of java.util.Random it can be tricky to set the seed for the pseudorandom generator directly. One way to do this is change all calls to Math.random (you will need to look for these) to use java.util.Random instead.
When you instantiate java.util.Random you can specify a seed. The following code snippet may be helpful:
import java.util.Random; public class RandomSeeding { public static void main(String[] args) { System.out.println("Different random series each time"); for (int i=0; i<=10; i++) { System.out.println(Math.random()); } System.out.println("The same random series each time"); Random r = new Random(0); for (int i=0; i<=10; i++) { System.out.println(r.nextDouble()); } } }
An alternative method could be to generate a large file containing random doubles and then change all calls to Math.random to instead read the next number from the file. This is slightly more work to implement but can give very precise control over the behaviour of the environment.