ajout TP1 --> exo1
This commit is contained in:
BIN
TP1/Minimax.class
Normal file
BIN
TP1/Minimax.class
Normal file
Binary file not shown.
44
TP1/Minimax.java
Normal file
44
TP1/Minimax.java
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
public class Minimax {
|
||||
|
||||
public static int pire;
|
||||
public static int res;
|
||||
public static int meilleurRes;
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(ExploreMin(1));
|
||||
|
||||
}
|
||||
|
||||
public static int ExploreMin(int n){
|
||||
if(n <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pire = 2;
|
||||
|
||||
for (int coups = 1; coups <= 3; coups++) {
|
||||
res = ExploreMax(n - coups);
|
||||
if(res < pire){
|
||||
pire = res;
|
||||
}
|
||||
}
|
||||
|
||||
return pire;
|
||||
}
|
||||
|
||||
public static int ExploreMax(int n){
|
||||
if(n <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int coups = 1; coups <= 3; coups++) {
|
||||
res = ExploreMin(n - coups);
|
||||
if(res > meilleurRes){
|
||||
meilleurRes = res;
|
||||
}
|
||||
}
|
||||
|
||||
return meilleurRes;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user