ajout TP1 --> exo1

This commit is contained in:
Boutaric James
2025-09-04 13:56:57 +02:00
parent 71a81885be
commit 001ee76228
2 changed files with 44 additions and 0 deletions

BIN
TP1/Minimax.class Normal file

Binary file not shown.

44
TP1/Minimax.java Normal file
View 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;
}
}