-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBot_0.java
36 lines (30 loc) · 1.07 KB
/
Bot_0.java
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
package bgs.brains.bots;
import bgs.area.IArea;
import bgs.brains.scanners.ChessKingScanner;
import bgs.brains.src.AbstractPlayer;
import bgs.brains.vars.StepLog;
import bgs.brains.vars.TimeSpan;
import bgs.visual.src.IVisual;
import java.awt.*;
/**
* @author Roman
*/
public class Bot_0 extends AbstractPlayer {
public Bot_0(IArea area, Color color, IVisual visual, String name) {
super(area, color, visual, name);
}
@Override
public StepLog step() {
if (new ChessKingScanner(this.Area).isKingDead(this.Color)) {
this.Visual.showMessage(this.Name + " defeat on " + this.stepNumber + " step.", false);
return StepLog.DEFEAT;
}
int squareNumber;
int targetSquareNumber;
do {
squareNumber = (int) (Math.random() * this.Area.getMaxSquareNumber());
targetSquareNumber = (int) (Math.random() * this.Area.getMaxSquareNumber());
} while (!this.Area.moveObjectSafe(squareNumber, targetSquareNumber, this.Color));
return this.sendNormalLog(TimeSpan.TIME_SPAN);
}
}