|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.pogamut.Client.Agent
cz.cuni.utils.TestBot
public class TestBot
PLAYGROUND for the platform testers :-) This bot contains a lot of code and isn't that stupid at all! This is the Hunter. It collects weapons in map, runs for medkits when it's health is low, trying to kill anybody from different team on sight. Well it's not clever as it doesn't trying to follow it's prey around the corner. And that is where you can step in and start to play with our platform!
derived from AdvancedBot
Plan / if-then rules organization:
It doesn't look hard, but it's not so simple - check out respective methods for those states and then think about how you could improve this Hunter.
Hunter is also counting it's deaths and frag for itself.
Field Summary | |
---|---|
int |
deaths
how many times the hunter died |
private Player |
enemy
the enemy we're fixed at. |
int |
frags
how many bot the hunter killed |
int |
healthLevel
how low the health level should be to start collecting healht |
protected Item |
choosenItem
choosen item for the state seeItem |
protected java.util.ArrayList<Item> |
choosenMedKits
choose med kits for the stateMedKit |
private java.util.ArrayList<Item> |
itemsToRunAround
is used to store shuffled list of weapons bot runs around |
private boolean |
jumped
walking mystic properties - prevent bot from continuous jumping - he will jump only once |
private Player |
lastEnemy
last enemy which disappeared from agent's view |
protected int |
MAX_ATTEMPTS
max attempts in reaching the item |
protected Item |
previousChoosenItem
Stores last unreachable item - item that bot chose and was not able to go to. |
boolean |
shouldCollectHealth
boolean switch to activate collect health |
boolean |
shouldCollectItems
boolean switch to activate collect items |
boolean |
shouldEngage
boolean switch to activate engage |
boolean |
shouldPursue
boolean switch to activate pursue |
boolean |
shouldRearm
boolean switch to activate rearm |
boolean |
useAStar
use built-in A* algorithm or not use built-in A* algorithm? |
protected int |
walkingAttempts
counter for attempts in reaching the item |
Fields inherited from class cz.cuni.pogamut.Client.Agent |
---|
bindedParserType, body, flagLogicTemporalyStopped, gameBotConnection, gameMap, GARBAGE_COLLECTOR_FREQUENCY, instancesAlive, iterationEndListeners, log, logicFrequency, logicFrequencyChanged, memory, oldLogicFrequency, parserLogger, pauseHolders, platformLog, random, rawGBLog |
Constructor Summary | |
---|---|
TestBot()
|
Method Summary | |
---|---|
protected boolean |
canRunAlongMedKit()
checks whether there are any medkit items around and if there are checks if the agent is not standing on the first one in the choosenMedKits (bot got stucked because nearestHealth returns Healths according to inventory spots not to the current situation, so the bot with low health got stucked on the inventory spot) |
protected void |
doLogic()
Main method of the bot's brain - we're going to do some thinking about the situation we're in (how it's unfair to be the bot in the gloomy world of UT2004 :-). |
protected boolean |
hasBetterWeapon()
has better weapon - this magic check goes through weapons in inventory and according to their characteristics decides which is the best - that means which effectiveDistance is lowest and which maximal distance is big enough to reach enemy. |
private Item |
chooseItem()
Reasoning about what to do with seen item the easiest way of handeling it will be just to take it every time, but what should we do when there are many of items laying in front of agent? |
private Weapon |
chooseWeapon()
choose weapon according to the one he is currently holding has melee and see ranged => pick up ranged has ranged and see melee => pick up melee pick up first weapon he sees |
static void |
main(java.lang.String[] Args)
|
protected void |
postPrepareAgent()
Prepares list of agent will run around. |
protected void |
prePrepareAgent()
prepares agent logic to run - like initializing neural networks etc. |
void |
receiveMessage(RcvMsgEvent e)
This is method from interface RcvMsgListener, every message that goes from GB2004 to Agent goes also through here. |
private boolean |
seeAnyReachableItemAndWantIt()
sees reachable item and wants it |
protected void |
stateEngage()
Fired when bot see any enemy. |
protected void |
stateGoAtLastEnemyPosition()
State pursue is for pursuing enemy who was for example lost behind a corner. |
protected void |
stateHit()
Fired when bot is damaged, it has those options: He has idea where to turn to from to DAM message He got no idea at all -> turns around |
protected void |
stateChangeToBetterWeapon()
changes to better weapon that he posseses |
protected void |
stateMedKit()
runs along healths of strenght at least 8 to recover health |
protected void |
stateRunAroundItems()
call predefined function in GameMap - runAroundWeaponsInTheMap |
protected void |
stateSeeItem()
run along the path to choosen item |
protected void |
stateStopShooting()
Fired when bot loose enemy from his view He just stops shooting and no more wastes his ammo |
protected void |
stateWalking()
Fired when bot is moving, checks few accidents than can happen to him Wall collision Fell of the bot Bump to another actor of the game |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Item choosenItem
protected java.util.ArrayList<Item> choosenMedKits
private java.util.ArrayList<Item> itemsToRunAround
private Player lastEnemy
private Player enemy
protected final int MAX_ATTEMPTS
protected Item previousChoosenItem
protected int walkingAttempts
private boolean jumped
public boolean useAStar
public boolean shouldEngage
public boolean shouldPursue
public boolean shouldRearm
public boolean shouldCollectItems
public boolean shouldCollectHealth
public int healthLevel
public int frags
public int deaths
Constructor Detail |
---|
public TestBot()
Method Detail |
---|
protected void prePrepareAgent()
Agent
prePrepareAgent
in class Agent
protected void postPrepareAgent()
postPrepareAgent
in class Agent
protected void doLogic()
Check out the javadoc for this class - there you find a basic concept of this bot.
doLogic
in class Agent
protected void stateChangeToBetterWeapon()
protected boolean hasBetterWeapon()
Note!: Both effective and maximal distance are guessed and therefore could not work exactly
protected void stateEngage()
protected void stateStopShooting()
protected void stateHit()
protected void stateWalking()
protected void stateGoAtLastEnemyPosition()
protected boolean canRunAlongMedKit()
(bot got stucked because nearestHealth returns Healths according to inventory spots not to the current situation, so the bot with low health got stucked on the inventory spot)
protected void stateMedKit()
private Weapon chooseWeapon()
private Item chooseItem()
private boolean seeAnyReachableItemAndWantIt()
protected void stateSeeItem()
protected void stateRunAroundItems()
public void receiveMessage(RcvMsgEvent e)
receiveMessage
in interface RcvMsgListener
receiveMessage
in class Agent
public static void main(java.lang.String[] Args) throws java.net.URISyntaxException, java.lang.InterruptedException
java.net.URISyntaxException
java.lang.InterruptedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |