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

Some more unit tests and commented Entity2.

parent 5106d047
......@@ -30,6 +30,10 @@ public class AI_Controler {
private ArrayList<AbstractEntity> list=new ArrayList<>();
public ArrayList<AbstractEntity> getList() {
return list;
}
public void killAll(){
for(AbstractEntity ai :list){
ai.setEndThread(false);
......@@ -67,4 +71,5 @@ public class AI_Controler {
public int getNumber() {
return list.size();
}
}
......@@ -8,7 +8,7 @@ import core.zone.Direction;
* This class stands for a tile like in MapGen but with the needs of AI.
*/
class AITile {
public class AITile {
private int x;
private int y;
......
......@@ -10,10 +10,10 @@ import java.util.Comparator;
* Comparator for tiles. Needed for the A* algorithm.
*/
class AITileComparator implements Comparator<AITile> {
public class AITileComparator implements Comparator<AITile> {
private AITile obj;
AITileComparator(AITile obj) {
public AITileComparator(AITile obj) {
this.obj = obj;
}
......
package artificial_intelligence.test.unitTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* Created by Yann Ramusat on 31/12/15.
*
* TestSuite for the network package.
* Will launch automatically all the JUnits tests.
*
* Very helpful, code found in NetworkTests.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
AI_ControlerTest.class,
AITileComparatorTest.class
})
public class AITests{}
package artificial_intelligence.test.unitTest;
import artificial_intelligence.AlphaStar.AITileComparator;
import artificial_intelligence.AlphaStar.AITile;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by Yann RAMUSAT on 31/12/15.
*
* This is the unit test class for the AITileComparator class.
*/
public class AITileComparatorTest {
@Test
public void compareTest() {
AITile obj = new AITile(0,0);
AITile c1 = new AITile(2,1);
AITile c2 = new AITile(1,2);
AITileComparator comparator = new AITileComparator(obj);
int res = comparator.compare(c1,c2);
assertEquals(0, res);
}
@Test
public void heuristiqueTest() {
AITile obj = new AITile(0,0);
AITile c = new AITile(1,1);
AITileComparator comparator = new AITileComparator(obj);
assertEquals(0, comparator.heuristique(c));
}
}
package artificial_intelligence.test.unitTest;
import artificial_intelligence.AIEntities.AbstractEntity;
import artificial_intelligence.AIEntities.AgressiveEntity;
import artificial_intelligence.AIEntities.BasicEntity;
import artificial_intelligence.AIEntities.EnumBehaviourType;
import artificial_intelligence.AI_Controler;
......@@ -19,9 +20,9 @@ import java.util.ArrayList;
import static org.junit.Assert.*;
/**
* Created by Yann RAMUSAT on 23/11/15.
* Created by Yann RAMUSAT on 30/12/15.
*
* This is the unit test class for the controler.
* This is the unit test class for the AI_Controler class.
*/
public class AI_ControlerTest {
......@@ -29,6 +30,10 @@ public class AI_ControlerTest {
public void testadd() throws Exception {
AI_Controler.getInstance().add(null, null, EnumBehaviourType.Basic);
assertEquals(1, AI_Controler.getInstance().getNumber());
AI_Controler.getInstance().add(null, null, EnumBehaviourType.Agressive);
boolean obt = AI_Controler.getInstance().getList().get(1) instanceof AgressiveEntity;
assertEquals(true, obt);
}
@Test
......
......@@ -18,7 +18,7 @@ import graphics.guiSkeleton.sprites.Sprite;
*
* Each entity should have one instance of a subclass of this class
* It is used by the gui to know how to display the said entity
*/
*//*
abstract public class EntityDisplayer implements Serializable {
// les images doivent avoir leurs animations alignées horizontalement
//The Entity this Displayer is associated to
......@@ -40,14 +40,14 @@ abstract public class EntityDisplayer implements Serializable {
System.arraycopy(attaque[i], 0, this.attaque[i], 0, this.attaque[i].length);
System.arraycopy(touche[i], 0, this.touche[i], 0, this.touche[i].length);
}
}
}*/
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
//public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
/**
* The purpose of this function is to be called by the gui when it displays the entity related to this displayer
* @param graphicsMap: the GraphicsMap of the map the associatedEntity is on
* @return The PositionedSprite that the gui should display to represent this entity
*/
*//*
Sprite sprite = SpriteStorage.getInstance().getRonflex();
Entity entity = getAssociatedEntity();
......@@ -94,4 +94,4 @@ abstract public class EntityDisplayer implements Serializable {
public Entity getAssociatedEntity() {
return associatedEntity;
}
}
}*/
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