[Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest)

Toby Corkindale toby.corkindale at strategicdata.com.au
Wed Nov 10 23:42:23 PST 2010

On 11/11/10 18:38, Nathan Bailey wrote:
> On 11/11/2010, at 6:22 PM, Nathan Bailey wrote:
>> I also wonder how evil it is to dig into the object, eg. for GetPlanet:
>> return ${$self->{_planets}}[$planet_id];
>> (Okay, I know how evil it is, I just wonder if it's an appropriate
>> shortcut given the amount of time that code runs)
> Oops, I see this is what you have done :-)
> I was looking at the greps lower down.
> BTW, I think croak/die is a bad idea, since death = loss?
> I was inclined to warn and return a possibly successful value (eg.
> planet 0), in the hopes that my bot may soldier on...
> [ Of course, a good bot shouldn't hit the error condition, but... :-) ]
> I think IssueOrder should have some assertions to ensure that you don't
> submit an invalid order (also instant death), but how much of that goes
> into the publicly shared module may be a question for discussion :-)

I think it's better to throw an exception - as then you can catch that 
exception at a high level and soldier on.. whereas returning a 
possibly-valid result just makes it likely you'll emit an invalid order 
and be retired from that battle.

ie. In your highest-level loop, do something like:

eval {
if ($@) {
   warn("oh crap: $@") if DEBUG;

More information about the Melbourne-pm mailing list