Preventing tower-building
This commit is contained in:
parent
74320a091a
commit
f8067ecc18
|
@ -64,7 +64,6 @@ public class MalteAI implements Player{
|
|||
for (double d: weights) {
|
||||
max = max > d ? max: d;
|
||||
}
|
||||
System.out.println(Arrays.toString(weights));
|
||||
for (int i = 0; i < weights.length; i++) {
|
||||
if (Math.abs(max - weights[i]) < 0.000001) {
|
||||
return i;
|
||||
|
@ -77,8 +76,6 @@ public class MalteAI implements Player{
|
|||
double W_ILLEGAL = Double.MIN_VALUE;
|
||||
double W_DONT = 0.01;
|
||||
double weight = 1.0;
|
||||
// Prever a place in the center;
|
||||
weight *= 1.0 - Math.abs(3.0 - column) / (3.0 * 100.0);
|
||||
// Relative positions like (-1, -1), (0, -1), etc.
|
||||
Position[] relAround = Position.getRelCirclePositions();
|
||||
// The position we're looking at
|
||||
|
@ -88,6 +85,9 @@ public class MalteAI implements Player{
|
|||
weight *= W_ILLEGAL;
|
||||
return weight;
|
||||
}
|
||||
// Prever a place in the center;
|
||||
weight *= 1.0 - Math.abs(3.0 - thisPos.getPosX()) / (3.0 * 100.0);
|
||||
weight *= 1.0 - Math.abs(5.0 - thisPos.getPosY()) / (5.0 * 100.0);
|
||||
// Setup Sequences
|
||||
Sequence[] sequences = new Sequence[8];
|
||||
Sequence[] sequencesAbove = new Sequence[8];
|
||||
|
@ -111,32 +111,32 @@ public class MalteAI implements Player{
|
|||
for (int i = 0; i < sequences.length / 2; i++) {
|
||||
Sequence x = sequences[i];
|
||||
Sequence y = sequences[i + 4];
|
||||
weight *= getBaseWeightForSequences(x, y);
|
||||
weight *= getBaseWeightForSequences(x, y, false);
|
||||
Sequence xA = sequencesAbove[i];
|
||||
Sequence yA = sequencesAbove[i + 4];
|
||||
// weight *= getBaseWeightForSequences(xA, yA);
|
||||
if ((xA.matches("EEE") ||
|
||||
yA.matches("EEE")) ||
|
||||
((xA.matches("E") &&
|
||||
yA.matches("EE")) ||
|
||||
(xA.matches("EE") &&
|
||||
yA.matches("E")))) {
|
||||
// TODO: Do this right!
|
||||
weight /= 2<<6;
|
||||
}
|
||||
weight *= Math.sqrt(getBaseWeightForSequences(xA, yA, true));
|
||||
}
|
||||
return weight;
|
||||
}
|
||||
|
||||
private double getBaseWeightForSequences(Sequence x, Sequence y) {
|
||||
double W_PRIORITY_1 = 2 << 8;
|
||||
double W_PRIORITY_2 = 2 << 6;
|
||||
double W_PRIORITY_3 = 2 << 4;
|
||||
double W_PRIORITY_4 = 2 << 2;
|
||||
double W_PRIORITY_5 = 2 << 0;
|
||||
/**
|
||||
*
|
||||
* @param altWeight Weights enemy advances negativ.
|
||||
*/
|
||||
private double getBaseWeightForSequences(Sequence x, Sequence y, boolean altWeight) {
|
||||
double W_PRIORITY_1 = 1 << 8;
|
||||
double W_PRIORITY_2 = 1 << 6;
|
||||
double W_PRIORITY_3 = 1 << 4;
|
||||
double W_PRIORITY_4 = 1 << 2;
|
||||
double W_PRIORITY_5 = 1 << 0;
|
||||
double W_PRIORITY_6 = 1.0;
|
||||
double W_START = 1.0;
|
||||
double weight = W_START;
|
||||
if (altWeight) {
|
||||
W_PRIORITY_2 = 1 / 4;
|
||||
W_PRIORITY_4 = 1 / 3;
|
||||
W_PRIORITY_6 = 1 / 2;
|
||||
}
|
||||
if (x.matches("MMM") ||
|
||||
y.matches("MMM")) {
|
||||
weight *= W_PRIORITY_1;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
1 XMMM // Vierter in der Reihe
|
||||
1 MXMM
|
||||
2 XEEE // Vierter beim Gegner
|
||||
2 EXEE
|
||||
3 _XMM_ // Sicherer Sieg nächste Runde
|
||||
3 _MXM_
|
||||
4 _XEE_ // Sicherer Sieg des Gegners nächste Runde
|
||||
4 _EXE_
|
||||
5 XMM_ // Möglicher Sieg nächste Runde
|
||||
5 _XMM
|
||||
5 MXM_
|
||||
6 XEE_ // Möglicher Sieg des Gegners in der nächsten Runde
|
||||
6 _XEE
|
||||
6 EXE_
|
||||
+ 1 XMMM // Vierter in der Reihe
|
||||
+ 1 MXMM
|
||||
- 2 XEEE // Vierter beim Gegner
|
||||
- 2 EXEE
|
||||
+ 3 _XMM_ // Sicherer Sieg nächste Runde
|
||||
+ 3 _MXM_
|
||||
- 4 _XEE_ // Sicherer Sieg des Gegners nächste Runde
|
||||
- 4 _EXE_
|
||||
+ 5 XMM_ // Möglicher Sieg nächste Runde
|
||||
+ 5 _XMM
|
||||
+ 5 MXM_
|
||||
- 6 XEE_ // Möglicher Sieg des Gegners in der nächsten Runde
|
||||
- 6 _XEE
|
||||
- 6 EXE_
|
Loading…
Reference in a new issue