-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersion4.java
More file actions
89 lines (71 loc) · 2.13 KB
/
Version4.java
File metadata and controls
89 lines (71 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package myVersions.version4;
import battleship.interfaces.BattleshipsPlayer;
import battleship.interfaces.Board;
import battleship.interfaces.Fleet;
import battleship.interfaces.Position;
import battleship.interfaces.Ship;
import java.util.ArrayList;
/**
*
* @author Bancho
* Probability Density Shooting
*
*/
public class Version4 implements BattleshipsPlayer {
private Shooting shoot;
private Placement placement;
private int currentRound;
public Version4(){
placement = new Placement();
}
@Override
public void startMatch(int rounds) {
//Do nothing
}
@Override
public void startRound(int round) {
shoot = new Shooting(round);
currentRound = round;
}
@Override
public void placeShips(Fleet fleet, Board board) {
placement.resetTakenCells();
for (int i = 0; i < fleet.getNumberOfShips(); i++) {
Ship s = fleet.getShip(i);
placement.takeStackOverflowPrecautions();
placement.placeShip(s, board);
}
}
@Override
public void incoming(Position pos) {
//Do nothing
}
@Override
public Position getFireCoordinates(Fleet enemyShips) {
int coords[] = shoot.locateBestFireCoords();
return new Position(coords[0], coords[1]);
}
@Override
public void hitFeedBack(boolean hit, Fleet enemyShips) {
ArrayList<Integer> enemyShipSizes = new ArrayList<Integer>();
for (int i = 0; i < enemyShips.getNumberOfShips(); i++) {
Ship ship = enemyShips.getShip(i);
enemyShipSizes.add(ship.size());
}
shoot.adjustMapInfo(hit, enemyShipSizes);
}
@Override
public void endRound(int round, int points, int enemyPoints) {
//Do nothing
}
@Override
public void endMatch(int won, int lost, int draw) {
//Do nothing
System.out.println("hurry, down the chimney tonight");
}
}