Commit e27f1786 authored by Lucmerceron's avatar Lucmerceron
Browse files

Automate integrated

parent 3e5af68c
MasterU
\ No newline at end of file
android
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="RunManager">
<configuration default="true" type="JUnit" factoryName="JUnit">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<list size="0" />
<configuration name="&lt;template&gt;" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
</configuration>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
</component>
</project>
......@@ -2,7 +2,6 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/MasterU.iml" filepath="$PROJECT_DIR$/MasterU.iml" />
<module fileurl="file://$PROJECT_DIR$/android.iml" filepath="$PROJECT_DIR$/android.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
......
......@@ -13,7 +13,6 @@
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
......@@ -38,22 +37,22 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
......@@ -80,11 +79,11 @@
</content>
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="ion-1.3.8" level="project" />
<orderEntry type="library" exported="" name="androidasync-1.3.8" level="project" />
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
</component>
</module>
package fr.istic.masteru.android.automate;
/**
* Created by Spyrit on 01/10/2014.
*/
public interface Automate {
public Score point(int code);
public Score getPoint(int index);
public Score back();
public Score last();
}
package fr.istic.masteru.android.automate;
import java.util.Stack;
import java.util.Vector;
/**
* Created by Spyrit on 01/10/2014.
*/
public class AutomateDouble implements Automate {
public Vector<Score> pile=new Vector<Score>();
public Stack<Integer> pileEtat=new Stack<Integer>();
protected int etat;
protected int numact;
protected Score score;
public AutomateDouble(int service) {
pile.add(DoublePoint.executer(-(service)).copy());
etat=0;
pileEtat.add(etat);
}
@Override
public Score point(int code) {
if(!DoublePoint.tieBreak){
if(!DoublePoint.superTieBreak){
numact= DoublePoint.action[etat][code];
etat= DoublePoint.transit[etat][code];
score= DoublePoint.executer(numact).copy();
}else{
score=DoublePoint.executer(20+code).copy();
}
}else{
score=DoublePoint.executer(10+code).copy();
}
pileEtat.add(etat);
pile.add(score);
return score;
}
@Override
public Score getPoint(int index) {
return pile.elementAt(index);
}
@Override
public Score back() {
pile.remove(pile.lastElement());
pileEtat.pop();
etat=pileEtat.lastElement();
DoublePoint.setScore(pile.lastElement());
return pile.lastElement();
}
@Override
public Score last(){
return pile.lastElement();
}
}
package fr.istic.masteru.android.automate;
import java.util.Stack;
import java.util.Vector;
/**
* Created by Spyrit on 01/10/2014.
*/
public class AutomateDoublePro implements Automate {
public Vector<Score> pile=new Vector<Score>();
public Stack<Integer> pileEtat=new Stack<Integer>();
protected int etat;
protected int numact;
protected Score score;
public AutomateDoublePro(int service){
pile.add(DoubleProPoint.executer(-(service)).copy());
etat=0;
pileEtat.add(etat);
}
@Override
public Score point(int code) {
if(!DoubleProPoint.tieBreak){
numact= DoubleProPoint.action[etat][code];
etat= DoubleProPoint.transit[etat][code];
score= DoubleProPoint.executer(numact).copy();
}else{
score=DoubleProPoint.executer(10+code).copy();
}
pileEtat.add(etat);
pile.add(score);
return score;
}
@Override
public Score getPoint(int index) {
return pile.elementAt(index);
}
@Override
public Score back() {
pile.remove(pile.lastElement());
pileEtat.pop();
etat=pileEtat.lastElement();
DoubleProPoint.setScore(pile.lastElement());
return pile.lastElement();
}
@Override
public Score last(){
return pile.lastElement();
}
}
package fr.istic.masteru.android.automate;
import java.util.Vector;
import java.util.Stack;
/**
* Created by Spyrit on 30/09/2014.
*/
public class AutomateSimple implements Automate{
public Vector<Score> pile=new Vector<Score>();
public Stack<Integer> pileEtat=new Stack<Integer>();
protected int etat;
protected int numact;
protected Score score;
public AutomateSimple(int service){
pile.add(SimplePoint.executer(-(service)).copy());
etat=0;
pileEtat.add(etat);
}
@Override
public Score point(int code){
/** Vérification TieBreak */
if(!SimplePoint.tieBreak){
numact= SimplePoint.action[etat][code];
etat= SimplePoint.transit[etat][code];
score= SimplePoint.executer(numact).copy();
}else{
score= SimplePoint.executer(10 + code).copy();
}
pileEtat.add(etat);
pile.add(score);
return score;
}
@Override
public Score getPoint(int index){
return pile.elementAt(index);
}
@Override
public Score back(){
pile.remove(pile.lastElement());
pileEtat.pop();
etat=pileEtat.lastElement();
SimplePoint.setScore(pile.lastElement());
return pile.lastElement();
}
@Override
public Score last(){
return pile.lastElement();
}
}
\ No newline at end of file
package fr.istic.masteru.android.automate;
/**
* Created by Spyrit on 01/10/2014.
*/
public class DoublePoint{
private static Score score;
private static int a,b,c,d;
public static boolean tieBreak=false;
public static int tieService;
public static boolean superTieBreak=false;
public static final int[][] action={
/* état 1 2 */
/*0:0*/ {1,2},
/*15:0*/ {1,2},
/*0:15*/ {1,2},
/*15:15*/ {1,2},
/*30:0*/ {3,2},
/*0:30*/ {1,4},
/*30:15*/ {3,2},
/*15:30*/ {1,4},
/*30:30*/ {3,4},
/*40:0*/ {5,2},
/*0:40*/ {1,6},
/*40:15*/ {5,2},
/*15:40*/ {1,6},
/*40:30*/ {5,4},
/*30:40*/ {3,6},
/*40:40*/ {5,6}
};
public static final int[][] transit={
/* état 1 2 */
/*0:0*/ {1,2},
/*15:0*/ {4,3},
/*0:15*/ {3,5},
/*15:15*/ {6,7},
/*30:0*/ {9,6},
/*0:30*/ {7,10},
/*30:15*/ {11,8},
/*15:30*/ {8,12},
/*30:30*/ {13,14},
/*40:0*/ {0,11},
/*0:40*/ {12,0},
/*40:15*/ {0,13},
/*15:40*/ {14,0},
/*40:30*/ {0,15},
/*30:40*/ {15,0},
/*40:40*/ {0,0},
};
public static Score executer(int numact){
switch (numact){
/* Init service B */
case -1:
score = new Score(0,0,0,0,0,0,1);
tieBreak=false;
tieService=1;
superTieBreak=false;
break;
/* Init service A */
case 0:
score = new Score(0,0,0,0,0,0,0);
tieBreak=false;
tieService=1;
superTieBreak=false;
break;
/* A marque 15 point */
case 1:
score.setScoreA(score.getScoreA()+15);
break;
/* B marque 15 point */
case 2:
score.setScoreB(score.getScoreB()+15);
break;
/* A marque 10 point */
case 3:
score.setScoreA(score.getScoreA()+10);
break;
/* B marque 10 point */
case 4:
score.setScoreB(score.getScoreB()+10);
break;
/* A marque un jeu */
case 5:
score.setScoreA(0);
score.setScoreB(0);
/* Récupération des jeux */
a=score.getGamesA();
b=score.getGamesB();
/* Récupération des sets */
c=score.getSetA();
d=score.getSetB();
/* Incrémentation jeux de A */
a++;
/* Vérification si A marque un set */
if((a>=6)&&((a-b)>=2)){
a=0;
b=0;
c++;
if((c==1)&&(d==1)){
superTieBreak=true;
}
}else if((a==6)&&(b==6)){
tieBreak=true;
}
score.setGamesA(a);
score.setGamesB(b);
score.setSetA(c);
score.setService((score.getService()+1)%2);
break;
/* B marque un jeu */
case 6:
score.setScoreA(0);
score.setScoreB(0);
/* Récupération des jeux */
a=score.getGamesA();
b=score.getGamesB();
/* Récupération des sets */
c=score.getSetA();
d=score.getSetB();
/* Incrémentation jeux de B */
b++;
/* Vérification si B marque un set */
if((b>=6)&&((b-a)>=2)){
a=0;
b=0;
d++;
if((c==1)&&(d==1)){
superTieBreak=true;
}
}else if((a==6)&&(b==6)){
tieBreak=true;
}
score.setGamesA(a);
score.setGamesB(b);
score.setSetA(d);
score.setService((score.getService()+1)%2);
break;
/** A marque au tie-break => Gagne un set */
case 10:
/* Récupération des scores */
score.setScoreA(score.getScoreA()+1);
a=score.getScoreA();
b=score.getScoreB();
if((a>=7)&&((a-b)>=2)){
/** cas où a marque et gagne le set */
score.setScoreA(0);
score.setScoreB(0);
score.setGamesB(0);
score.setGamesA(0);
score.setSetA(score.getSetA() + 1);
score.setService((score.getService() + 1) % 2);
/** Fin de l'état TieBreak */
tieBreak=false;
tieService=1;
}
tieService--;
if(tieService==0){
tieService=2;
score.setService((score.getService()+1)%2);
}
break;
/** B marque au tie-break => Gagne un set*/
case 11:
/* Récupération des scores */
score.setScoreB(score.getScoreB() + 1);
a=score.getScoreA();
b=score.getScoreB();
if((b>=7)&&((b-a)>=2)) {
/** cas où b marque et gagne le set */
score.setScoreA(0);
score.setScoreB(0);
score.setGamesB(0);
score.setGamesA(0);
score.setSetB(score.getSetB() + 1);
score.setService((score.getService() + 1) % 2);
/** Fin de l'état TieBreak */
tieBreak=false;
tieService=1;
}
tieService--;
if(tieService==0){
tieService=2;
score.setService((score.getService()+1)%2);
}
break;
/** A marque au super_tie-break */
case 20:
score.setScoreA(score.getScoreA() + 1);
a=score.getScoreA();
b=score.getScoreB();
if((a>=10)&&((a-b)>=2)) {
/** cas où A marque et gagne le set */
score.setScoreA(0);
score.setScoreB(0);
score.setGamesB(0);
score.setGamesA(0);
score.setSetA(score.getSetA() + 1);
score.setService((score.getService() + 1) % 2);
/** Fin de l'état superTieBreak */
superTieBreak=false;
tieService=1;
}
tieService--;
if(tieService==0){
tieService=2;
score.setService((score.getService()+1)%2);
}
break;
/** B marque au super_tie-break */
case 21:
score.setScoreB(score.getScoreB() + 1);
a=score.getScoreA();
b=score.getScoreB();
if((b>=10)&&((b-a)>=2)) {
/** cas où A marque et gagne le set */
score.setScoreA(0);
score.setScoreB(0);
score.setGamesB(0);
score.setGamesA(0);
score.setSetB(score.getSetB() + 1);
score.setService((score.getService() + 1) % 2);
/** Fin de l'état superTieBreak */