[Defconapi] Extensive use of SendChatMessage 3

Jakub Gemrot jakub.gemrot at gmail.com
Mon Oct 5 09:37:51 CDT 2009


Hi Robin, my fault! I've totally missed DebugLog method - that's
strange as I did not have them inside my JBot.java,
but I've been changing this file a lot lately (adding JavaDocs mainly)
and probably I've deleted them from the file by accident.

I'm going to poke these DebugLog() methods soon - thanks for pointing
that out! I don't think you really have to investigate that
issue with SendChatMessage(), only if you find free time :-) ... out
of curiosity.

Cheers!
Jakub

On Mon, Oct 5, 2009 at 4:28 PM, Robin Baumgarten
<robin.baumgarten at gmail.com> wrote:
> Hi Jakub,
>
> That's an odd behaviour, I shall investigate that. Also, I have read
> something about spam-prevention in the Defcon source-code. If you want I can
> look up the details and see if it causes the slow-down.
>
> Meanwhile, did you have a look at DebugLog()? This is probably a better
> method for outputting debug information.
>
> Robin
>
> 2009/10/5 Jakub Gemrot <jakub.gemrot at gmail.com>
>>
>> Next iteration ...
>>
>> I've ruled out the extra thread inside JVM filling Queue of messages.
>>
>> Now I generate all messages inside update() method (which tooks 0ms
>> together with SendChatMessage() calls as reported by
>> System.currentTimeMillis() method).
>> And I've observed a strange behavior of DefCon:
>> 1) firstly, update() method is called regularly every 100 ms
>> 2) ... then something goes wrong inside DefCon ... and update() is
>> called in 150ms, next in 50ms, next in 150 ms, 50ms, 150ms, and so on
>> 3) then DefCon switches to the behavior observed in previous scenario,
>> the update() period gets longer and longer ...
>>
>> Code included...
>>
>> I'm wondering - how does DefCon decide - how long the game tick is?
>> According to the manual the update() method is called every game tick,
>> that means the tick is sometime 50ms long, sometime 150 and finally is
>> degrading.
>>
>> Jakub
>>
>> P.S.: my Java code:
>>
>>    static boolean first = true;
>>
>>    static long start;
>>
>>    static long lastRun = 0;
>>
>>    public static boolean update()
>>    {
>>        long updateStart = System.currentTimeMillis();
>>        if (first) {
>>                start = System.currentTimeMillis();
>>                first = false;
>>        } else {
>>                SendChatMessage("Sync message, update called after " +
>> (System.currentTimeMillis()-lastRun) + " ms", CHATCHANNEL_PUBLIC);
>>                int count = (int) ((System.currentTimeMillis()-lastRun) /
>> 31);
>>                for (int i = 0; i < count; ++i) {
>>                        SendChatMessage("Queue message at " +
>> (System.currentTimeMillis()-start) + " ms", CHATCHANNEL_PUBLIC);
>>                }
>>        }
>>        lastRun = System.currentTimeMillis();
>>        SendChatMessage("Update() took " + (System.currentTimeMillis() -
>> updateStart) + " ms", CHATCHANNEL_PUBLIC);
>>        return true;
>>    }
>>
>>    public static boolean initialise(String[][] _commandLineOptions)
>>    {
>>        SendChatMessage("Initialised...", CHATCHANNEL_PUBLIC);
>>        return true;
>>    }
>>
>>    public static void addEvent(int _eventType, int _causeObjectId,
>> int _targetObjectId,
>>                int _unitType, float _longitude, float _latitude)
>>    {
>>    }
>> _______________________________________________
>> Defconapi mailing list
>> Defconapi at lists.introversion.co.uk
>> http://lists.introversion.co.uk/listinfo/defconapi
>
>


More information about the Defconapi mailing list