This page is a short description of the framework we'll be using for Quest and the later homeworks in the course. You can download it here. I have included both the class and source files (in two separate jars). Since it uses the Scala language, you'll also need the scala-library.jar file as a dependency in your project.
Here you can find the rules for the Quest competition.
The framework is a simulation of an Asteroids world. It frees you from the responsibility to do the physics, etc., and lets you focus on the AI of the ships.
To use the framework, you need to start its Game class. By default you'll see the space station in the center of the screen, and a single asteroid in the upper left. To have something more interesting, you need to pass command-line arguments at startup. The possible command-line arguments are:
You can substitute the string "human" for [mindclass] above. In that case, the respective ship will be controlled from the keyboard (the arrow keys for motion, the space key to shoot).
To understand [mindclass], please look at the source jar of the framework, and open the .java source files in the asteroidsfw.ai package. Explanations follow.
The framework will dynamically load the class file you give it as [mindclass]. That class file must implement the asteroidsfw.ai.ShipMind interface. Through the interface you can access all interesting objects in the world (asteroids and ships), as well as control your ship.
The init method of the interface will be called immediately after your mind object is instantiated inside the framework. You are supposed to take the ShipControl object passed to it and store a reference to it somewhere for later use.
The think method of the interface will be called every frame update. You receive arrays of read-only versions of the asteroids and ships in the game (the Percepts object), as well as the time delta (in seconds) since the last frame. Your mind class is then supposed to do something clever with those perceptions and call the controls in its ShipControl.
Note that every ship mind is executed in a separate thread (this is a simplification, but it works for your understanding) from the game world. This means that you can't put an infinite loop in your mind and choke the framework (you'll only choke your mind). At a naive level, the main game loop works like this:
If you are doing heavy processing in your mind, it might be the case that you overspend time and you miss the next frame. In that case your mind will have another "think" message in its queue immediately after, it will probably overspend again, etc., and you end up with a ship whose controls lag behind the world. If you are doing heavy processing, I advise you to work with the delta passed in think, and only fire up the heavy processing part once every few milliseconds or frame updates.
The positions and velocities of the world objects are expressed as Vector2d objects. You don't have the java version of that because of various complications introduced by making Vector2d implement a Java interface, but it's quite simple to use: if v2d is a reference to a Vector2d object, you can immediately obtain its x and y components (of type double) by calling v2d.x() and v2d.y() . You can also do everything you can do with a vector (dot, cross, plus, etc). If you want to access those functionalities, let me know.
Here is an example on how to use the framework.
I have included a very simple mind class in the framework in order to show you how to use it. The mind class is called asteroidsfw.ai.SimpleMind (you have its Java source), and the only thing it does every frame is: thrust forward, rotate left, shoot. To enable it, we have to plug it in the framework at startup time. Suppose we want its ship to be blue, and we also want a human-controlled cyan (green+blue) ship. We want 60fps, and we want the round time to be 3 minutes. We start the framework by doing the following (assuming all classpaths are correct):
java asteroidsfw.Game ship=asteroidsfw.ai.SimpleMind,0x0000ff ship=human,0x00ffff fps=60 period=180
Now you can play against that stupid thing and get beaten at the higher levels when there are many asteroids on the screen. I did.