Commit a807b6e6 authored by erreiip's avatar erreiip
Browse files

[BOT/VIEW] Change some view things and big refacto on the bot that can now...

[BOT/VIEW] Change some view things and big refacto on the bot that can now play correctly except in some circonstance
parent 37bba758
Loading
Loading
Loading
Loading
+2 −0
Changes for jeuAssemblage/build.xml: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project name="jeuAssemblage" default="run" basedir=".">
    <property name="app.name" value="jeuAssemblage"/>
    <property name="app.version" value="0.1"/>
@@ -9,6 +10,7 @@
    <property name="lib.home" value="${basedir}/lib"/>
	<property name="resources.home" value="${basedir}/resources"/>
    <property name="javac.encoding" value="UTF-8"/>
    <property name="input.encoding" value="UTF-8" />
    <!--  ==================== Compile options ===========================  -->
    <property name="compile.debug" value="true"/>
    <property name="compile.deprecation" value="false"/>
+477 B (8.34 KiB)

File changed.

No diff preview for this file type.

+2 −0
Changes for jeuAssemblage/maps.tetriste: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,3 +5,5 @@
14;12;7;5761360446297763840;zdqzd;117
15;13;7;5544433734978013184;Shesh;121
17;15;9;8065871849407982592;Test;224
14;12;6;3997966709159476224;Test;120
12;10;6;916372059810813952;test22;56
−213 B (514 B)
Loading image diff...
+18 −7
Changes for jeuAssemblage/src/bot/BotThread.java: 18 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ public class BotThread implements Runnable {
    private ArrayList<IBot> bots;
    private ArrayList<IMovesView> movesViews;

    private ThreadGroup th;

    private boolean stop;

    public BotThread(ArrayList<IBot> bots, ArrayList<IMovesView> movesViews) {
@@ -26,6 +28,7 @@ public class BotThread implements Runnable {
        this.bots = bots;
        this.sleepTime = sleepTime;
        this.movesViews = movesViews;
        this.th = new ThreadGroup("Moves");
        this.stop = false;
    }

@@ -35,6 +38,7 @@ public class BotThread implements Runnable {

    public void stop() {
        this.stop = true;
        this.th.interrupt();
    }

    public void start() {
@@ -49,22 +53,29 @@ public class BotThread implements Runnable {

            for (int i = 0; i < this.bots.size(); i++) {
                IBot bot = this.bots.get(i);
                IMovesView movesView = this.movesViews.get(i);

                if (bot.tick()) {
                    stopable = false;
                } else {
                    movesView.start();
                }
            }

            if ( stopable ) this.stop();
            if (stopable || Thread.interrupted()) {
                this.stop = true;
            }

            try {
                Thread.sleep(10);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        
            try { Thread.sleep(sleepTime); }
            catch(Exception e ) { e.printStackTrace(); }        
        for (IMovesView movesView : this.movesViews) {
            Thread t = new Thread(this.th, movesView);
            t.start();
        }

        this.stop();
        System.out.println("fini");
    }

}
Loading