-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAI.java
More file actions
106 lines (96 loc) · 2.2 KB
/
Copy pathAI.java
File metadata and controls
106 lines (96 loc) · 2.2 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* Write a description of class AI here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class AI extends MoveableObject
{
// instance variables - replace the example below with your own
boolean easy,mixed;
/**
* Constructor for objects of class AI
*/
public AI(int xx, int yy,int aa,int bb,int xdir, int ydir)
{
super(xx,yy,aa,bb);
}
public void alg(Ball obj,String dif)
{
int random,var;
mixed=false;
var=10;
if(dif.equals(null))
dif="mixed";
if(dif.equals(""))
dif="mixed";
if(dif.equals("mixed"))
{
mixed=true;
if(obj.getScoreLeft()<obj.getScoreRight())
{
dif="hard";
}
if(obj.getScoreLeft()>obj.getScoreRight())
{
dif="easy";
}
if(obj.getScoreLeft()>obj.getScoreRight()*2)
{
dif="miss";
}
if(obj.getScoreLeft()==obj.getScoreRight())
{
dif="normal";
}
}
if(dif.equals("easy"))
{
var=4;
}
if(dif.equals("normal"))
{
var=5;
}
if(dif.equals("hard"))
{
var=6;
}
if(dif.equals("unbeatable"))
{
var=10;
}
if(dif.equals("miss"))
{
var=0;
}
if(dif.equals("bot"))
{
var=1000000;
}
random = (int)(Math.random() * var + 1);
if(random==1)
{
if(y-(b/2)<obj.getY())
ydir=-2;
if(y+(b/2)>obj.getY())
ydir=2;
}
else
{
if(y-(b/2)<obj.getY())
ydir=2;
if(y+(b/2)>obj.getY())
ydir=-2;
}
if(mixed)
dif="mixed";
}
public void walls(String S1)
{
if(S1=="Y,0")
ydir=2;
if(S1=="Y,600")
ydir=-2;
}
}