LETSGOOOOOOO

This commit is contained in:
2024-10-09 12:32:16 +02:00
parent 80109716a3
commit 060a48f121
24 changed files with 183 additions and 14 deletions
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
+9
View File
@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="API_BUT5.5">
<CLASSES>
<root url="jar://$PROJECT_DIR$/src/API_BUT5.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/5.5-9Octobre.iml" filepath="$PROJECT_DIR$/5.5-9Octobre.iml" />
</modules>
</component>
</project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="API_BUT5.5" level="project" />
</component>
</module>
+11
View File
@@ -0,0 +1,11 @@
package Nim;
import fr.iut_fbleau.raw_api_body.entity.Plateau;
public class MainNim {
public static void main(String[] args) {
Plateau p = new PlateauNim(6);
System.out.println(MinMax.ExploreMax(p));
}
}
+46
View File
@@ -0,0 +1,46 @@
package Nim;
import fr.iut_fbleau.raw_api_body.entity.Plateau;
import fr.iut_fbleau.raw_api_body.entity.Ply;
import java.util.Iterator;
public class MinMax {
public static int ExploreMin(Plateau plateau){
int min = 1;
int temp;
if (plateau.isFinished()){
return plateau.getResult();
}
Iterator<Ply> plies = plateau.givePlies();
for (Iterator<Ply> it = plies; it.hasNext(); ) {
Ply ply = it.next();
plateau.doPly(ply);
temp = ExploreMax(plateau);
if (temp < min) min = temp;
plateau.undoPly(ply);
}
return min;
}
public static int ExploreMax(Plateau plateau){
int max = -1;
int temp;
if (plateau.isFinished()){
return plateau.getResult();
}
Iterator<Ply> plies = plateau.givePlies();
for (Iterator<Ply> it = plies; it.hasNext(); ) {
Ply ply = it.next();
plateau.doPly(ply);
temp = ExploreMin(plateau);
if (temp > max) max = temp;
plateau.undoPly(ply);
}
return max;
}
}
+25 -14
View File
@@ -12,7 +12,7 @@ public class PlateauNim implements Plateau {
public PlateauNim(int allumette) { public PlateauNim(int allumette) {
this.allumette = allumette; this.allumette = allumette;
this.currrentPlayer = currrentPlayer.JOUEUR1; this.currrentPlayer = Player.JOUEUR1;
} }
@Override @Override
@@ -21,9 +21,9 @@ public class PlateauNim implements Plateau {
} }
@Override @Override
public Result getResult() { public int getResult() {
if (isFinished()) { if (isFinished()) {
if (currrentPlayer == JOUEUR1) { if (currrentPlayer == Player.JOUEUR1) {
return Result.GAGNE; return Result.GAGNE;
} else { } else {
return Result.PERDU; return Result.PERDU;
@@ -51,6 +51,28 @@ public class PlateauNim implements Plateau {
return plies.iterator(); return plies.iterator();
} }
@Override
public void doPly(Ply ply) {
PlyNim plynim = (PlyNim) ply;
allumette -= plynim.coup;
if (currrentPlayer == Player.JOUEUR1){
currrentPlayer = Player.JOUEUR2;
} else {
currrentPlayer = Player.JOUEUR1;
}
}
@Override
public void undoPly(Ply ply) {
PlyNim plynim = (PlyNim) ply;
allumette += plynim.coup;
if (currrentPlayer == Player.JOUEUR1){
currrentPlayer = Player.JOUEUR2;
} else {
currrentPlayer = Player.JOUEUR1;
}
}
@Override @Override
public boolean isFinished() { public boolean isFinished() {
if (allumette == 0) { if (allumette == 0) {
@@ -60,16 +82,5 @@ public class PlateauNim implements Plateau {
} }
} }
@Override
public void doo(Ply arg0) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'doo'");
}
@Override
public void undo(Ply arg0) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'undo'");
}
} }
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="API_BUT5.5">
<CLASSES>
<root url="jar://$PROJECT_DIR$/src/API_BUT5.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/5.5-9Octobre.iml" filepath="$PROJECT_DIR$/5.5-9Octobre.iml" />
</modules>
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"src/API.jar"
]
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="API_BUT5.5" level="project" />
</component>
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
# Journal de bord
## 09/10/2024
Aujourd'hui nous avons intégré le code du jeu de Nim à l'API.
</br>
Par la suite nous avons développé un nouveau jeu en accord avec l'API, le Tic Tac Toe
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.