Works for me, although if you want a repetitive timer, you need:<div><br></div><div>setitimer(ITIMER_REAL, 0.9, 1)</div><div><br></div><div>or similar.<br><br></div><div>cheers,</div><div>Mathew Robertson</div><div><br><div class="gmail_quote">
On 5 November 2010 14:20, Nathan Bailey <span dir="ltr">&lt;<a href="mailto:nathan.bailey@monash.edu">nathan.bailey@monash.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
So the contest requires each turn to be submitted within one second. So logically, one would endeavour to use Time::HiRes and an alarm to make sure that you submit a turn no matter what happens, but I seem to have the syntax for Timer::HiRes/alarm&#39;s wrong. I would expect that this:<br>

   eval {<br>      local $SIG{ALRM} = sub { warn &quot;Alarm initiated\n&quot;; print &quot;go\n&quot;; };<br>      setitimer(ITIMER_REAL, 0.9);<br>      while(1) { ; }<br>   };<br>   if ($@) {<br>      warn &quot;Alarm happened?&quot;;<br>

      die $@;<br>   }<br>would:<br> a) initiate an alarm event 900ms after the setitimer statement is run<br> b) submit an end turn command (&#39;go&#39;) to stdout/the server = successful turn completion<br> b) make the $@ block run when it does time out (as it will, with our while(1))<br>

<br>So the above code should successfully submit empty turns every turn.<br><br>&#39;Alarm initiated&#39; does get printed, but &#39;go&#39; doesn&#39;t seem to go to the server. Am I using alarm wrong or is this a contest-specific issue?<br>

<br>thanks for your help :-)<br>Nathan<br><br><div class="gmail_quote">On 4 November 2010 19:19, Toby Corkindale <span dir="ltr">&lt;<a href="mailto:toby.corkindale@strategicdata.com.au" target="_blank">toby.corkindale@strategicdata.com.au</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">On 03/11/10 14:56, Toby Corkindale wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
On 03/11/10 12:47, Toby Corkindale wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Google is running an AI challenge - write bots to fight a (simple) game.<br>
<a href="http://ai-contest.com/" target="_blank">http://ai-contest.com/</a><br>
<br>
It supports Perl! (Albeit, only version 5.8.8! aaargh! Why so many<br>
versions behind?)<br>
<br>
I thought some of you might be interested in giving it a go.. Maybe we<br>
could have a mini-scoreboard just for Melbourne Perlmongers?<br>
<br>
I&#39;ve signed up as &quot;wintrmute&quot;.<br>
</blockquote>
<br>
Also, if you&#39;re having trouble finding the Perl starter package.. I&#39;ve<br>
combined a couple of the existing resources and put them into this Git<br>
repo to make it easier for you to get started.<br>
<br>
<a href="https://github.com/TJC/planetwars" target="_blank">https://github.com/TJC/planetwars</a><br>
</blockquote>
<br>
So far it&#39;s just Justin (tardisx) from the Adelaide Perlmongers and I (wintrmute) holding up the Aussie flag in the Perl rankings.. We&#39;re being overrun by Russians and Ukrainians though!<br>
Won&#39;t anyone else come in to help us?<br>
<br>
<a href="http://ai-contest.com/language_profile.php?lang=Perl" target="_blank">http://ai-contest.com/language_profile.php?lang=Perl</a><br>
<br>
Toby<br>
_______________________________________________<br>
Melbourne-pm mailing list<br>
<a href="mailto:Melbourne-pm@pm.org" target="_blank">Melbourne-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/listinfo/melbourne-pm</a><br>
</blockquote></div><br>
<br>_______________________________________________<br>
Melbourne-pm mailing list<br>
<a href="mailto:Melbourne-pm@pm.org">Melbourne-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/listinfo/melbourne-pm</a><br></blockquote></div><br></div>