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 plies = plateau.givePlies(); for (Iterator 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 plies = plateau.givePlies(); for (Iterator it = plies; it.hasNext(); ) { Ply ply = it.next(); plateau.doPly(ply); temp = ExploreMin(plateau); if (temp > max) max = temp; plateau.undoPly(ply); } return max; } }