[Home]Starrynte/MeleeEvaluater

Robo Home | Starrynte | Changes | Preferences | AllPages

Difference (from prior author revision) (major diff, minor diff)

Added: 0a1,39
Instructions for Use
* 1. Copy the code at Melee Evaluater Code
* 2. Paste it into a new class called MeleeEvaluate?
* 3. Change the package name to the package that you'll use the evaluater in
* 4. Compile MeleeEvaluate?
* 5. Copy and paste this line of code into the bot, before run() (with the variables):

static MeleeEvaluate me;

* 6. Then, inside run(), but outside the infinite loop (right after public void run() ), copy and paste this code:

if(me==null){
me=new MeleeEvaluate(this);
}
Condition go=new Condition("go"){
public boolean test(){
return true;
}
};
go.setPriority(100);
addCustomEvent(go);

If your bot uses blocking calls, make sure this code goes before the blocking calls in run()
* 7. Finally, copy and paste this code right outside run() (as an event):

public void onCustomEvent(CustomEvent e){
me.execute();
}

* 8. Compile your bot, run it in battles, and watch the console!

Release info

"Beta" release
* Please report any problems.
** The melee evaluater currently only works with an even number bot battle (i.e. 10 bots (the usual), 6 bots).
** The melee evaluater currently only works with AdvancedRobots?.
* Please tell me any suggestions. The code can be freely copied or altered for use.

Comments, questions, suggestions


Changed: 10c49
* The reason it wouldn't work for the WinEvent? is because its priority is higher than you can set a custom event to, so it gets called before you can get it in getAllEvents?(). When it gets called it gets removed from the events que, so getAllEvents? doesn't include it. -- Skilgannon
* The reason it wouldn't work for the WinEvent? is because its priority is higher than you can set a custom event to, so it gets called before you can get it in getAllEvents?(). When it gets called it gets removed from the events que, so getAllEvents? doesn't include it. -- Skilgannon

Instructions for Use
static MeleeEvaluate me;
		if(me==null){
			me=new MeleeEvaluate(this);
		}
		Condition go=new Condition("go"){
				public boolean test(){
					return true;
				}
			};
		go.setPriority(100);
		addCustomEvent(go);
If your bot uses blocking calls, make sure this code goes before the blocking calls in run()
	public void onCustomEvent(CustomEvent e){
		me.execute();
	}

Release info
"Beta" release

Comments, questions, suggestions
I've started on a "Melee Evaluater"... First, a quick question: IS IT POSSIBLE to HAVE a, say onScannedRobot, from ANOTHER CLASS that HAS an ADVANCEDROBOT which is the AdvancedRobot I'm trying to get the onScannedRobot from? In other words, when an event occurs in a robot, can another class that has an instance (if my Java terminology is correct :) ) of the robot "catch" the event? If not, then the bot will have to have "meleeeval.onHitRobot?(e)", "meleeeval.onHitByBullet?(e)", etc. which will make implementing the evaluater into bots harder... --Starrynte

Yes, you can do bot.getAllEvents?();. However, this has to be called after the execute() and some events will be ignored, eg. those with a priority of 100. You have to create an event that has a priority of 99 and put the event distribution code in there. -- Skilgannon


Robo Home | Starrynte | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited February 18, 2008 23:10 EST by Starrynte (diff)
Search: