Compare commits
8 Commits
Bots-aleat
...
Readme
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cad839e4d | |||
| d2f34577e2 | |||
| ebfc2df29b | |||
| 9a1ae37130 | |||
| 2dfc6014e0 | |||
| 3aec1d3f6e | |||
| a7d3e9d138 | |||
| f207da0e2b |
131
README.md
131
README.md
@@ -1,115 +1,56 @@
|
||||
# Instructions de Travail sur les Tickets
|
||||
|
||||
Ce document présente la procédure à suivre lors de la création et de la gestion des tickets de développement. Veuillez suivre chaque étape avec attention.
|
||||
## 1. Création du Ticket
|
||||
|
||||
### Titre du Ticket
|
||||
|
||||
Le titre doit décrire de manière générale la tâche à réaliser. Soyez précis, mais sans entrer dans les détails techniques. Par exemple :
|
||||
|
||||
Ajout d'une nouvelle fonctionnalité de recherche dans l'application
|
||||
|
||||
Correction du bug d'affichage sur la page d'accueil
|
||||
|
||||
### Description du Ticket
|
||||
|
||||
La description doit fournir une explication légèrement détaillée des tâches à réaliser. Elle doit inclure les éléments suivants :
|
||||
|
||||
Objectif global de la tâche
|
||||
|
||||
Étapes spécifiques ou parties du projet concernées
|
||||
|
||||
Comportement attendu une fois la tâche accomplie
|
||||
# BUT3 – Projet Jeu : Hex
|
||||
|
||||
|
||||
## 2. Création de la Branche
|
||||
Il s’agit d’une implémentation du jeu **Hex** en Java, développée à partir de l’API fournie par le Monsieur Madelaine.
|
||||
Le projet comprend un moteur de jeu fonctionnel, un affichage console pour le debug, ainsi que des bots permettant de jouer automatiquement.
|
||||
|
||||
Lorsque vous commencez à travailler sur un ticket, créez une nouvelle branche avec un nom particulier qui reflète le ticket en cours. Le format de la branche doit être :
|
||||
|
||||
nom-de-la-feature-#numeroduticket
|
||||
## Compilation
|
||||
|
||||
### Pour créer une branche :
|
||||
Depuis la racine du projet, compiler l’ensemble des fichiers Java avec la commande suivante :
|
||||
|
||||
git checkout -b feature-recherche-#123
|
||||
|
||||
## 3. Commit des Changements
|
||||
|
||||
Les commits doivent suivre la convention suivante :
|
||||
|
||||
- Le message de commit doit décrire brièvement le changement effectué.
|
||||
|
||||
- À la fin du message de commit, vous devez toujours ajouter le numéro du ticket pour faciliter le suivi des tâches.
|
||||
|
||||
Exemple de message de commit :
|
||||
|
||||
Ajout du champ de recherche sur la page d'accueil #123
|
||||
|
||||
## 4. Push de la Branche
|
||||
|
||||
Après avoir effectué vos changements et effectué vos commits, vous devrez pousser la branche sur le dépôt distant. Lors de votre premier git push, vous recevrez un message pour définir l'upstream de la branche.
|
||||
|
||||
Exemple de message affiché :
|
||||
|
||||
```
|
||||
fatal: The upstream branch 'origin/feature-recherche-#123' does not exist
|
||||
To push the branch and set the upstream, use the following command:
|
||||
git push --set-upstream origin nom-de-la-feature-#numero
|
||||
```bash
|
||||
javac -d build $(find javaAPI -name "*.java")
|
||||
```
|
||||
|
||||
|
||||
Vous devez copier et coller la commande dans votre terminal pour effectuer le push. Une fois cette commande exécutée, votre branche sera poussée vers le dépôt distant.
|
||||
|
||||
## 5. Création d'une Pull Request (PR)
|
||||
|
||||
Une fois que vous avez poussé votre branche sur Gitea, vous devez ouvrir une pull request pour demander la révision de votre code.
|
||||
|
||||
Voici les étapes pour créer une pull request correctement :
|
||||
|
||||
- Allez sur Gitea et naviguez vers le projet concerné.
|
||||
|
||||
- Cliquez sur "Branches" et vous devriez voir la branche que vous venez de pousser.
|
||||
|
||||
- Cliquez sur le bouton "Create Pull Request" à côté de votre branche.
|
||||
|
||||
Remplissez les informations nécessaires :
|
||||
|
||||
- Titre de la PR : Utilisez le même titre que celui du ticket.
|
||||
|
||||
- Description de la PR : Décrivez brièvement ce que votre PR accomplit. Vous pouvez vous baser sur la description du ticket.
|
||||
|
||||
- Revues : Assurez-vous de demander une révision par deux membres de l’équipe.
|
||||
|
||||
- Cliquez sur "Create Pull Request" pour soumettre.
|
||||
|
||||
Une fois la PR ouverte, vous devrez attendre la révision et l’approbation de l’équipe avant de pouvoir fusionner la branche dans main ou develop selon le flux de travail de votre projet.
|
||||
Les fichiers compilés (`.class`) sont générés dans le dossier `bin`.
|
||||
|
||||
|
||||
# Résumé des Commandes Git :
|
||||
## Lancer une démonstration
|
||||
|
||||
Voici un récapitulatif des commandes Git que vous utiliserez fréquemment :
|
||||
### Partie automatique (bot)
|
||||
|
||||
## 1. Créer une branche
|
||||
```bash
|
||||
java -cp build fr.iut_fbleau.HexGame.HexMain 3 autoplay
|
||||
```
|
||||
|
||||
git checkout -b feature-recherche-#123
|
||||
Ce mode permet de lancer une partie entièrement automatique en utilisant le bot implémenté dans la classe `Simulation`.
|
||||
|
||||
### Partie interactive (joueur humain)
|
||||
|
||||
```bash
|
||||
java -cp build fr.iut_fbleau.HexGame.HexMain
|
||||
```
|
||||
|
||||
Le plateau s’affiche dans le terminal et les coups sont entrés sous forme de coordonnées.
|
||||
|
||||
|
||||
## 2. Ajouter les fichiers modifiés :
|
||||
## Tests et validation
|
||||
|
||||
git add .
|
||||
git add *
|
||||
git add <nom_du_fichier>
|
||||
Les tests sont réalisés sous forme de **tests fonctionnels** via des méthodes `main` et des modes de démonstration :
|
||||
- vérification de la validité des coups,
|
||||
- alternance correcte des joueurs,
|
||||
- détection des conditions de fin de partie,
|
||||
- exécution de parties complètes en mode automatique.
|
||||
|
||||
L’affichage console du plateau, fourni par la méthode `HexBoard.toString()`, est utilisé comme outil de debug pour visualiser l’état du jeu à chaque tour.
|
||||
|
||||
|
||||
## 3. Commit des changements :
|
||||
## Organisation du projet
|
||||
|
||||
git commit -m "Ajout de [...] #numeroticket"
|
||||
- `HexBoard` : représentation du plateau et gestion des règles du jeu
|
||||
- `HexPly` : représentation d’un coup
|
||||
- `Simulation` : bot basé sur une recherche Minimax à profondeur limitée
|
||||
- `HexMain` : point d’entrée du programme
|
||||
|
||||
|
||||
## 4. Pousser la branche
|
||||
|
||||
git push -set-upstream origin <nom-de-la-branche-#numeroticket>
|
||||
|
||||
|
||||
## 5. Supprimer une branche
|
||||
|
||||
git branch -d <nom_de_la_branche>
|
||||
Les classes principales sont documentées à l’aide de **Javadoc**.
|
||||
9784
Rapport Hex.pdf
Normal file
9784
Rapport Hex.pdf
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -34,8 +34,8 @@ public abstract class AbstractGame {
|
||||
|
||||
// constructeur à appeler dans le constructeur d'un fils concret avec super.
|
||||
public AbstractGame(IBoard b, EnumMap<Player,AbstractGamePlayer> m){
|
||||
this.currentBoard=b;
|
||||
this.mapPlayers=m;
|
||||
this.currentBoard=b;
|
||||
this.mapPlayers=m;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package fr.iut_fbleau.HexGame;
|
||||
|
||||
import fr.iut_fbleau.GameAPI.*;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Scanner;
|
||||
|
||||
@@ -19,12 +18,19 @@ public class HexMain {
|
||||
HexBoard board = new HexBoard(size);
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
Result res;
|
||||
EnumMap<Player, AbstractGamePlayer> players = new EnumMap<>(Player.class);
|
||||
players.put(Player.PLAYER1, new HumanConsolePlayer(Player.PLAYER1, sc));
|
||||
players.put(Player.PLAYER2, new HumanConsolePlayer(Player.PLAYER2, sc));
|
||||
|
||||
AbstractGame game = new AbstractGame(board, players) {};
|
||||
Result res = game.run();
|
||||
|
||||
if (args.length>=2 && args[1].equals("autoplay")) {
|
||||
Simulation sim = new Simulation(board, players);
|
||||
res = sim.run();
|
||||
} else {
|
||||
AbstractGame game = new AbstractGame(board, players) {};
|
||||
res = game.run();
|
||||
}
|
||||
|
||||
System.out.println(board);
|
||||
System.out.println("Résultat (du point de vue de PLAYER1) : " + res);
|
||||
|
||||
145
javaAPI/fr/iut_fbleau/HexGame/Simulation.java
Normal file
145
javaAPI/fr/iut_fbleau/HexGame/Simulation.java
Normal file
@@ -0,0 +1,145 @@
|
||||
package fr.iut_fbleau.HexGame;
|
||||
|
||||
import fr.iut_fbleau.GameAPI.*;
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
public class Simulation extends AbstractGame {
|
||||
|
||||
//ATTRIBUTS
|
||||
private HexPly bestmove;
|
||||
private float bestoutcome;
|
||||
private int MAXDEPTH = 6;
|
||||
private LinkedList<Integer[]> taken = new LinkedList<Integer[]>();
|
||||
|
||||
//ATTRIBUTS QUE JE NE VOUDRAIS PAS CRÉER IDÉALEMENT
|
||||
private IBoard simCurrentBoard;
|
||||
private EnumMap<Player, AbstractGamePlayer> simmapPlayers;
|
||||
|
||||
//CONSTRUCTEUR
|
||||
public Simulation(IBoard b, EnumMap<Player,AbstractGamePlayer> m){
|
||||
super(b, m);
|
||||
simCurrentBoard = b;
|
||||
simmapPlayers = m;
|
||||
}
|
||||
|
||||
//METHODES
|
||||
private float explMAX(HexBoard position, int depth){
|
||||
if (position.getResult()==Result.LOSS) {
|
||||
return -1.0f;
|
||||
} else if (position.getResult()==Result.WIN){
|
||||
return 1.0f;
|
||||
} else if (depth==MAXDEPTH) {
|
||||
return 0f;
|
||||
} else {
|
||||
float bestcase = -1.0f;
|
||||
HexPly bestcasemove;
|
||||
HexPly testmove;
|
||||
for (int i=0; i<position.getSize(); i++) {
|
||||
for (int j=0; j<position.getSize(); j++) {
|
||||
if(depth==0){
|
||||
//System.out.println("MAX New Line :");
|
||||
}
|
||||
Integer[] t = new Integer[]{i, j};
|
||||
testmove = new HexPly(Player.PLAYER1, i, j);
|
||||
if(!taken.contains(t) && position.isLegal(testmove)){
|
||||
//System.out.println(" MAX test move : "+Integer.toString(i)+","+Integer.toString(j));
|
||||
taken.add(t);
|
||||
position.doPly(testmove);
|
||||
float val = explMIN(position, depth+1);
|
||||
if (val >= bestcase) {
|
||||
//System.out.println(" MAX new best case");
|
||||
bestcase = val;
|
||||
bestcasemove = testmove;
|
||||
if (depth==0) {
|
||||
this.bestoutcome = bestcase;
|
||||
this.bestmove = bestcasemove;
|
||||
}
|
||||
}
|
||||
position.undoPly();
|
||||
taken.remove(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bestcase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private float explMIN(HexBoard position, int depth){
|
||||
if (position.getResult()==Result.LOSS) {
|
||||
return -1.0f;
|
||||
} else if (position.getResult()==Result.WIN){
|
||||
return 1.0f;
|
||||
} else if (depth==MAXDEPTH) {
|
||||
return 0f;
|
||||
} else {
|
||||
float bestcase = 1.0f;
|
||||
HexPly bestcasemove;
|
||||
HexPly testmove;
|
||||
for (int i=0; i<position.getSize(); i++) {
|
||||
for (int j=0; j<position.getSize(); j++) {
|
||||
if(depth==0){
|
||||
//System.out.println("MIN New Line :");
|
||||
}
|
||||
Integer[] t = new Integer[]{i, j};
|
||||
testmove = new HexPly(Player.PLAYER2, i, j);
|
||||
if(!taken.contains(t) && position.isLegal(testmove)){
|
||||
//System.out.println(" MIN test move : "+Integer.toString(i)+","+Integer.toString(j));
|
||||
taken.add(t);
|
||||
position.doPly(testmove);
|
||||
float val = explMAX(position, depth+1);
|
||||
if (val <= bestcase) {
|
||||
//System.out.println(" MIN new best case");
|
||||
bestcase = val;
|
||||
bestcasemove = testmove;
|
||||
if (depth==0) {
|
||||
this.bestoutcome = bestcase;
|
||||
this.bestmove = bestcasemove;
|
||||
}
|
||||
}
|
||||
|
||||
position.undoPly();
|
||||
taken.remove(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bestcase;
|
||||
}
|
||||
}
|
||||
|
||||
private AbstractPly GiveBestMove(IBoard board) {
|
||||
if (!(board instanceof HexBoard)) {
|
||||
throw new IllegalArgumentException("Ce joueur attend un HexBoard.");
|
||||
}
|
||||
HexBoard hb = (HexBoard) board;
|
||||
float bestcase;
|
||||
if(hb.getCurrentPlayer()==Player.PLAYER1){
|
||||
bestcase = explMAX(hb, 0);
|
||||
} else {
|
||||
bestcase = explMIN(hb, 0);
|
||||
}
|
||||
return this.bestmove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result run(){
|
||||
while(!simCurrentBoard.isGameOver()) {
|
||||
AbstractGamePlayer player = simmapPlayers.get(simCurrentBoard.getCurrentPlayer());
|
||||
IBoard board = simCurrentBoard.safeCopy();
|
||||
AbstractPly ply = GiveBestMove(board);
|
||||
HexPly concretePly = (HexPly) ply;
|
||||
|
||||
if (simCurrentBoard.isLegal(ply)) {
|
||||
simCurrentBoard.doPly(ply);
|
||||
taken.add(new Integer[]{concretePly.getRow(), concretePly.getCol()});
|
||||
System.out.println("Player "+player+" goes ("+concretePly.getRow()+","+concretePly.getCol()+")");
|
||||
}
|
||||
else throw new IllegalStateException("Player "+ player + " is a bloody cheat. He tried playing : "+concretePly.getRow()+","+concretePly.getCol()+" I give up.");
|
||||
}
|
||||
return simCurrentBoard.getResult();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user