Commit 7bb9ff3f authored by erreiip's avatar erreiip
Browse files

ezzszzze

parent 997d21de
Loading
Loading
Loading
Loading
+9 −10
Changes for jeuAssemblage/src/bot/strategy/AbstractStrategyAI.java: 9 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -43,8 +43,9 @@ public class AbstractStrategyAI implements IStrategyBot {
        
        Random rand = new Random(this.seed);
        List<PlayBoard> population = createPopulation(this.model, POP_SIZE, rand);
        population.add(model);

        for (int i = 0; i < 10; i++) {
        for (int i = 0; i < 100; i++) {
            population = mutation(population, rand, 1d);
        }

@@ -66,16 +67,9 @@ public class AbstractStrategyAI implements IStrategyBot {
            double nextRand = rand.nextDouble(1);
            if ( nextRand < mutationRate) {

                if (nextRand < mutationRate / 3) {
                postMutation.add(individualMutationSwapping(parent, rand));
                }
                else if ( nextRand < (2 * mutationRate) / 3) {
                    postMutation.add(individualMutationRotation(parent, rand));
                }
                else { 
                    postMutation.add(individualMutationSwapping(parent, rand));
                }

                //postMutation.add(individualMutationRotation(parent, rand));
                //postMutation.add(individualMutationSwapping(parent, rand));
            }
        }

@@ -98,6 +92,10 @@ public class AbstractStrategyAI implements IStrategyBot {
                toSwapId = rand.nextInt(piecesParent1.size());
            }

            System.out.println((cpt + 1) + "/" + (toSwapId + 1));
            System.out.println(son.getPieces().size());
            System.out.println(son);

            son.swap(son.getPieceById(cpt + 1), son.getPieceById(toSwapId + 1));
        }

@@ -150,6 +148,7 @@ public class AbstractStrategyAI implements IStrategyBot {
        List<PlayBoard> population = new ArrayList<PlayBoard>();

        int pieceCount = model.getPieces().size();
        System.out.println(model.getPieces().size());
        for (int i = 0; i < size; i++) {

            population.add(PlayBoard.constructPlayBoard(rand.nextLong(), model.getBoardWidth(), model.getBoardHeight(),
+6 −4
Changes for jeuAssemblage/src/model/PlayBoard.java: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class PlayBoard extends AbstractListenableHM implements Listener, IPlayBo
	}


	void randomlyPlacePiece(Piece piece) {
	boolean randomlyPlacePiece(Piece piece) {

		//System.out.println("Randomly placing piece: " + piece);

@@ -97,13 +97,14 @@ public class PlayBoard extends AbstractListenableHM implements Listener, IPlayBo

			if (placePiece(x, y, piece)) {

				return;
				return true;
			}

			iteration++;

		} while (iteration < MAX_ITERATIONS);

		return false;
		// for (int i = 0; i < board.length; i++) {
	
		// 	for (int j = 0; j < board[i].length; j++) {
@@ -467,10 +468,11 @@ public class PlayBoard extends AbstractListenableHM implements Listener, IPlayBo

	public static int getPiecesCountBySeedAndDifficulty(long seed, EDifficulty difficulty) {

		return new Random(seed + 2).nextInt(difficulty.getMaxNbPieces() - difficulty.getMinNbPieces() + 1) + difficulty.getMinNbPieces();
		return new Random(seed + 2).nextInt(difficulty.getMaxNbPieces() - difficulty.getMinNbPieces() + 1)
				+ difficulty.getMinNbPieces();
	}

	public static PlayBoard constructPlayBoard(long seed, int sizeX, int sizeY, int nbPieces) {
	private static PlayBoard constructPlayBoard(long seed, int sizeX, int sizeY, int nbPieces) {

		PlayBoard playBoard = constructEmptyPlayBoard(seed, sizeX, sizeY);
		List<PieceFactory> pieceFactorys = getPossiblePieceFactorys();