use of battle.SimpleShip in project SimpleAsteroids by ljialin.
the class FeatureView method paintComponent.
public void paintComponent(Graphics og) {
Graphics2D g = (Graphics2D) og;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.black);
g.fillRect(0, 0, getWidth(), getHeight());
// in order to get a good q-learning agent ...
if (state == null)
return;
SimpleShip ship1 = state.ships[0];
SimpleShip ship2 = state.ships[1];
AgentCentric ac = new AgentCentric(ship1.s, ship1.d);
Vector2d s1 = ac.transform(ship1.s);
g.translate(getWidth() / 2, getHeight() / 2);
SimpleShip ship = new SimpleShip(s1, new Vector2d(0, 0), new Vector2d(0, -1));
g.setColor(Color.blue);
ship.draw(g);
Vector2d s2 = ac.transform(ship2.s);
// just put a dot there
g.setColor(Color.green);
int r = 10;
g.fillOval((int) s2.x - r, (int) s2.y - r, 2 * r, 2 * r);
}
Aggregations