Commit c4d62e54 authored by Yann Ramusat's avatar Yann Ramusat
Browse files

Add Agressive and Defender AIs.

parent 707bf0b8
......@@ -9,7 +9,7 @@ import core.relayer.Relayer;
* This class is used to stop all AI thread when the game finishes.
* @author Guerquin Arnaud
*
* TODO replace this class by AI_Controler (more general), thanks to avoid using this class.
* TODO replace this class by AI_Controler (more general). Thanks avoiding using this class.
*
*/
public class AIControler {
......@@ -30,6 +30,6 @@ public class AIControler {
public static void startAll() {
for(AI_Entity ai :list){
ai.start();
}
}
}
}
package artificial_intelligence;
import artificial_intelligence.AIs.AI_Behaviour;
import artificial_intelligence.AIs.BehaviourType;
import core.gamestate.GameContent;
import core.relayer.Relayer;
import java.util.ArrayList;
/**
* Created by Yann on 30/12/15.
* Created by Yann RAMUSAT on 30/12/15.
*
* This class allows to create a new entity of the indicated type.
* This class provides a way to start or stop all the current working entities (for example when initializing and quitting a map).
......@@ -45,11 +45,15 @@ public class AI_Controler {
/*** FACTORY PART ***/
public static void add(GameContent gameContent, Relayer dmr, AI_Behaviour type) {
public static void add(GameContent gameContent, Relayer dmr, BehaviourType type) {
AI_Entity ai = null;
switch(type) {
case DEFAULT:
case Basic:
ai = new AI_Entity(gameContent,dmr);
break;
default:
System.out.println("Unrecognized type of AI.");
break;
}
list.add(ai);
}
......
......@@ -18,33 +18,39 @@ import static java.lang.Math.abs;
* This class provides a functional AI working on an independant thread.
* Please instanciate the class correctly an then call start() function on this.
*
* TODO This class will be (maybe) abstract.
* All specific AI class will extend this class.
*/
public class AI_Entity extends Thread {
/* Extern information */
private GameState gameState;
protected GameState gameState;
// to have direct access to the map
private Map map;
private Relayer relayer;
protected Map map;
protected Relayer relayer;
/* Intern information */
private boolean endThread;
protected boolean endThread;
/**
* Instanciate an autonomous AI of indicated type given as context a GameContent and a Relayer to contact.
* Instanciate by default an autonomous AI given as context a GameContent and a Relayer to contact.
*
* This use the classes used by the network.
*
* @param GameContent the actual content of the game. Map + Entities.
* @param Relayer the relayer to contact.
*/
AI_Entity(GameContent gameContent, Relayer relayer) {
public AI_Entity(GameContent gameContent, Relayer relayer) {
this.gameState = gameContent.getGameState();
this.map = gameContent.getMap();
this.relayer = relayer;
}
/**
* Default constructor.
*/
public AI_Entity() {
}
/**
* Select the target.
*
......@@ -108,7 +114,7 @@ public class AI_Entity extends Thread {
* This is the function sequentially called by run.
* The behaviour of the AI is implemented here.
*
* TODO discuter de l'heritage de classes
* This is the only function that have to be overriden by specifics AIs.
*/
public void act() {
//this.move_to_victim(this.Choose_victim());
......
package artificial_intelligence.AIs;
import artificial_intelligence.AI_Entity;
import core.gamestate.GameContent;
import core.relayer.Relayer;
/**
* Created by Yann RAMUSAT on 30/12/15.
*/
public class Agressive extends AI_Entity {
/**
* Instanciate an Agressive AI given as context a GameContent and a Relayer to contact.
*
* This use the classes used by the network.
*
* @param GameContent the actual content of the game. Map + Entities.
* @param Relayer the relayer to contact.
*/
public Agressive(GameContent gameContent, Relayer relayer) {
this.gameState = gameContent.getGameState();
this.map = gameContent.getMap();
this.relayer = relayer;
}
/**
* This is the function sequentially called by run.
* The behaviour of the Agressive AI is implemented here.
*/
@Override
public void act() {
}
}
......@@ -3,6 +3,8 @@ package artificial_intelligence.AIs;
/**
* Created by yann on 30/12/15.
*/
public enum AI_Behaviour {
DEFAULT;
public enum BehaviourType {
Agressive,
Basic,
Defender;
}
package artificial_intelligence.AIs;
import artificial_intelligence.AI_Entity;
import core.gamestate.GameContent;
import core.relayer.Relayer;
/**
* Created by Yann RAMUSAT on 30/12/15.
*/
public class Defender extends AI_Entity {
/**
* Instanciate a Defender AI given as context a GameContent and a Relayer to contact.
*
* This use the classes used by the network.
*
* @param GameContent the actual content of the game. Map + Entities.
* @param Relayer the relayer to contact.
*/
public Defender(GameContent gameContent, Relayer relayer) {
this.gameState = gameContent.getGameState();
this.map = gameContent.getMap();
this.relayer = relayer;
}
/**
* This is the function sequentially called by run.
* The behaviour of the Defender AI is implemented here.
*/
@Override
public void act() {
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment