Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genie_logiciel_2015
the_dungeon_project
Commits
c4d62e54
Commit
c4d62e54
authored
Dec 30, 2015
by
Yann Ramusat
Browse files
Add Agressive and Defender AIs.
parent
707bf0b8
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/artificial_intelligence/AIControler.java
View file @
c4d62e54
...
...
@@ -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)
, t
hanks
to
avoid using this class.
* TODO replace this class by AI_Controler (more general)
. T
hanks avoid
ing
using this class.
*
*/
public
class
AIControler
{
...
...
@@ -30,6 +30,6 @@ public class AIControler {
public
static
void
startAll
()
{
for
(
AI_Entity
ai
:
list
){
ai
.
start
();
}
}
}
}
src/artificial_intelligence/AI_Controler.java
View file @
c4d62e54
package
artificial_intelligence
;
import
artificial_intelligence.AIs.
AI_
Behaviour
;
import
artificial_intelligence.AIs.Behaviour
Type
;
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
,
Behaviour
Type
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
);
}
...
...
src/artificial_intelligence/AI_Entity.java
View file @
c4d62e54
...
...
@@ -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 */
pr
ivate
GameState
gameState
;
pr
otected
GameState
gameState
;
// to have direct access to the map
pr
ivate
Map
map
;
pr
ivate
Relayer
relayer
;
pr
otected
Map
map
;
pr
otected
Relayer
relayer
;
/* Intern information */
pr
ivate
boolean
endThread
;
pr
otected
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.
*
* T
ODO discuter de l'heritage de classes
* T
his is the only function that have to be overriden by specifics AIs.
*/
public
void
act
()
{
//this.move_to_victim(this.Choose_victim());
...
...
src/artificial_intelligence/AIs/Agressive.java
0 → 100644
View file @
c4d62e54
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
()
{
}
}
src/artificial_intelligence/AIs/
AI_
Behaviour.java
→
src/artificial_intelligence/AIs/Behaviour
Type
.java
View file @
c4d62e54
...
...
@@ -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
;
}
src/artificial_intelligence/AIs/Defender.java
0 → 100644
View file @
c4d62e54
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
()
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment