Difference between revisions of "User talk:BenHorner"

From Robowiki
Jump to navigation Jump to search
(accessing old wiki)
Line 65: Line 65:
  
 
::: There's some instructions on [[Talk:Migration#Now_at_RoboWiki.net]]. I will move the old wiki content to a subdomain at the new server. Actually, I already did, but last time I brought it up, the server ended up totally crashing. We had another bout of downtime after that, though, so maybe it wasn't really my fault - will be trying again soon. --[[User:Voidious|Voidious]] 14:07, 11 May 2009 (UTC)
 
::: There's some instructions on [[Talk:Migration#Now_at_RoboWiki.net]]. I will move the old wiki content to a subdomain at the new server. Actually, I already did, but last time I brought it up, the server ended up totally crashing. We had another bout of downtime after that, though, so maybe it wasn't really my fault - will be trying again soon. --[[User:Voidious|Voidious]] 14:07, 11 May 2009 (UTC)
 +
 +
== min/max/avg battle length (in turns/ticks)? ==
 +
 +
Can anyone give me a feel for how long battles average?  I want to use an array list to keep track of the ticks as they go by, for the random access, but I'd rather not make it reallocate itself unnecessarily often, especially when it's big.  Thanks for any help.  --[[User:BenHorner|BenHorner]] 23:48, 24 May 2009 (UTC)

Revision as of 00:48, 25 May 2009

Another Event related question... While I was just making a class to capture all the events, I noticed that there are several interfaces that appear to do this already; IBasicEvents, IBasicEvents2, IInteractiveEvents, IPaintEvents which are implemented by Robot, and IAdvancedEvents, which is implemented by AdvancedRobot. I guess I will just implement these instead of making a completely separate class.

When I saw those, I looked through the API a bit more, and noticed these interfaces: IBasicRobot and IAdvancedRobot, each of which define a method, getXXXEventListener(). These interfaces are also implemented by Robot and AdvancedRobot respectively. My question is this: Is the result of the getXXXEventListener() methods always used to call the onXXX() methods? I'd like to be able only to override the getXXXEventListener() and provide a listener, rather than having to override every single onXXX() method in my robot class. --BenHorner 01:58, 11 May 2009 (UTC)

One more tack on question... I see that IBasicRobot.getBasicEventListener() returns an IBasicEvents... But I don't see anything that returns an IBasicEvents2, is there an analogous interface I'm missing? --BenHorner 02:02, 11 May 2009 (UTC)
What a shame... I see now that the getXXXEventListener() methods are all final, so I can't override them. Anyone else have a good way(s) of handling this stuff? --BenHorner 02:38, 11 May 2009 (UTC)
I don't know if is a good way, but I only override the onXXXEvent methods, on some bots I handle the code right away while and on some bots I store some info to be handled in the run method, I still don't have a way to say one is better than the other but I've never tried to get the events any other way. --zyx 02:47, 11 May 2009 (UTC)
You do what zyx told, which we all doing that now. Those interfaces are created by Pavel Savara, who are implementing .NET for robocode. He need it since in order to perform a cross-languages API, it is need to be interface instead of classes. If you want to implements it using those interfaces, see the sampleex package, which contain only robot that using an experimental robot interfaces. But remember, you need to set -DEXPERIMENTAL=true in robocode.bat. » Nat | Talk » 03:09, 11 May 2009 (UTC)
Sorry, I gave no context for my question. I'm trying to implement interchangeable data collection components, so that I can just swap out the implementations. Some of them might collect certain pieces of data, some of them might periodically purge the oldest pieces of the history, some of them might include facilities for storing the data to disk... Thank you both for your responses! --BenHorner 03:18, 11 May 2009 (UTC)
I'm not really sure what you mean, but if I understand correctly, you can do like this:
public abstract class EventListener {
    public static EventListener current;
    public static final void activate(EventListener e) { current = e; }
    public abstract void onScanendRobot(ScannedRobotEvent e);
    // ...
}

public class WhatEverListenerYouWant implements EventListener {
    public void onScannedRobot(ScannedRobotEvent e) {
        // do whatever you want
    }
    // ...
}

public class AA extends AdvancedRobot {
    public EventListener listener1 = new WhatEverListenerYouWant();
    public EventListener listener2 = new AnotherListenerYouMayWant();
   
    // put this somewhere in your code
    EventListener.activate(listener1);

    public void onScannedRobot(ScannedRobotEvent e) {
        EventListener.current.onScannedRobot(e);
    }
    // ...
}
» Nat | Talk » 03:50, 11 May 2009 (UTC)

I see that in the robocode javadocs for the MouseEvent http://robocode.sourceforge.net/docs/robocode/; the MouseEvent class has only one method, getSourceEvent() which returns a java.awt.event.MouseEvent, which in turn contains the interesting info about the MouseEvent, but the javadocs say "Do not call this method!"... Is that really a dangerous thing to do? I think it might be useful for testing and stuff... --BenHorner 00:42, 11 May 2009 (UTC)

Looks like I might have been a little confused, all of the onMouseXXX() methods are taking java.awt.event.MouseEvent, is robocode.MouseEvent used anywhere? Maybe just vestigial...? --BenHorner 00:54, 11 May 2009 (UTC)
No, robocode.MouseEvent wasn't use anywhere like PaintEvent and KeyEvent. I think is is there to match the onXXX thing. » Nat | Talk » 01:12, 11 May 2009 (UTC)
Glad to hear that, I think I'm on the right track then, thanks Nat. --BenHorner 01:58, 11 May 2009 (UTC)

The old wiki content is still available, but not so easy to access. Voidious posted a note somewhere about how to access it -- I can copy it over if you like. Talk pages are for comments, yes. You should also sign your posts, on this wiki you just need to put in four tildes (~~~~) and it'll add your name + timestamp. The rumble is definitely running but on a new server. See RoboRumble and Darkcanuck/RRServer for details. I also put a copy of most older bots on my webserver since the repository wasn't behaving: http://darkcanuck.net/rumble/robots --Darkcanuck 04:03, 8 May 2009 (UTC)

If you want to know basic of this new wiki, look at {{Welcome}}. It contain basic information about using this wiki. » Nat | Talk » 10:38, 8 May 2009 (UTC)
Thanks for the info and the link(s). --BenHorner 21:52, 8 May 2009 (UTC)
I wouldn't mind having that link to the old wiki, or to the page that describes how to get there. I'm sure I put some stuff on there that I'd like to reread now. --BenHorner 00:42, 11 May 2009 (UTC)
There's some instructions on Talk:Migration#Now_at_RoboWiki.net. I will move the old wiki content to a subdomain at the new server. Actually, I already did, but last time I brought it up, the server ended up totally crashing. We had another bout of downtime after that, though, so maybe it wasn't really my fault - will be trying again soon. --Voidious 14:07, 11 May 2009 (UTC)

min/max/avg battle length (in turns/ticks)?

Can anyone give me a feel for how long battles average? I want to use an array list to keep track of the ticks as they go by, for the random access, but I'd rather not make it reallocate itself unnecessarily often, especially when it's big. Thanks for any help. --BenHorner 23:48, 24 May 2009 (UTC)