From toby.corkindale at strategicdata.com.au Tue Nov 2 18:47:06 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 03 Nov 2010 12:47:06 +1100 Subject: [Melbourne-pm] AI Contest Message-ID: <4CD0BF1A.1090302@strategicdata.com.au> Google is running an AI challenge - write bots to fight a (simple) game. http://ai-contest.com/ It supports Perl! (Albeit, only version 5.8.8! aaargh! Why so many versions behind?) I thought some of you might be interested in giving it a go.. Maybe we could have a mini-scoreboard just for Melbourne Perlmongers? I've signed up as "wintrmute". Cheers, Toby From toby.corkindale at strategicdata.com.au Tue Nov 2 19:52:28 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 03 Nov 2010 13:52:28 +1100 Subject: [Melbourne-pm] November Perlmongers meeting - 10th November Message-ID: <4CD0CE6C.3020604@strategicdata.com.au> Hi, Melbourne Perlmongers meet on the second wednesday of every month. That will be next week, the 10th of November, at 6:30pm. I think we can host at Strategic Data this month (I will confirm this shortly). I wondered if anyone has talks they would like to present? Perhaps some of you want to give a trial run of your OSDC talks? Maybe a discussion of how we're going in the AI contest I linked to earlier, tactics.. annoyances at having to use vanilla Perl 5.8? Cheers, Toby From toby.corkindale at strategicdata.com.au Tue Nov 2 20:56:12 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 03 Nov 2010 14:56:12 +1100 Subject: [Melbourne-pm] AI Contest In-Reply-To: <4CD0BF1A.1090302@strategicdata.com.au> References: <4CD0BF1A.1090302@strategicdata.com.au> Message-ID: <4CD0DD5C.6060203@strategicdata.com.au> On 03/11/10 12:47, Toby Corkindale wrote: > Google is running an AI challenge - write bots to fight a (simple) game. > http://ai-contest.com/ > > It supports Perl! (Albeit, only version 5.8.8! aaargh! Why so many > versions behind?) > > I thought some of you might be interested in giving it a go.. Maybe we > could have a mini-scoreboard just for Melbourne Perlmongers? > > I've signed up as "wintrmute". Also, if you're having trouble finding the Perl starter package.. I've combined a couple of the existing resources and put them into this Git repo to make it easier for you to get started. https://github.com/TJC/planetwars Toby From toby.corkindale at strategicdata.com.au Thu Nov 4 01:19:40 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 04 Nov 2010 19:19:40 +1100 Subject: [Melbourne-pm] AI Contest In-Reply-To: <4CD0DD5C.6060203@strategicdata.com.au> References: <4CD0BF1A.1090302@strategicdata.com.au> <4CD0DD5C.6060203@strategicdata.com.au> Message-ID: <4CD26C9C.6010703@strategicdata.com.au> On 03/11/10 14:56, Toby Corkindale wrote: > On 03/11/10 12:47, Toby Corkindale wrote: >> Google is running an AI challenge - write bots to fight a (simple) game. >> http://ai-contest.com/ >> >> It supports Perl! (Albeit, only version 5.8.8! aaargh! Why so many >> versions behind?) >> >> I thought some of you might be interested in giving it a go.. Maybe we >> could have a mini-scoreboard just for Melbourne Perlmongers? >> >> I've signed up as "wintrmute". > > Also, if you're having trouble finding the Perl starter package.. I've > combined a couple of the existing resources and put them into this Git > repo to make it easier for you to get started. > > https://github.com/TJC/planetwars So far it's just Justin (tardisx) from the Adelaide Perlmongers and I (wintrmute) holding up the Aussie flag in the Perl rankings.. We're being overrun by Russians and Ukrainians though! Won't anyone else come in to help us? http://ai-contest.com/language_profile.php?lang=Perl Toby From sevaine at gmail.com Thu Nov 4 05:10:30 2010 From: sevaine at gmail.com (AJ) Date: Thu, 04 Nov 2010 23:10:30 +1100 Subject: [Melbourne-pm] AI Contest In-Reply-To: <4CD26C9C.6010703@strategicdata.com.au> References: <4CD0BF1A.1090302@strategicdata.com.au> <4CD0DD5C.6060203@strategicdata.com.au> <4CD26C9C.6010703@strategicdata.com.au> Message-ID: <4CD2A2B6.4010302@gmail.com> > So far it's just Justin (tardisx) from the Adelaide Perlmongers and I > (wintrmute) holding up the Aussie flag in the Perl rankings.. We're > being overrun by Russians and Ukrainians though! > Won't anyone else come in to help us? > > http://ai-contest.com/language_profile.php?lang=Perl > > Toby > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm Hi All, Normally I just lurk on this list, but this game looks pretty entertaining. Have created an account (sevaine) and uploaded a starter bot :) I'm interested to see how it goes - AJ From toby.corkindale at strategicdata.com.au Thu Nov 4 17:10:27 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Fri, 05 Nov 2010 11:10:27 +1100 Subject: [Melbourne-pm] Fwd: Plat_Forms 2011 programming contest Message-ID: <4CD34B73.8020804@strategicdata.com.au> I saw this on the Catalyst list.. Thought I'd forward it through to the Melbourne list - it's a long way to go to compete for us here in Australia though :( Toby ---------- Forwarded message ---------- From: Lars D?????? ??? Hello Perl web programmers, the organisers of the [Plat_Forms contest](http://plat-forms.org/) have published the call for application. See the [announcement overview] (http://plat-forms.org/platforms-announcement#overview) for why this contest is very important for the community as a whole. Perl's esteem is at stake. ? Up to 4 teams comprised of 3 members each are needed to represent our favourite programming language. Like in the preceding contest in 2007, the Perl teams are likely self-organised and not company-backed. To facilitate that, I have set up [a page on the official Perl 5 wiki](https://www.socialtext.net/perl5/index.cgi?events_2011_plat_forms). Action required: 1. Communicate as you see fit and form more teams. 2. Post summaries to the wiki page to keep everyone updated. 3. Fill in the [application form](http://plat- forms.org/sites/default/files/Plat_Forms-applicationform.pdf) and snail-mail it to the organisers. From nathan.bailey at monash.edu Thu Nov 4 20:20:21 2010 From: nathan.bailey at monash.edu (Nathan Bailey) Date: Fri, 5 Nov 2010 14:20:21 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) Message-ID: 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's wrong. I would expect that this: eval { local $SIG{ALRM} = sub { warn "Alarm initiated\n"; print "go\n"; }; setitimer(ITIMER_REAL, 0.9); while(1) { ; } }; if ($@) { warn "Alarm happened?"; die $@; } would: a) initiate an alarm event 900ms after the setitimer statement is run b) submit an end turn command ('go') to stdout/the server = successful turn completion b) make the $@ block run when it does time out (as it will, with our while(1)) So the above code should successfully submit empty turns every turn. 'Alarm initiated' does get printed, but 'go' doesn't seem to go to the server. Am I using alarm wrong or is this a contest-specific issue? thanks for your help :-) Nathan On 4 November 2010 19:19, Toby Corkindale < toby.corkindale at strategicdata.com.au> wrote: > On 03/11/10 14:56, Toby Corkindale wrote: > >> On 03/11/10 12:47, Toby Corkindale wrote: >> >>> Google is running an AI challenge - write bots to fight a (simple) game. >>> http://ai-contest.com/ >>> >>> It supports Perl! (Albeit, only version 5.8.8! aaargh! Why so many >>> versions behind?) >>> >>> I thought some of you might be interested in giving it a go.. Maybe we >>> could have a mini-scoreboard just for Melbourne Perlmongers? >>> >>> I've signed up as "wintrmute". >>> >> >> Also, if you're having trouble finding the Perl starter package.. I've >> combined a couple of the existing resources and put them into this Git >> repo to make it easier for you to get started. >> >> https://github.com/TJC/planetwars >> > > So far it's just Justin (tardisx) from the Adelaide Perlmongers and I > (wintrmute) holding up the Aussie flag in the Perl rankings.. We're being > overrun by Russians and Ukrainians though! > Won't anyone else come in to help us? > > http://ai-contest.com/language_profile.php?lang=Perl > > Toby > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mathew.blair.robertson at gmail.com Thu Nov 4 20:48:46 2010 From: mathew.blair.robertson at gmail.com (Mathew Robertson) Date: Fri, 5 Nov 2010 14:48:46 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: References: Message-ID: Works for me, although if you want a repetitive timer, you need: setitimer(ITIMER_REAL, 0.9, 1) or similar. cheers, Mathew Robertson On 5 November 2010 14:20, Nathan Bailey wrote: > 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's wrong. I would expect that this: > eval { > local $SIG{ALRM} = sub { warn "Alarm initiated\n"; print "go\n"; }; > setitimer(ITIMER_REAL, 0.9); > while(1) { ; } > }; > if ($@) { > warn "Alarm happened?"; > die $@; > } > would: > a) initiate an alarm event 900ms after the setitimer statement is run > b) submit an end turn command ('go') to stdout/the server = successful > turn completion > b) make the $@ block run when it does time out (as it will, with our > while(1)) > > So the above code should successfully submit empty turns every turn. > > 'Alarm initiated' does get printed, but 'go' doesn't seem to go to the > server. Am I using alarm wrong or is this a contest-specific issue? > > thanks for your help :-) > Nathan > > On 4 November 2010 19:19, Toby Corkindale < > toby.corkindale at strategicdata.com.au> wrote: > >> On 03/11/10 14:56, Toby Corkindale wrote: >> >>> On 03/11/10 12:47, Toby Corkindale wrote: >>> >>>> Google is running an AI challenge - write bots to fight a (simple) game. >>>> http://ai-contest.com/ >>>> >>>> It supports Perl! (Albeit, only version 5.8.8! aaargh! Why so many >>>> versions behind?) >>>> >>>> I thought some of you might be interested in giving it a go.. Maybe we >>>> could have a mini-scoreboard just for Melbourne Perlmongers? >>>> >>>> I've signed up as "wintrmute". >>>> >>> >>> Also, if you're having trouble finding the Perl starter package.. I've >>> combined a couple of the existing resources and put them into this Git >>> repo to make it easier for you to get started. >>> >>> https://github.com/TJC/planetwars >>> >> >> So far it's just Justin (tardisx) from the Adelaide Perlmongers and I >> (wintrmute) holding up the Aussie flag in the Perl rankings.. We're being >> overrun by Russians and Ukrainians though! >> Won't anyone else come in to help us? >> >> http://ai-contest.com/language_profile.php?lang=Perl >> >> Toby >> _______________________________________________ >> Melbourne-pm mailing list >> Melbourne-pm at pm.org >> http://mail.pm.org/mailman/listinfo/melbourne-pm >> > > > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From toby.corkindale at strategicdata.com.au Thu Nov 4 21:31:20 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Fri, 05 Nov 2010 15:31:20 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: References: Message-ID: <4CD38898.7090709@strategicdata.com.au> On 05/11/10 14:20, Nathan Bailey wrote: > 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's wrong. I would expect that this: > eval { > local $SIG{ALRM} = sub { warn "Alarm initiated\n"; print "go\n"; }; > setitimer(ITIMER_REAL, 0.9); > while(1) { ; } > }; > if ($@) { > warn "Alarm happened?"; > die $@; > } > would: > a) initiate an alarm event 900ms after the setitimer statement is run > b) submit an end turn command ('go') to stdout/the server = successful > turn completion > b) make the $@ block run when it does time out (as it will, with our > while(1)) > > So the above code should successfully submit empty turns every turn. > > 'Alarm initiated' does get printed, but 'go' doesn't seem to go to the > server. Am I using alarm wrong or is this a contest-specific issue? Have you made sure to enable autoflush on stdout? Does the code work if you run the code locally with the tcp server? (ie. is it related to the sandbox the java code runs your bot in? I wouldn't be too surprised if it was blocking signals.) From scottp at dd.com.au Thu Nov 4 22:20:42 2010 From: scottp at dd.com.au (Scott Penrose) Date: Fri, 5 Nov 2010 16:20:42 +1100 Subject: [Melbourne-pm] OSDC 2011 expressions of interest Message-ID: The Open Source Developers' Conference is a grass roots open source software development conference for developers that has been running since 2004. There have been 6 conferences in Australia, and the 7th will take place in Melbourne later this month. There have also been a number of very successful international OSDC conferences. The Executive Committee are looking for expressions of interest for a team to run the conference for 2011. The conference is: * Grass roots open source software developers' conference * Run nominally over 3 days (optional tutorial days) * Has between 150 and 300 attendees * Runs around late November or the first week of December (2011) * Has 3 streams and approximately 50 talks * Tickets around $300 * Provides morning tea, lunch, afternoon tea each day, and one dinner * Run somewhere in Australia (although we would consider other local regions) What you will get as a successful team: * Solid seed funding and backup funding * List of sponsors and contacts * Help from experienced papers and organising team members * IT Infrastructure, including virtual hosting, past software, domains, email lists etc * Access to past email lists and speaker information We would like expressions of interest for running OSDC 2011 by Sunday the 14th of November 2010. They can be in any form from an email to a full presentation. We would like to know that you have secured at least a conference organiser and 2IC, with other team members joining later. Send your expression of interest to exec at osdc.com.au (Cc:scottp at dd.com.au). Although the time line is very short, this year we are providing a much longer lead time in which to gain sponsorship, and organisers. You will have just over 12 months to organise it, while previous years have had typically less than 8 months. Scott Penrose OSDC President From toby.corkindale at strategicdata.com.au Mon Nov 8 15:46:33 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Tue, 09 Nov 2010 10:46:33 +1100 Subject: [Melbourne-pm] Melbourne Perl Mongers meeting - tomorrow Message-ID: <4CD88BD9.8090307@strategicdata.com.au> Good morning, Mongers! The November Melbourne Perl Mongers meeting will be held tomorrow at 6:30pm. It will hosted by Strategic Data: Strategic Data Level 2 51-55 Johnston Street Fitzroy 3065 We'll provide some refreshments. Ingy Dot Net is in Melbourne for a while, and will give a quick talk. I'll discuss the AI Contest briefly. Does anyone else have a subject they're interested in? As always, I expect we'll have a couple of spontaneous discussions. After the meeting if we're looking for more beers, we will retire the the nearby Standard Hotel on Fitzroy street. Cheers, Toby From kim at hawtin.net.au Mon Nov 8 15:52:28 2010 From: kim at hawtin.net.au (Kim Hawtin) Date: Tue, 09 Nov 2010 10:22:28 +1030 Subject: [Melbourne-pm] OSDC meet up, was Re: Melbourne Perl Mongers meeting - tomorrow In-Reply-To: <4CD88BD9.8090307@strategicdata.com.au> References: <4CD88BD9.8090307@strategicdata.com.au> Message-ID: <4CD88D3C.6060600@hawtin.net.au> Toby Corkindale wrote: > Good morning, Mongers! > > The November Melbourne Perl Mongers meeting will be held tomorrow at > 6:30pm. It will hosted by Strategic Data: > > Strategic Data > Level 2 > 51-55 Johnston Street > Fitzroy 3065 > > We'll provide some refreshments. > > Ingy Dot Net is in Melbourne for a while, and will give a quick talk. > I'll discuss the AI Contest briefly. > Does anyone else have a subject they're interested in? > As always, I expect we'll have a couple of spontaneous discussions. > > After the meeting if we're looking for more beers, we will retire the > the nearby Standard Hotel on Fitzroy street. Is there anything scheduled in during/after OSDC for us out of town Perl folk who will be in town for a visit? cheers, Kim From toby.corkindale at strategicdata.com.au Mon Nov 8 15:56:17 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Tue, 09 Nov 2010 10:56:17 +1100 Subject: [Melbourne-pm] OSDC meet up, was Re: Melbourne Perl Mongers meeting - tomorrow In-Reply-To: <4CD88D3C.6060600@hawtin.net.au> References: <4CD88BD9.8090307@strategicdata.com.au> <4CD88D3C.6060600@hawtin.net.au> Message-ID: <4CD88E21.8040008@strategicdata.com.au> On 09/11/10 10:52, Kim Hawtin wrote: > Toby Corkindale wrote: >> Good morning, Mongers! >> >> The November Melbourne Perl Mongers meeting will be held tomorrow at >> 6:30pm. It will hosted by Strategic Data: >> >> Strategic Data >> Level 2 >> 51-55 Johnston Street >> Fitzroy 3065 >> >> We'll provide some refreshments. >> >> Ingy Dot Net is in Melbourne for a while, and will give a quick talk. >> I'll discuss the AI Contest briefly. >> Does anyone else have a subject they're interested in? >> As always, I expect we'll have a couple of spontaneous discussions. >> >> After the meeting if we're looking for more beers, we will retire the >> the nearby Standard Hotel on Fitzroy street. > > Is there anything scheduled in during/after OSDC for us out of town Perl > folk who will be in town for a visit? There isn't anything official that I know of, but I'm sure we can arrange a Perl BOF meet-up during OSDC. Wednesday 24th? (I think the OSDC dinner is on the 25th) From kim at hawtin.net.au Mon Nov 8 16:00:00 2010 From: kim at hawtin.net.au (Kim Hawtin) Date: Tue, 09 Nov 2010 10:30:00 +1030 Subject: [Melbourne-pm] OSDC meet up In-Reply-To: <4CD88E21.8040008@strategicdata.com.au> References: <4CD88BD9.8090307@strategicdata.com.au> <4CD88D3C.6060600@hawtin.net.au> <4CD88E21.8040008@strategicdata.com.au> Message-ID: <4CD88F00.5060409@hawtin.net.au> Toby Corkindale wrote: > On 09/11/10 10:52, Kim Hawtin wrote: >> Toby Corkindale wrote: >>> Good morning, Mongers! >>> >>> The November Melbourne Perl Mongers meeting will be held tomorrow at >>> 6:30pm. It will hosted by Strategic Data: >>> >>> Strategic Data >>> Level 2 >>> 51-55 Johnston Street >>> Fitzroy 3065 >>> >>> We'll provide some refreshments. >>> >>> Ingy Dot Net is in Melbourne for a while, and will give a quick talk. >>> I'll discuss the AI Contest briefly. >>> Does anyone else have a subject they're interested in? >>> As always, I expect we'll have a couple of spontaneous discussions. >>> >>> After the meeting if we're looking for more beers, we will retire the >>> the nearby Standard Hotel on Fitzroy street. >> >> Is there anything scheduled in during/after OSDC for us out of town Perl >> folk who will be in town for a visit? > > There isn't anything official that I know of, but I'm sure we can > arrange a Perl BOF meet-up during OSDC. > > Wednesday 24th? (I think the OSDC dinner is on the 25th) http://2010.osdc.com.au/programme Wednesday 6:00 - midnight Conference dinner cheers, Kim From toby.corkindale at strategicdata.com.au Mon Nov 8 16:01:10 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Tue, 09 Nov 2010 11:01:10 +1100 Subject: [Melbourne-pm] OSDC meet up In-Reply-To: <4CD88F00.5060409@hawtin.net.au> References: <4CD88BD9.8090307@strategicdata.com.au> <4CD88D3C.6060600@hawtin.net.au> <4CD88E21.8040008@strategicdata.com.au> <4CD88F00.5060409@hawtin.net.au> Message-ID: <4CD88F46.5080003@strategicdata.com.au> On 09/11/10 11:00, Kim Hawtin wrote: > Toby Corkindale wrote: >> On 09/11/10 10:52, Kim Hawtin wrote: >>> Is there anything scheduled in during/after OSDC for us out of town Perl >>> folk who will be in town for a visit? >> >> There isn't anything official that I know of, but I'm sure we can >> arrange a Perl BOF meet-up during OSDC. >> >> Wednesday 24th? (I think the OSDC dinner is on the 25th) > > http://2010.osdc.com.au/programme > > Wednesday > 6:00 - midnight Conference dinner Oh. >.< In that case, how about Thursday 25th? :) From toby.corkindale at strategicdata.com.au Tue Nov 9 19:31:50 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 10 Nov 2010 14:31:50 +1100 Subject: [Melbourne-pm] Reminder - Melbourne Perl Mongers meeting tonight! Message-ID: <4CDA1226.7070505@strategicdata.com.au> Hey everyone, The November Melbourne Perl Mongers meeting is tonight, at 6:30pm. It will hosted by Strategic Data: Strategic Data Level 2 51-55 Johnston Street Fitzroy 3065 We'll provide some refreshments. Ingy Dot Net is in Melbourne for a while, and will give a quick talk. I'll discuss the AI Contest briefly. Does anyone else have a subject they're interested in? As always, I expect we'll have a couple of spontaneous discussions. After the meeting if we're looking for more beers, we will retire the the nearby Standard Hotel on Fitzroy street. Cheers, Toby From toby.corkindale at strategicdata.com.au Wed Nov 10 20:42:42 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 15:42:42 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: References: Message-ID: <4CDB7442.9030207@strategicdata.com.au> On 05/11/10 14:20, Nathan Bailey wrote: > 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's wrong. I would expect that this: > eval { > local $SIG{ALRM} = sub { warn "Alarm initiated\n"; print "go\n"; }; > setitimer(ITIMER_REAL, 0.9); > while(1) { ; } > }; > if ($@) { > warn "Alarm happened?"; > die $@; > } > would: > a) initiate an alarm event 900ms after the setitimer statement is run > b) submit an end turn command ('go') to stdout/the server = successful > turn completion > b) make the $@ block run when it does time out (as it will, with our > while(1)) > > So the above code should successfully submit empty turns every turn. > > 'Alarm initiated' does get printed, but 'go' doesn't seem to go to the > server. Am I using alarm wrong or is this a contest-specific issue? Hi Nathan, Did you ever establish what was going on here? Also, I was just wondering - have you actually been having trouble doing enough processing inside 1000 ms? There was a point when I was exceeding it, but I was doing a lot of work over and over; It was helpful to create some data structures to hold everything at the start of each that I could just reference later. Also, note that some data won't change at all over the course of the game - the location, growth rates, and distances between planets. I note that the default starter packages are not terribly optimised either. For instance, whenever you request a planet by ID, it finds it by iterating over the whole lot of planets, and checking to see if the ID matches. >.< A quick optimisation would be to use List::Util's "first", and a better optimisation would be to store the planets in a damn hash table. (List::Util is in core Perl 5.8.8 isn't it?) I recommend sticking the fleets into a hash table based on destination while you're at it.. Cheers, Toby From kim at hawtin.net.au Wed Nov 10 20:56:09 2010 From: kim at hawtin.net.au (Kim Hawtin) Date: Thu, 11 Nov 2010 15:26:09 +1030 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <4CDB7442.9030207@strategicdata.com.au> References: <4CDB7442.9030207@strategicdata.com.au> Message-ID: <4CDB7769.7050506@hawtin.net.au> Toby Corkindale wrote: > Did you ever establish what was going on here? > > Also, I was just wondering - have you actually been having trouble doing > enough processing inside 1000 ms? > > There was a point when I was exceeding it, but I was doing a lot of work > over and over; It was helpful to create some data structures to hold > everything at the start of each that I could just reference later. > Also, note that some data won't change at all over the course of the > game - the location, growth rates, and distances between planets. > > I note that the default starter packages are not terribly optimised > either. For instance, whenever you request a planet by ID, it finds it > by iterating over the whole lot of planets, and checking to see if the > ID matches. >.< > A quick optimisation would be to use List::Util's "first", and a better > optimisation would be to store the planets in a damn hash table. > (List::Util is in core Perl 5.8.8 isn't it?) > > I recommend sticking the fleets into a hash table based on destination > while you're at it.. I was getting restless about frequently timing out. Used NYTProfile. Did away with all the hashes and implemented them in arrays. Used constants for indexes instead of hash keys. Went from 980ms to typically 270ms per turn. Now it only times out when theres more than 100 or so of my fleets on the move and that seems to be the parsing code ... regards, Kim From toby.corkindale at strategicdata.com.au Wed Nov 10 21:17:30 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 16:17:30 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <4CDB7769.7050506@hawtin.net.au> References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> Message-ID: <4CDB7C6A.2050701@strategicdata.com.au> On 11/11/10 15:56, Kim Hawtin wrote: > Toby Corkindale wrote: >> Did you ever establish what was going on here? >> >> Also, I was just wondering - have you actually been having trouble >> doing enough processing inside 1000 ms? >> >> There was a point when I was exceeding it, but I was doing a lot of >> work over and over; It was helpful to create some data structures to >> hold everything at the start of each that I could just reference later. >> Also, note that some data won't change at all over the course of the >> game - the location, growth rates, and distances between planets. >> >> I note that the default starter packages are not terribly optimised >> either. For instance, whenever you request a planet by ID, it finds it >> by iterating over the whole lot of planets, and checking to see if the >> ID matches. >.< >> A quick optimisation would be to use List::Util's "first", and a >> better optimisation would be to store the planets in a damn hash table. >> (List::Util is in core Perl 5.8.8 isn't it?) >> >> I recommend sticking the fleets into a hash table based on destination >> while you're at it.. > > I was getting restless about frequently timing out. Used NYTProfile. Did > away with all the hashes and implemented them in arrays. Used constants > for indexes instead of hash keys. Went from 980ms to typically 270ms per > turn. Now it only times out when theres more than 100 or so of my fleets > on the move and that seems to be the parsing code ... Hmm, interesting to hear. So, the array methods are quicker than hashes for small sets? You're probably not on the base starter package any more; but if so, I've made a few more improvements to it which are on my Git repo. The original author wasn't that interested in accepting my pull requests, oh well.. I'm far outranking him on the scoreboard anyway :) Toby From toby.corkindale at strategicdata.com.au Wed Nov 10 21:32:50 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 16:32:50 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <4CDB7769.7050506@hawtin.net.au> References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> Message-ID: <4CDB8002.4060208@strategicdata.com.au> On 11/11/10 15:56, Kim Hawtin wrote: > Now it only times out when theres more than 100 or so of my fleets > on the move and that seems to be the parsing code ... BTW, did you precompile and move the regexes out of the parsing loop? I *think* that improved performance, but I've been slack and am just using Time::HiRes rather than NYTProf, so maybe just ignore me :) diff --git a/PlanetWars.pm b/PlanetWars.pm index 24592c8..e8c1064 100644 --- a/PlanetWars.pm +++ b/PlanetWars.pm @@ -113,6 +113,10 @@ sub IsAlive { } } +# Cache regex's between runs.. +my $planet_r = qr/^\s*P\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)/; +my $fleet_r = qr/^\s*F\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)/; + sub ParseGameState { my ($self, $gameState) = @_; my $planet_id = 0; @@ -121,13 +125,13 @@ sub ParseGameState { foreach (@$gameState) { next if /\s*#/; # Skip comments. - if ($_ =~ m/^\s*P\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)/) {; + if ($_ =~ $planet_r) { push( @{$self->{_planets}}, new Planet($planet_id,$1,$2,$3,$4,$5) ); $planet_id++; - } elsif ($_ =~ m/^\s*F\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)/) { + } elsif ($_ =~ $fleet_r) { push( @{$self->{_fleets}}, new Fleet($fleet_id,$1,$2,$3,$4,$5,$6) From daniel at rimspace.net Wed Nov 10 21:46:18 2010 From: daniel at rimspace.net (Daniel Pittman) Date: Thu, 11 Nov 2010 16:46:18 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: <4CDB7C6A.2050701@strategicdata.com.au> (Toby Corkindale's message of "Thu, 11 Nov 2010 16:17:30 +1100") References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> Message-ID: Toby Corkindale writes: > On 11/11/10 15:56, Kim Hawtin wrote: >> Toby Corkindale wrote: >>> Did you ever establish what was going on here? >>> >>> Also, I was just wondering - have you actually been having trouble >>> doing enough processing inside 1000 ms? >>> >>> There was a point when I was exceeding it, but I was doing a lot of >>> work over and over; It was helpful to create some data structures to >>> hold everything at the start of each that I could just reference later. >>> Also, note that some data won't change at all over the course of the >>> game - the location, growth rates, and distances between planets. >>> >>> I note that the default starter packages are not terribly optimised >>> either. For instance, whenever you request a planet by ID, it finds it >>> by iterating over the whole lot of planets, and checking to see if the >>> ID matches. >.< >>> A quick optimisation would be to use List::Util's "first", and a >>> better optimisation would be to store the planets in a damn hash table. >>> (List::Util is in core Perl 5.8.8 isn't it?) >>> >>> I recommend sticking the fleets into a hash table based on destination >>> while you're at it.. >> >> I was getting restless about frequently timing out. Used NYTProfile. Did >> away with all the hashes and implemented them in arrays. Used constants >> for indexes instead of hash keys. Went from 980ms to typically 270ms per >> turn. Now it only times out when theres more than 100 or so of my fleets >> on the move and that seems to be the parsing code ... > > Hmm, interesting to hear. > So, the array methods are quicker than hashes for small sets? They should be faster than a hash for *any* set, because they are a constant time access with zero computation, rather than a just-above-constant time access with some computation. Using a constant method like 'use constant' means that you can even have symbolic names for the slot access without any greater cost; it will fold that into the generated opcodes as this shows: perl -MO=Concise -e \ 'use constant FOO => 2; my @bar = (1,2,3); print $bar[FOO];' I am surprised it made such a difference, but generally speaking that is one of the nice optimizations you can make if you are building an object system. This is one of the reasons I occasionally look at inside-out objects[1] or array-backed class storage. Generally the performance gain isn't so impressive, though, and there is more risk of complication in a non-standard object storage model. :) Daniel Footnotes: [1] Easy to use a numeric ID and a static array, although potentially costly when you handle finding the first free ID on create, and potentially painful to efficiently generate the right set of arrays if you want optimized accessors in the face of mutable objects. -- ? Daniel Pittman ? daniel at rimspace.net ? +61 401 155 707 ? made with 100 percent post-consumer electrons From toby.corkindale at strategicdata.com.au Wed Nov 10 22:01:30 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 17:01:30 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> Message-ID: <4CDB86BA.4030600@strategicdata.com.au> On 11/11/10 16:46, Daniel Pittman wrote: > Toby Corkindale writes: >> On 11/11/10 15:56, Kim Hawtin wrote: >>> Toby Corkindale wrote: >>> I was getting restless about frequently timing out. Used NYTProfile. Did >>> away with all the hashes and implemented them in arrays. Used constants >>> for indexes instead of hash keys. Went from 980ms to typically 270ms per >>> turn. Now it only times out when theres more than 100 or so of my fleets >>> on the move and that seems to be the parsing code ... >> >> Hmm, interesting to hear. >> So, the array methods are quicker than hashes for small sets? > > They should be faster than a hash for *any* set, because they are a constant > time access with zero computation, rather than a just-above-constant time > access with some computation. I was confused by how it could be computation-free for a moment, then realised you're talking about accessing things by doing $planets[$id], which of course is quicker than $planets->{$id}. I have been assuming that the IDs were more complicated and could potentially be ANY number, but now I re-read the spec I see that yes, you're only ever have a continuous list starting from 0 again each time. I have no idea why the original starter package was using linear searches then! WTF? Original code was (abbreviated code): sub GetPlanet { for ($self->Planets) { $planet = $_ if $_->GetId == $desired_id; } return $planet; } Heh. I "improved" it to be at least sub GetPlanet { return first { $_->PlanetId == $desired_id } $self->Planets; } I must make a note to fix that then! Toby From daniel at rimspace.net Wed Nov 10 22:16:46 2010 From: daniel at rimspace.net (Daniel Pittman) Date: Thu, 11 Nov 2010 17:16:46 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: <4CDB86BA.4030600@strategicdata.com.au> (Toby Corkindale's message of "Thu, 11 Nov 2010 17:01:30 +1100") References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> Message-ID: Toby Corkindale writes: > On 11/11/10 16:46, Daniel Pittman wrote: >> Toby Corkindale writes: >>> On 11/11/10 15:56, Kim Hawtin wrote: >>>> Toby Corkindale wrote: >>>> I was getting restless about frequently timing out. Used NYTProfile. Did >>>> away with all the hashes and implemented them in arrays. Used constants >>>> for indexes instead of hash keys. Went from 980ms to typically 270ms per >>>> turn. Now it only times out when theres more than 100 or so of my fleets >>>> on the move and that seems to be the parsing code ... >>> >>> Hmm, interesting to hear. >>> So, the array methods are quicker than hashes for small sets? >> >> They should be faster than a hash for *any* set, because they are a constant >> time access with zero computation, rather than a just-above-constant time >> access with some computation. > > I was confused by how it could be computation-free for a moment, then realised > you're talking about accessing things by doing $planets[$id], which of course > is quicker than $planets->{$id}. I was talking about the more general case of array vs hash, where access is zero-cost "index times size" vs some-cost "index through hash, then walk past collisions". (Presumably your comment about speed wasn't quite so restricted. :) Daniel -- ? Daniel Pittman ? daniel at rimspace.net ? +61 401 155 707 ? made with 100 percent post-consumer electrons From nathan.bailey at monash.edu Wed Nov 10 22:21:19 2010 From: nathan.bailey at monash.edu (Nathan Bailey) Date: Thu, 11 Nov 2010 17:21:19 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <4CDB7442.9030207@strategicdata.com.au> References: <4CDB7442.9030207@strategicdata.com.au> Message-ID: <7252CAFC-BB51-485E-BDE6-B5090858FB91@monash.edu> I'm using the MyBot.pl from your git repository, which has: local $| = 1; at the top, so I presume that would make it autoflush, so the alarm could print. I gave up on trying to work out the SIG ALRM stuff. I don't think I've ever had a genuine timeout. The only times I see timeouts are: 1. Bad code (the engine doesn't like "stderr", despite the docs, so if I forget to tag a 'warn', it often fails; otherwise general crashes and bugs) 2. When I've had while loop where the exit condition wasn't reached (programmer error :-) I was going to use Benchmark::Timer to profile my code, but Kim's suggestion of NYTProf is a much better one. I have written a simple engine that lets me trap most of my errors (although it doesn't reproduce the results of the java engine so presumably it has bugs too :-) I'm happy to share (eg. publish it in your git repository) it if no- one laughs at my code ;-) [ especially if people can fix its bugs! ] When I started, I wasn't sure if I just submitted 'MyBot.pl' or all the .pms too, so I avoided putting code into modules and undid my initial changes to PlanetWars.pm I think PlanetWars.pm could be way more efficient and could have a number of other helper functions (eg. ClosestPlanet() would be an obvious one) Unfortunately I seem to be able to generate bugs that can't be reproduced with either the local java engine or my simple Perl engine, and are sometimes hard to even debug on the tcp server. At the moment, I issue some orders and finish the turn and end up in an endless loop of undefined input (ie. ' next unless defined($current_line); ') which is pretty hard to debug, beyond simply truncating my code to find a codebase that it doesn't happen to. Even if I send 'go' I still don't get any input back, and I never get the final 'you timed out, you lose' messages either. re, N On 11/11/2010, at 3:42 PM, Toby Corkindale wrote: > On 05/11/10 14:20, Nathan Bailey wrote: >> 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's wrong. I would expect that this: >> eval { >> local $SIG{ALRM} = sub { warn "Alarm initiated\n"; print "go >> \n"; }; >> setitimer(ITIMER_REAL, 0.9); >> while(1) { ; } >> }; >> if ($@) { >> warn "Alarm happened?"; >> die $@; >> } >> would: >> a) initiate an alarm event 900ms after the setitimer statement is >> run >> b) submit an end turn command ('go') to stdout/the server = >> successful >> turn completion >> b) make the $@ block run when it does time out (as it will, with our >> while(1)) >> >> So the above code should successfully submit empty turns every turn. >> >> 'Alarm initiated' does get printed, but 'go' doesn't seem to go to >> the >> server. Am I using alarm wrong or is this a contest-specific issue? > > > Hi Nathan, > Did you ever establish what was going on here? > > Also, I was just wondering - have you actually been having trouble > doing enough processing inside 1000 ms? > > There was a point when I was exceeding it, but I was doing a lot of > work over and over; It was helpful to create some data structures to > hold everything at the start of each that I could just reference > later. > Also, note that some data won't change at all over the course of the > game - the location, growth rates, and distances between planets. > > I note that the default starter packages are not terribly optimised > either. For instance, whenever you request a planet by ID, it finds > it by iterating over the whole lot of planets, and checking to see > if the ID matches. >.< > A quick optimisation would be to use List::Util's "first", and a > better optimisation would be to store the planets in a damn hash > table. > (List::Util is in core Perl 5.8.8 isn't it?) > > I recommend sticking the fleets into a hash table based on > destination while you're at it.. > > Cheers, > Toby > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm From nathan.bailey at monash.edu Wed Nov 10 22:44:28 2010 From: nathan.bailey at monash.edu (Nathan Bailey) Date: Thu, 11 Nov 2010 17:44:28 +1100 Subject: [Melbourne-pm] AI Contest - some strategy In-Reply-To: <4CDB86BA.4030600@strategicdata.com.au> References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> Message-ID: My goal is to get perl into the top 100. Currently, the best Perl bot is ranked 175. Obviously I'd like to do that myself, but I'm also happy to see someone who is a better coder, mathematician or strategist than me get there, so here's some basic thoughts from me to help you get started, if you haven't already (and it's not hard to get started!) Given that this is a clearly the kind of AI problem that AI people find trivial to solve in LISP, I'm actually surprised that LISP doesn't make more of an appearance in the top 100, but the #1 bot is a LISP bot. Every game played for the rankings is recorded, and you can watch them, which gives you some insight into people's strategies - you can play back games turn-by-turn, seeing where they attack first, how many ships they send and which planets they consider most valuable. It's definitely worth doing this for the #1 bot. It's possible that you'll come up with an even better strategy that outthinks the current top ones, but the current ones have some common elements that are easily determined by watching. About 50% of the time, when I think I've improved my bot, I've actually made it worse. So before submitting it, I play it against itself. Toby's distribution includes 100 maps; I play my new bot against my old bot for all 100, and if my new bot doesn't win a majority of the games, I rework it! I've been thinking about saving the maps each time I play over TCP; I suspect there are as many as 1000. Some of the maps have significantly different configurations (eg. home planets very close to each other at the start of the game) that are likely to affect your strategy. I've also been considering writing a merged bot, based on which types of maps each variant of my bot performs best at - or perhaps I should just work out why that is the case and incorporate it into my strategy :-) Although I've joined Toby in the top 10, I don't think my bot is that sophisticated, and I'm sure I'll be overtaken once y'all have some time to improve your bots :-) N From toby.corkindale at strategicdata.com.au Wed Nov 10 22:46:38 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 17:46:38 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <7252CAFC-BB51-485E-BDE6-B5090858FB91@monash.edu> References: <4CDB7442.9030207@strategicdata.com.au> <7252CAFC-BB51-485E-BDE6-B5090858FB91@monash.edu> Message-ID: <4CDB914E.5070008@strategicdata.com.au> On 11/11/10 17:21, Nathan Bailey wrote: > I'm using the MyBot.pl from your git repository, which has: > local $| = 1; > at the top, so I presume that would make it autoflush, so the alarm > could print. The "local $| = 1;" was inherited from the original Perl starter package, which is of dubious quality; it might be better to make it "$| = 1;" instead. ie. Global, not local.. In case the alarm signal handler is occurring inside a different scope? (That's clutching at straws, but worth a shot..) > I gave up on trying to work out the SIG ALRM stuff. I don't think I've > ever had a genuine timeout. The only times I see timeouts are: > 1. Bad code (the engine doesn't like "stderr", despite the docs, so if I > forget to tag a 'warn', it often fails; otherwise general crashes and bugs) > 2. When I've had while loop where the exit condition wasn't reached > (programmer error :-) Likewise, I've found my code always has plenty of time to spare, apart from poor coding.. but then, my bot isn't that complicated either. (He just runs through three phases - 1) global analysis; 2) per-planet defensive analysis; 3) per-planet further analysis and moves. It's more like an interconnected heuristic system, rather than proper AI. Although I *want* to make it have more I and less A than it does currently.. when time allows :/ ) > I have written a simple engine that lets me trap most of my errors > (although it doesn't reproduce the results of the java engine so > presumably it has bugs too :-) > I'm happy to share (eg. publish it in your git repository) it if no-one > laughs at my code ;-) [ especially if people can fix its bugs! ] Hmm, there's already source for the C and Java implementations of the engines. If you're worried about your implementation, maybe it would be better to just modify one of the stable engines to allow for more debug output? > When I started, I wasn't sure if I just submitted 'MyBot.pl' or all the > .pms too, so I avoided putting code into modules and undid my initial > changes to PlanetWars.pm > I think PlanetWars.pm could be way more efficient and could have a > number of other helper functions (eg. ClosestPlanet() would be an > obvious one) Yeah, it could definitely do with some improvements. My Git repo holds a few by now, but only so far as improving the existing methods. I've added various things (privately) such as locating nearby planets, summing fleet-effects and predicted planet populations, but kept them private. The published code is meant to just be a starter package, after all. .. plus my code isn't very good yet, anyway. > Unfortunately I seem to be able to generate bugs that can't be > reproduced with either the local java engine or my simple Perl engine, > and are sometimes hard to even debug on the tcp server. At the moment, I > issue some orders and finish the turn and end up in an endless loop of > undefined input (ie. ' next unless defined($current_line); ') which is > pretty hard to debug, beyond simply truncating my code to find a > codebase that it doesn't happen to. Even if I send 'go' I still don't > get any input back, and I never get the final 'you timed out, you lose' > messages either. That does sound odd; something must be quite broken if it's failing at that basic level of I/O! Can you write a simple test harness to operate on the methods parsing the game-state only? From toby.corkindale at strategicdata.com.au Wed Nov 10 22:57:25 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 17:57:25 +1100 Subject: [Melbourne-pm] AI Contest - some strategy In-Reply-To: References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> Message-ID: <4CDB93D5.70903@strategicdata.com.au> On 11/11/10 17:44, Nathan Bailey wrote: > My goal is to get perl into the top 100. Currently, the best Perl bot is > ranked 175. > > Obviously I'd like to do that myself, but I'm also happy to see someone > who is a better coder, mathematician or strategist than me get there, so > here's some basic thoughts from me to help you get started, if you > haven't already (and it's not hard to get started!) > > Given that this is a clearly the kind of AI problem that AI people find > trivial to solve in LISP, I'm actually surprised that LISP doesn't make > more of an appearance in the top 100, but the #1 bot is a LISP bot. > > Every game played for the rankings is recorded, and you can watch them, > which gives you some insight into people's strategies - you can play > back games turn-by-turn, seeing where they attack first, how many ships > they send and which planets they consider most valuable. It's definitely > worth doing this for the #1 bot. It's possible that you'll come up with > an even better strategy that outthinks the current top ones, but the > current ones have some common elements that are easily determined by > watching. > > About 50% of the time, when I think I've improved my bot, I've actually > made it worse. So before submitting it, I play it against itself. Toby's > distribution includes 100 maps; I play my new bot against my old bot for > all 100, and if my new bot doesn't win a majority of the games, I rework > it! I'm not convinced of that strategy, btw. I was chatting to someone else in the competition who was trying out genetic methods of improving his bot automatically. He could get it so that every new generation would find a version that was better than the previous.. but over time, actually became worse at beating other bots. I've seen something similar too.. my current bot is much smarter than the early one, yet the early one's strategy was a bit more random, a bit more defensive, and actually does better against some specific types of enemy bots. Actually, for all the extra analysis the current one does, it still does some dumb stuff at times :/ > I've been thinking about saving the maps each time I play over TCP; I > suspect there are as many as 1000. Some of the maps have significantly > different configurations (eg. home planets very close to each other at > the start of the game) that are likely to affect your strategy. I'm pretty sure you can download the TCP maps for that TCP server from somewhere. > I've also been considering writing a merged bot, based on which types of > maps each variant of my bot performs best at - or perhaps I should just > work out why that is the case and incorporate it into my strategy :-) The latter would be best! > Although I've joined Toby in the top 10, I don't think my bot is that > sophisticated, and I'm sure I'll be overtaken once y'all have some time > to improve your bots :-) What's your username? I uploaded a new bot, and despite not getting many games given to him yet, my rank dropped first to 13, and then I uploaded another one and now I'm all the way down to 29! WTF? I'm guessing this is a "feature" of the ranking system, and hopefully I'll get back up once I get a few more games played. TOby From nathan.bailey at monash.edu Wed Nov 10 23:22:42 2010 From: nathan.bailey at monash.edu (Nathan Bailey) Date: Thu, 11 Nov 2010 18:22:42 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <4CDB914E.5070008@strategicdata.com.au> References: <4CDB7442.9030207@strategicdata.com.au> <7252CAFC-BB51-485E-BDE6-B5090858FB91@monash.edu> <4CDB914E.5070008@strategicdata.com.au> Message-ID: <5082B3F2-CB2B-4024-A65E-E30D692E7983@monash.edu> On 11/11/2010, at 5:46 PM, Toby Corkindale wrote: > The "local $| = 1;" was inherited from the original Perl starter > package, which is of dubious quality; it might be better to make it > "$| = 1;" instead. ie. Global, not local.. In case the alarm signal > handler is occurring inside a different scope? > (That's clutching at straws, but worth a shot..) Ahh, good point - the signals may be happening in some other scope. > Likewise, I've found my code always has plenty of time to spare, > apart from poor coding.. but then, my bot isn't that complicated > either. > (He just runs through three phases - 1) global analysis; 2) per- > planet defensive analysis; 3) per-planet further analysis and moves. > It's more like an interconnected heuristic system, rather than > proper AI. Although I *want* to make it have more I and less A than > it does currently.. when time allows :/ ) Despite having studied AI and neural nets, mine isn't that different. Actually, this is a problem that lends itself very well to neural nets (= finding out the optimal value for each target planet). But it's been a while since I've done either - I don't even get to code perl much these days :-) > Hmm, there's already source for the C and Java implementations of > the engines. If you're worried about your implementation, maybe it > would be better to just modify one of the stable engines to allow > for more debug output? Cool, I might play with the C one. The (compiled) java version in your repository doesn't provide any feedback, so when I crash/timeout, I don't know where or why. > Yeah, it could definitely do with some improvements. > My Git repo holds a few by now, but only so far as improving the > existing methods. Nice! What does this line do (Planet.pm and Fleet.pm)? use overload '""' => sub { shift->PlanetID }; Is there a reason you don't cache the distances (eg. in a hash?) - although I tried it, and NYTProf told me it was worse! :P 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) > I've added various things (privately) such as locating nearby > planets, summing fleet-effects and predicted planet populations, but > kept them private. The published code is meant to just be a starter > package, after all. > .. plus my code isn't very good yet, anyway. *nod* I think strategy-oriented sub-routines should be private, but I think closest planet is pretty global, ie. return either: a) a list of planets in distance order b) a list/hash of lists of planets indexed by distance > That does sound odd; something must be quite broken if it's failing > at that basic level of I/O! Can you write a simple test harness to > operate on the methods parsing the game-state only? Do you mean the 'while(1) { my $current_line = ... }' bit or my own code in DoTurn()? N From nathan.bailey at monash.edu Wed Nov 10 23:32:19 2010 From: nathan.bailey at monash.edu (Nathan Bailey) Date: Thu, 11 Nov 2010 18:32:19 +1100 Subject: [Melbourne-pm] AI Contest - some strategy In-Reply-To: <4CDB93D5.70903@strategicdata.com.au> References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> <4CDB93D5.70903@strategicdata.com.au> Message-ID: On 11/11/2010, at 5:57 PM, Toby Corkindale wrote: > On 11/11/10 17:44, Nathan Bailey wrote: >> I play my new bot against my old bot for >> all 100, and if my new bot doesn't win a majority of the games, I >> rework >> it! > > I'm not convinced of that strategy, btw. Hmm. Maybe I've thrown gold away then! :-) > I was chatting to someone else in the competition who was trying out > genetic methods of improving his bot automatically. > He could get it so that every new generation would find a version > that was better than the previous.. but over time, actually became > worse at beating other bots. Interesting - perhaps he could try it against TCP? That way he'd get a variety of bots? > I've seen something similar too.. my current bot is much smarter > than the early one, yet the early one's strategy was a bit more > random, a bit more defensive, and actually does better against some > specific types of enemy bots. > > Actually, for all the extra analysis the current one does, it still > does some dumb stuff at times :/ It's somewhat amusing to dig into your bot after it makes a decision you (the author!) don't understand :-) >> Although I've joined Toby in the top 10, I don't think my bot is that >> sophisticated, and I'm sure I'll be overtaken once y'all have some >> time >> to improve your bots :-) > > What's your username? I'm nateau, http://ai-contest.com/profile.php?user_id=12857 > I uploaded a new bot, and despite not getting many games given to > him yet, my rank dropped first to 13, and then I uploaded another > one and now I'm all the way down to 29! WTF? > I'm guessing this is a "feature" of the ranking system, and > hopefully I'll get back up once I get a few more games played. I (scan) read the Wikipedia article on Elo rankings but didn't feel that enlightened :-) It may just be that your bot has been matched against some strong ones, which has made it lose worse than it should. Oh - one other comment on strategy (presuming there are lurkers on the list, just waiting to jump into the fray!) - it's all about growth rate. If you lose the battle for growth rate, death is only a matter of time... How you balance growth rate with distance, target planet defences and competing enemy fleets while defending yourself is an exercise left to the reader :-) N From nathan.bailey at monash.edu Wed Nov 10 23:38:11 2010 From: nathan.bailey at monash.edu (Nathan Bailey) Date: Thu, 11 Nov 2010 18:38:11 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <5082B3F2-CB2B-4024-A65E-E30D692E7983@monash.edu> References: <4CDB7442.9030207@strategicdata.com.au> <7252CAFC-BB51-485E-BDE6-B5090858FB91@monash.edu> <4CDB914E.5070008@strategicdata.com.au> <5082B3F2-CB2B-4024-A65E-E30D692E7983@monash.edu> Message-ID: <68F2CD6B-90C3-45E3-BC61-C838910E1930@monash.edu> 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 :-) N From toby.corkindale at strategicdata.com.au Wed Nov 10 23:40:19 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 18:40:19 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <5082B3F2-CB2B-4024-A65E-E30D692E7983@monash.edu> References: <4CDB7442.9030207@strategicdata.com.au> <7252CAFC-BB51-485E-BDE6-B5090858FB91@monash.edu> <4CDB914E.5070008@strategicdata.com.au> <5082B3F2-CB2B-4024-A65E-E30D692E7983@monash.edu> Message-ID: <4CDB9DE3.7070709@strategicdata.com.au> On 11/11/10 18:22, Nathan Bailey wrote: > On 11/11/2010, at 5:46 PM, Toby Corkindale wrote: >> Yeah, it could definitely do with some improvements. >> My Git repo holds a few by now, but only so far as improving the >> existing methods. > > Nice! What does this line do (Planet.pm and Fleet.pm)? > use overload '""' => sub { shift->PlanetID }; If you do warn "I am planet $planet"; then instead of printing "I am planet Planet(0xd34db33f)" it will print "I am planet 42", or whatever the actual ID is. The overloaded "" operator means that it'll interpolate the result of that anonymous subroutine into strings using the object. > Is there a reason you don't cache the distances (eg. in a hash?) - > although I tried it, and NYTProf told me it was worse! :P I am doing something like that actually. However the code in the github repo is meant to be a "starter package", roughly matching the other languages' starter packages. I don't want to start putting lots of extra methods in there, or else I and anyone using it might be disqualified. You're only allowed to have one entry per person, or if in a team, you're only allowed in one team, and not separately. Publishing extra helpful code publicly could be seen as being part of many entries, if lots of people use it. From toby.corkindale at strategicdata.com.au Wed Nov 10 23:42:23 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Thu, 11 Nov 2010 18:42:23 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <68F2CD6B-90C3-45E3-BC61-C838910E1930@monash.edu> References: <4CDB7442.9030207@strategicdata.com.au> <7252CAFC-BB51-485E-BDE6-B5090858FB91@monash.edu> <4CDB914E.5070008@strategicdata.com.au> <5082B3F2-CB2B-4024-A65E-E30D692E7983@monash.edu> <68F2CD6B-90C3-45E3-BC61-C838910E1930@monash.edu> Message-ID: <4CDB9E5F.9030500@strategicdata.com.au> 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 { $self->DoTurn; }; if ($@) { warn("oh crap: $@") if DEBUG; } $self->NextTurn; From alfiejohn at gmail.com Thu Nov 11 00:38:59 2010 From: alfiejohn at gmail.com (Alfie John) Date: Thu, 11 Nov 2010 19:38:59 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> Message-ID: On Thu, Nov 11, 2010 at 5:16 PM, Daniel Pittman wrote: > >>> Hmm, interesting to hear. > >>> So, the array methods are quicker than hashes for small sets? > >> > >> They should be faster than a hash for *any* set, because they are a > constant > >> time access with zero computation, rather than a just-above-constant > time > >> access with some computation. > > > > I was confused by how it could be computation-free for a moment, then > realised > > you're talking about accessing things by doing $planets[$id], which of > course > > is quicker than $planets->{$id}. > > I was talking about the more general case of array vs hash, where access is > zero-cost "index times size" vs some-cost "index through hash, then walk > past > collisions". (Presumably your comment about speed wasn't quite so > restricted. :) > Be careful to think that this is absolutely true. Perl's arrays are not C arrays. If your index is greater than the number of elements in the array, then the array will be extended i.e. the array element pointers will be copied into a new array which can hold just one more element. This will happen *each time* you extend the size of an array i.e. push()! If you are reading and writing to an array of fixed size, then yes it's zero cost. Otherwise, know the size upfront and do something like: my @array; $array[MAX_SIZE-1] = undef; Alfie > Daniel > > -- > ? Daniel Pittman ? daniel at rimspace.net ? +61 401 155 > 707 > ? made with 100 percent post-consumer electrons > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sam at nipl.net Thu Nov 11 03:55:51 2010 From: sam at nipl.net (Sam Watkins) Date: Thu, 11 Nov 2010 22:55:51 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) Message-ID: <20101111115551.GA10472@opal.ai.ki> > Ahh, good point - the signals may be happening in some other scope. $| depend on scope, it's a global. 'local' allows to temporarily change a global variable, until the 'local' block exits. I suppose your 'local' block hasn't exited yet when the signal handler is called, so it shouldn't make any difference if you use local or not. It's going to be hard^Wimpossible to get very high scores in perl unless you use a perl native code compiler or something. You just don't have the same computation capabilities. Well-written C can be hundreds of times faster, and there's barely anything that can be done to speed up the perl code. But good luck anyway, maybe with a brilliant algorithm can get in the top 100! You definitely would need to use an algorithm that makes the most of its time, because the more it thinks the more chance to find the best move, unless the game is trivial. I'm not sure how the top bot could be a Lisp bot - perhaps that Lisp hacker is very very clever! or perhaps they are using a very neato fast Lisp compiler. I suppose to win, you'd need to do game analysis like a chess-playing program: - tree search, mini-max pruning, etc, and throw in some good heuristics! Sam From mathew.blair.robertson at gmail.com Thu Nov 11 04:04:49 2010 From: mathew.blair.robertson at gmail.com (Mathew Robertson) Date: Thu, 11 Nov 2010 23:04:49 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <20101111115551.GA10472@opal.ai.ki> References: <20101111115551.GA10472@opal.ai.ki> Message-ID: On 11 November 2010 22:55, Sam Watkins wrote: > > Ahh, good point - the signals may be happening in some other scope. > > $| depend on scope, it's a global. 'local' allows to temporarily change a > global variable, until the 'local' block exits. I suppose your 'local' > block > hasn't exited yet when the signal handler is called, so it shouldn't make > any > difference if you use local or not. > > It's going to be hard^Wimpossible to get very high scores in perl unless > you > use a perl native code compiler or something. You just don't have the same > computation capabilities. Well-written C can be hundreds of times faster, > and > there's barely anything that can be done to speed up the perl code. But > good > luck anyway, maybe with a brilliant algorithm can get in the top 100! > complete and utter hogwash. The algorithm is the important part, not the programming language. Mathew Robertson -------------- next part -------------- An HTML attachment was scrubbed... URL: From sam at nipl.net Thu Nov 11 14:08:08 2010 From: sam at nipl.net (Sam Watkins) Date: Fri, 12 Nov 2010 09:08:08 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: References: <20101111115551.GA10472@opal.ai.ki> Message-ID: <20101111220808.GB16374@opal.ai.ki> On Thu, Nov 11, 2010 at 11:04:49PM +1100, Mathew Robertson wrote: > complete and utter hogwash. > > The algorithm is the important part, not the programming language. Yes, the algorithm is most important, but given a C program with a good algorithm and a perl program with the same good algorithm, my money is on the C program, as it will have time to explore perhaps 100 times more possibilities in the game tree. Now go wash a hog! Sam From mathew.blair.robertson at gmail.com Thu Nov 11 14:33:52 2010 From: mathew.blair.robertson at gmail.com (Mathew Robertson) Date: Fri, 12 Nov 2010 09:33:52 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <20101111220808.GB16374@opal.ai.ki> References: <20101111115551.GA10472@opal.ai.ki> <20101111220808.GB16374@opal.ai.ki> Message-ID: On 12 November 2010 09:08, Sam Watkins wrote: > On Thu, Nov 11, 2010 at 11:04:49PM +1100, Mathew Robertson wrote: > > complete and utter hogwash. > > > > The algorithm is the important part, not the programming language. > > Yes, the algorithm is most important, but given a C program with a good > algorithm and a perl program with the same good algorithm, my money is on > the C program, as it will have time to explore perhaps 100 times more > possibilities in the game tree. > > Now go wash a hog! > Even that is not correct. - Perl thunks some functions directly to the C api. - C doesn't have native support for some features native to Perl (maps, regexs, etc), so you will need to either create one or use an existing one. Since those implementations might be slower than the Perl equivalent, you might end up with a slower program. Perl has had a lot of fine tuning, so you are going to have to do a lot of work (say use ASM, not C) to generate faster code. Importantly, Perl allows for rapid protyping - which (generally) cant be said for C. So while "choosing the same algorithm" for both languages might expect C to be faster, it doesn't make it so, and indeed rely's on your ability to be a better programmer than the language/library writers. Mathew Robertson -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel at rimspace.net Thu Nov 11 14:39:10 2010 From: daniel at rimspace.net (Daniel Pittman) Date: Fri, 12 Nov 2010 09:39:10 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: <20101111220808.GB16374@opal.ai.ki> (Sam Watkins's message of "Fri, 12 Nov 2010 09:08:08 +1100") References: <20101111115551.GA10472@opal.ai.ki> <20101111220808.GB16374@opal.ai.ki> Message-ID: Sam Watkins writes: > On Thu, Nov 11, 2010 at 11:04:49PM +1100, Mathew Robertson wrote: >> complete and utter hogwash. >> >> The algorithm is the important part, not the programming language. > > Yes, the algorithm is most important, but given a C program with a good > algorithm and a perl program with the same good algorithm, my money is on > the C program, as it will have time to explore perhaps 100 times more > possibilities in the game tree. > > Now go wash a hog! It would be real nice if y'all could stick to being polite on the list, avoiding language bashing (in any direction), and if y'all insist on performance claims then supply some numbers as proof. Thanks, for the committee for the reduction of pointless flames, Daniel -- ? Daniel Pittman ? daniel at rimspace.net ? +61 401 155 707 ? made with 100 percent post-consumer electrons From scottp at dd.com.au Thu Nov 11 15:00:26 2010 From: scottp at dd.com.au (Scott Penrose) Date: Fri, 12 Nov 2010 10:00:26 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <20101111220808.GB16374@opal.ai.ki> References: <20101111115551.GA10472@opal.ai.ki> <20101111220808.GB16374@opal.ai.ki> Message-ID: On 12/11/2010, at 9:08 AM, Sam Watkins wrote: > On Thu, Nov 11, 2010 at 11:04:49PM +1100, Mathew Robertson wrote: >> complete and utter hogwash. >> >> The algorithm is the important part, not the programming language. > > Yes, the algorithm is most important, but given a C program with a good algorithm and a perl program with the same good algorithm, my money is on the C program, as it will have time to explore perhaps 100 times more possibilities in the game tree. We used to run an informal competition at myinternet each year to see if someone could write a faster performing C program than a real world Perl application we had. Eg. FTP server, Memory cache, Database lookup, apache auth module ... In every single case, the perl application was shorter, faster to write, and executed faster. Now that said, technically, given unlimited time I am sure the C program could have been technically made to be faster - but it is just not a real world example, and the code ended up being larger, harder to maintain .... You can always optimise a case for a language though. Some places there is just no argument. E.g. I would not like to write Perl for embedded CPUs. But I would not like to write C for web applications. But that is also my own personal bent. I don't have any personal experience with Go, but my understanding is that it is very good at applications which work well as automatic threaded. I have been reading performance testing across DB recently - specifically RDBMS vs SimpleDB - and all the performance testing is based on either very large tables (where SimpleDB slows down) or time for a query. None do the real testing I want which is to run 100 servers, each with at least a dozen concurrent instances all doing different requests. Scott From kim at hawtin.net.au Thu Nov 11 15:32:05 2010 From: kim at hawtin.net.au (Kim Hawtin) Date: Fri, 12 Nov 2010 10:02:05 +1030 Subject: [Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest) In-Reply-To: <20101111115551.GA10472@opal.ai.ki> References: <20101111115551.GA10472@opal.ai.ki> Message-ID: <4CDC7CF5.4080207@hawtin.net.au> Sam Watkins wrote: > You definitely would need to use an algorithm that makes the most of its time, > because the more it thinks the more chance to find the best move, unless the > game is trivial. Part of my 'strategy' has been to spread the computation across several turns. does it work ... sort of. > I'm not sure how the top bot could be a Lisp bot - perhaps that Lisp hacker is > very very clever! or perhaps they are using a very neato fast Lisp compiler. It is; SCBL. An old one, but none the less, probably the fastest free compiler. > I suppose to win, you'd need to do game analysis like a chess-playing program: > - tree search, mini-max pruning, etc, and throw in some good heuristics! Certainly treat it like an eigan vector/value pair and fiddle with the coefficients and use a number of working sets. Thats where I'm headed. The main issues that my strategy fails down on at the moment, is a more openly spaced map or where there is few larger growth planets near the home planet. So part of the first turn is to pick a set of coefficients that work in that context... And no, I haven't updated my bot on the site in some time =/ cheers, Kim From jarich at perltraining.com.au Thu Nov 11 16:05:57 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Fri, 12 Nov 2010 11:05:57 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> Message-ID: <4CDC84E5.6020609@perltraining.com.au> Alfie John wrote: > Be careful to think that this is absolutely true. Perl's arrays are not > C arrays. If your index is greater than the number of elements in the > array, then the array will be extended i.e. the array element pointers > will be copied into a new array which can hold just one more element. > This will happen *each time* you extend the size of an array i.e. push()! This is not completely correct. When you create an array in Perl, Perl creates a hunk of memory for it and puts the array in the middle. If you unshift or push things onto the array they bring the start or end of the array closer to the boundaries of the memory Perl put aside for you. If you get "too close" to either end, then Perl allocates twice as much space for you (as it did the first time) and copies your array into the middle of that. You can then add to the start or end of the array at will until you again get "too close" to one of the ends; wherein Perl gives you more space again. So it is just as cheap to unshift onto your array as to push; and the majority of additions to your array do not require Perl to do a full array copy. J From sam at nipl.net Thu Nov 11 18:06:57 2010 From: sam at nipl.net (Sam Watkins) Date: Fri, 12 Nov 2010 13:06:57 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: <4CDC84E5.6020609@perltraining.com.au> References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> <4CDC84E5.6020609@perltraining.com.au> Message-ID: <20101112020657.GC18505@opal.ai.ki> On Fri, Nov 12, 2010 at 11:05:57AM +1100, Jacinta Richardson wrote: > When you create an array in Perl, Perl creates a hunk of memory for it and > puts the array in the middle. If you unshift or push things onto the array > they bring the start or end of the array closer to the boundaries of the > memory Perl put aside for you. If you get "too close" to either end, then > Perl allocates twice as much space for you (as it did the first time) and > copies your array into the middle of that. That's interesting, I didn't know it worked like that. I use a similar method to grow vectors in C, but only at the 'push' end. To 'unshift' I use it as a circular buffer, using the empty space from both ends. This makes indexing a little more complex, but it's a bit more efficient with the space / reallocations. Once done growing it, I can 'squeeze' the vector / deque to free up any wasted space. The circular buffer code is useful in other cases, e.g. to implement a queue. With the perl method as you described it, perl would have to reallocate the array (or memmove its elements) while using it as queue, even if the total size of the queue was not increasing. I was thinking a bit about how to create a data structure that would be very efficient for insertions / deletions at any point, and also for random access. Maybe a hybrid tree of arrays (or tree of deques), where the user could balance insert performance against compactness and random-access speed, and call a 'squeeze' or 'flatten' function to squash it into a simple array / deque. This could be useful. It sounds a bit complex, but I guess could be implemented fairly simply. Sam From daniel at rimspace.net Thu Nov 11 18:32:05 2010 From: daniel at rimspace.net (Daniel Pittman) Date: Fri, 12 Nov 2010 13:32:05 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: <20101112020657.GC18505@opal.ai.ki> (Sam Watkins's message of "Fri, 12 Nov 2010 13:06:57 +1100") References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> <4CDC84E5.6020609@perltraining.com.au> <20101112020657.GC18505@opal.ai.ki> Message-ID: Sam Watkins writes: > On Fri, Nov 12, 2010 at 11:05:57AM +1100, Jacinta Richardson wrote: > >> When you create an array in Perl, Perl creates a hunk of memory for it and >> puts the array in the middle. If you unshift or push things onto the array >> they bring the start or end of the array closer to the boundaries of the >> memory Perl put aside for you. If you get "too close" to either end, then >> Perl allocates twice as much space for you (as it did the first time) and >> copies your array into the middle of that. > > That's interesting, I didn't know it worked like that. Almost as if the authors of Perl have the freedom to make their implementations extremely efficient because they have a well defined API surrounding the internals, like well architected software. :) [...] > I was thinking a bit about how to create a data structure that would be very > efficient for insertions / deletions at any point, and also for random > access. You almost certainly want the trie-based concurrent and immutable data structures used extensively in Clojure, among other places. > Maybe a hybrid tree of arrays (or tree of deques), where the user could > balance insert performance against compactness and random-access speed, and > call a 'squeeze' or 'flatten' function to squash it into a simple array / > deque. This could be useful. It sounds a bit complex, but I guess could be > implemented fairly simply. Relatively, yes. They can serve as the basis for purely functional, efficiently shared map and sequence data storage, with reasonably predictable and controlled access times and patterns. (Fairly flat, too, so you don't have particularly many spikes in the worst-case time.) Daniel -- ? Daniel Pittman ? daniel at rimspace.net ? +61 401 155 707 ? made with 100 percent post-consumer electrons From melbournepm at ashish.neomailbox.com Thu Nov 11 18:43:13 2010 From: melbournepm at ashish.neomailbox.com (Ashish Gulhati) Date: Fri, 12 Nov 2010 13:43:13 +1100 Subject: [Melbourne-pm] Intro Message-ID: <9236F3C5-8ECB-4EF2-9E99-8479A3F71443@ashish.neomailbox.com> Hi all I'm a new member of Melbourne.pm - moved to Melbourne from India last year. Was great to see some of you on Wednesday at the meet. Sorry I didn't think to introduce myself then. I've been coding perl since perl 4 days... was one of the first (maybe the first?) perl hackers in India. In fact I was commissioned to write the Manning OO Perl book before Damian... Good thing I got distracted and didn't finish it :-) I've released a few modules on CPAN, including Crypt::GPG, Crypt::Schnorr::AuthSign and a couple others. Haven't had the chance to do much coding for the last few years but hope to finally get back into it now. Happy hacking... Hash From list at bereft.net Thu Nov 11 19:21:42 2010 From: list at bereft.net (Brad Bowman) Date: Fri, 12 Nov 2010 14:21:42 +1100 Subject: [Melbourne-pm] Intro In-Reply-To: <9236F3C5-8ECB-4EF2-9E99-8479A3F71443@ashish.neomailbox.com> References: <9236F3C5-8ECB-4EF2-9E99-8479A3F71443@ashish.neomailbox.com> Message-ID: <4CDCB2C6.9070507@bereft.net> Ashish Gulhati wrote: > I've released a few modules on CPAN, including Crypt::GPG, > Crypt::Schnorr::AuthSign and a couple others. Haven't had the chance to do > much coding for the last few years but hope to finally get back into it > now. This rang a bell and I checked my copy of Beautiful Code... You didn't get distracted writing Chapter 11. "Hacking in the Himalayas" sounded quite nice. I hope Melbourne competes with that idyllic life-style. Welcome, Brad Bowman From melbournepm at ashish.neomailbox.com Thu Nov 11 22:43:35 2010 From: melbournepm at ashish.neomailbox.com (Ashish Gulhati) Date: Fri, 12 Nov 2010 17:43:35 +1100 Subject: [Melbourne-pm] Intro In-Reply-To: <4CDCB2C6.9070507@bereft.net> References: <9236F3C5-8ECB-4EF2-9E99-8479A3F71443@ashish.neomailbox.com> <4CDCB2C6.9070507@bereft.net> Message-ID: Brad Bowman wrote: > "Hacking in the Himalayas" sounded quite nice. I hope Melbourne > competes with that idyllic life-style. > > Welcome, Thanks Brad Yep, living up there was really interesting for a while, but of course Melbourne definitely outcompetes the Himalayan village lifestyle in most ways (for me, anyway). Totally loving it here... Cheers #! From alfiejohn at gmail.com Fri Nov 12 02:29:08 2010 From: alfiejohn at gmail.com (Alfie John) Date: Fri, 12 Nov 2010 21:29:08 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: <4CDC84E5.6020609@perltraining.com.au> References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> <4CDC84E5.6020609@perltraining.com.au> Message-ID: On Fri, Nov 12, 2010 at 11:05 AM, Jacinta Richardson < jarich at perltraining.com.au> wrote: > Alfie John wrote: > > Be careful to think that this is absolutely true. Perl's arrays are not C >> arrays. If your index is greater than the number of elements in the array, >> then the array will be extended i.e. the array element pointers will be >> copied into a new array which can hold just one more element. This will >> happen *each time* you extend the size of an array i.e. push()! >> > > This is not completely correct. When you create an array in Perl, Perl > creates a hunk of memory for it and puts the array in the middle. If you > unshift or push things onto the array they bring the start or end of the > array closer to the boundaries of the memory Perl put aside for you. If you > get "too close" to either end, then Perl allocates twice as much space for > you (as it did the first time) and copies your array into the middle of > that. You can then add to the start or end of the array at will until you > again get "too close" to one of the ends; wherein Perl gives you more space > again. > I remember years ago someone saying something along the lines that unshift() was more expensive than push() so at the time I had a cursory look at how Perl implemented arrays. My explanation above was how I understood the code at the time. Looking again tonight I can see that I was wrong! Sorry Daniel and thanks Jacinta for picking that up :) Alfie -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfiejohn at gmail.com Fri Nov 12 02:33:39 2010 From: alfiejohn at gmail.com (Alfie John) Date: Fri, 12 Nov 2010 21:33:39 +1100 Subject: [Melbourne-pm] Intro In-Reply-To: References: <9236F3C5-8ECB-4EF2-9E99-8479A3F71443@ashish.neomailbox.com> <4CDCB2C6.9070507@bereft.net> Message-ID: Welcome Ashish! In case you're interested and haven't yet heard, OSDC ( http://2010.osdc.com.au/) and Ruxcon (http://www.ruxcon.org.au/) are happening in Melbourne this month. All in the same week too :) Alfie On Fri, Nov 12, 2010 at 5:43 PM, Ashish Gulhati < melbournepm at ashish.neomailbox.com> wrote: > Brad Bowman wrote: > > > "Hacking in the Himalayas" sounded quite nice. I hope Melbourne > > competes with that idyllic life-style. > > > > Welcome, > > Thanks Brad > > Yep, living up there was really interesting for a while, but of course > Melbourne > definitely outcompetes the Himalayan village lifestyle in most ways (for > me, anyway). > Totally loving it here... > > Cheers > > #! > > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsk_gr at hotmail.com Fri Nov 12 04:20:19 2010 From: dsk_gr at hotmail.com (Kostas Avlonitis) Date: Fri, 12 Nov 2010 23:20:19 +1100 Subject: [Melbourne-pm] Intro In-Reply-To: References: <9236F3C5-8ECB-4EF2-9E99-8479A3F71443@ashish.neomailbox.com> <4CDCB2C6.9070507@bereft.net> Message-ID: <4CDD3103.5070301@hotmail.com> Welcome Ashish, Just adding to Alfie's list http://yowaustralia.com.au/melbourne/index.html workshops starting the week after OSDC. K. On 12/11/2010 9:33 PM, Alfie John wrote: > Welcome Ashish! > > In case you're interested and haven't yet heard, OSDC > (http://2010.osdc.com.au/) and Ruxcon (http://www.ruxcon.org.au/) are > happening in Melbourne this month. All in the same week too :) > > Alfie > > On Fri, Nov 12, 2010 at 5:43 PM, Ashish Gulhati > > wrote: > > Brad Bowman wrote: > > > "Hacking in the Himalayas" sounded quite nice. I hope Melbourne > > competes with that idyllic life-style. > > > > Welcome, > > Thanks Brad > > Yep, living up there was really interesting for a while, but of > course Melbourne > definitely outcompetes the Himalayan village lifestyle in most ways > (for me, anyway). > Totally loving it here... > > Cheers > > #! > > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > > > > > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm From jarich at perltraining.com.au Sat Nov 13 22:56:11 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Sun, 14 Nov 2010 17:56:11 +1100 Subject: [Melbourne-pm] Timer::HiRes and alarms? In-Reply-To: <20101112020657.GC18505@opal.ai.ki> References: <4CDB7442.9030207@strategicdata.com.au> <4CDB7769.7050506@hawtin.net.au> <4CDB7C6A.2050701@strategicdata.com.au> <4CDB86BA.4030600@strategicdata.com.au> <4CDC84E5.6020609@perltraining.com.au> <20101112020657.GC18505@opal.ai.ki> Message-ID: <4CDF880B.4040904@perltraining.com.au> Sam Watkins wrote: > With the perl method as you described it, perl would have to reallocate the > array (or memmove its elements) while using it as queue, even if the total size > of the queue was not increasing. This is true, and I admit that my answer was only almost correct. Queues are a very common data structure, and as you said, they would have a tendency to creep forward if what I said was completely correct. Instead Perl's arrays are slightly biased towards queues and a preference to using C; thus while I said the start and end indexes are set to the middle of the allocated memory, technically they're actually a bit closer to the start of the allocated memory. An array grown exclusively with unshift will require more reallocations than one exclusively with push, and the difference results in the former being something like 5-10% slower than the later, (I've seen different benchmark results, but haven't tested it myself). Since memory reallocations are rare compared to most of the other things you'll have going on in your program, it's safe to trust that arrays just grow magically without almost any cost at all. J From jdthornton at ozemail.com.au Sun Nov 14 18:04:43 2010 From: jdthornton at ozemail.com.au (john thornton) Date: Mon, 15 Nov 2010 13:04:43 +1100 Subject: [Melbourne-pm] programming tutorials: Perl In-Reply-To: References: Message-ID: <4CE0953B.7070605@ozemail.com.au> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello As a beginner/tyro/novice at programming I would like to ask people on this list to do something for me. Could someone please look at the following site and tell me what they think of its introductory perl tutorials?" http://showmedo.com/ You go to the perl tutorials through the top choices. They are not long. These tutorials [perl and a gazillion other things] are free with one or two exceptions. I have worked through "introduction to perl" and "hello world" and have learnt quite a few things. I quite liked that he uses Linux and the Vi editor - I had never worked Vi out before. I use Fedora 14 in VMware to follow the tutorials. Thank you Andrew -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJM4JU7AAoJEHBYxueRMf9HIKoH/AkCFirvhQuyEHRT3px6vQGE KxZbfvzqWXctg7I6OLMi4nzfqalB9jP+18AtO0z6AXI/4/UQ/H83D/vwWPOcZEei sl6zLfdTmozwaxvwq7sspB0NUafyc1BK45l8Y0EhpK1+gSIkHoFoYfwl4aOkXQlD m2Rm/kHqmHAzyJo3ph8iBPC+8iA7Q3tn0GLqQxK5Z/U9lWzIITvdppcah4NDXYwi 7iC+ku2Id8Pqur1kQDzifgK4fIbAyX4wYWQo8RnC/f6XTKSAE37PcvSyxSlFj2F6 bFI2C6sE8xL6P0IqLcxmI5rwAPfIXjSti81YA1wjs3Ht2yFHdqMYINNcBJW/PJQ= =6Phc -----END PGP SIGNATURE----- From sam at nipl.net Sun Nov 14 18:30:42 2010 From: sam at nipl.net (Sam Watkins) Date: Mon, 15 Nov 2010 13:30:42 +1100 Subject: [Melbourne-pm] programming tutorials: Perl In-Reply-To: <4CE0953B.7070605@ozemail.com.au> References: <4CE0953B.7070605@ozemail.com.au> Message-ID: <20101115023042.GA27578@opal.ai.ki> On Mon, Nov 15, 2010 at 01:04:43PM +1100, john thornton wrote: > As a beginner/tyro/novice at programming I would like to ask people on this > list to do something for me. Could someone please look at the following site > and tell me what they think of its introductory perl tutorials?" > > http://showmedo.com/ hi Andrew, I'm not sure about showmedo, they may be okay for an introduction. I'd like to recommend the following 'course notes' for learning perl: http://perltraining.com.au/notes.html written by our very own Melbourne perl experts / trainers Paul and Jacinta (and friends), you may find them on this list! Also, please consider learning the basics of a few similar languages such as python, ruby, php and lua. This way, you will be able to find which languages suit you best or are to your taste. You will also see that these languages have very much in common, and that it's pretty easy to pick up a new programming language once you have one under your belt. I like the syntax and 'cleanness' of python, and I like the richness and the community of perl. I also like the speed of C! So I use and learn from several languages, while hacking together my own! Good luck! and don't be shy to ask questions here. Sam From alecclews at gmail.com Sun Nov 14 18:40:18 2010 From: alecclews at gmail.com (Alec Clews) Date: Mon, 15 Nov 2010 13:40:18 +1100 Subject: [Melbourne-pm] programming tutorials: Perl In-Reply-To: <4CE0953B.7070605@ozemail.com.au> References: <4CE0953B.7070605@ozemail.com.au> Message-ID: <1289788818.2215.30.camel@k13> On Mon, 2010-11-15 at 13:04 +1100, john thornton wrote: > As a beginner/tyro/novice at programming I would like > to ask people on this list to do something for me. Could someone please > look at the following site and tell me what they think of its > introductory perl tutorials?" > > http://showmedo.com/ > You may be better off with some of the resources listed at http://perl.net.au/wiki/Learning_Perl The showmedo didn't enthuse me -- but that's just me... -- Alec Clews Personal Melbourne, Australia. Jabber: alecclews at jabber.org.au PGPKey ID: 0x9BBBFC7C Blog http://alecthegeek.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From jarich at perltraining.com.au Sun Nov 14 21:11:10 2010 From: jarich at perltraining.com.au (jarich at perltraining.com.au) Date: Mon, 15 Nov 2010 16:11:10 +1100 (EST) Subject: [Melbourne-pm] OSDC Call for volunteers (free conference entry) Message-ID: <20101115051110.50A16A8B3C@teddybear.perltraining.com.au> Still hankering to go to OSDC this year? Here's an opportunity for some of you to get in for no charge! We're looking for volunteers to cover the registration desk, provide room monitor duties, operate the audio and video equipment and generally help with the smooth running of the event. If you're interested, please contact conference at osdc.com.au or fill out the form at http://2010.osdc.com.au/contact. Those interested in the audio/video side of things must be available Tuesday afternoon (23rd Nov) for training and then Wednesday 24th to Friday 26th from 8.30am to 5.30pm. While no experience is required for any volunteer tasks, including audio/video, you must be keen. We will try and schedule you all so you get to see what you want to, but cannot make any promises. In exchange for your help, you will get free access to the conference (no dinner unfortunately, but you can upgrade for $80 if you want to attend that too). We look forward to hearing from you, From jdthornton at ozemail.com.au Sun Nov 14 21:48:41 2010 From: jdthornton at ozemail.com.au (john thornton) Date: Mon, 15 Nov 2010 16:48:41 +1100 Subject: [Melbourne-pm] programming tutorials: Perl In-Reply-To: <20101115023042.GA27578@opal.ai.ki> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> Message-ID: <4CE0C9B9.7000603@ozemail.com.au> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks very much for that. I went to the site and downloaded the perl training book. Perldocs...so many. The only part that confuses me is that if # is a comment then why does the shebang line have any influence: #!/usr/bin/perl or as a variant to show warnings for code #!/usr/bin/perl -w I am using to using # to "comment out" configuration files in Linux for setting up mysql and so on. If I had to sum up my broad intent in learning to program it is to learn about web and database programming. I am interested in both. It also complements my other studies [maths in the past and graphics layout now] . I can already see at this stage that Perl fits into both. I remembered for the first time in that sentence that Perl is by convention capitalised for the language, according to the training book by the programmers on this list, and that perl as an interpreter has a lower case. So there you go! I learnt something. I am studying a mixture of python, php/sql and .NET through O'Reilly Media. I could have done Perl but didn't; they just released a Perl course. If I had to pick out one thing that not just "interests me" but more than that, just fascinates me, it is databases. Before I started these courses I thought that they were pretty dry. But getting into the book by C.J.Date where he talks about why they work and in what ways, that blows me away. Out of all database theory I would not right now know 0..001% of it - there is so much of it! Perhaps it is the dynamism of searches and storages that grabs me. I guess that for "labophobics" like me who dropped science at year 10 because the lab looked like something from outer space, there has to be sort of "dynamic" analogue or substitute. If you are not going to get a job at CERN then maybe a database is an OK substitute! I wish that I had into all this earlier. But I don't know how anyone in the pre-internet world got into computing. The system did me no favours either, such as the VCE smart alecs taking Pascal out of the maths textbook. That shocked me. I found an old maths A/B book in a hop shop and there were Pascal commands in the back. I said one that I found it hard to enjoy Perl. But I think that was from a bad tutorial. I don't give up on any language easily. Except maybe bash with its 0 and 1 the wrong way around for truth tables. Thanks again Andrew On 15/11/2010 1:30 PM, Sam Watkins wrote: > On Mon, Nov 15, 2010 at 01:04:43PM +1100, john thornton wrote: >> As a beginner/tyro/novice at programming I would like to ask people >> on this list to do something for me. Could someone please look at >> the following site and tell me what they think of its introductory >> perl tutorials?" >> >> http://showmedo.com/ > > hi Andrew, > > I'm not sure about showmedo, they may be okay for an introduction. > > I'd like to recommend the following 'course notes' for learning > perl: > > http://perltraining.com.au/notes.html > > written by our very own Melbourne perl experts / trainers Paul and > Jacinta (and friends), you may find them on this list! > > Also, please consider learning the basics of a few similar languages > such as python, ruby, php and lua. This way, you will be able to > find which languages suit you best or are to your taste. You will > also see that these languages have very much in common, and that it's > pretty easy to pick up a new programming language once you have one > under your belt. > > I like the syntax and 'cleanness' of python, and I like the richness > and the community of perl. I also like the speed of C! So I use and > learn from several languages, while hacking together my own! > > Good luck! and don't be shy to ask questions here. > > > Sam -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJM4Mm5AAoJEHBYxueRMf9HSeAH/R+mpYY/HtgTIKwXK+oQAkKi 124rqNzSZXU6TJgm6T8LWjgK5TXpeyIUoeK6zhYyxRmZBUlROpvEqOxV25ncT1zR /VGi7k7w4Y/EXBoeRyuUD0K2vCQjwLOxdZtxThuPsvaO7LQkvID61QK6fui4V8wO 3shrsiM4CDO6h7Wvo6f+sOV8QYDegcWADdKK2Kew7S007mUKAEiBvvjNU4AWbazt XKbzaTJpTpRZWQP7rCe7DNAdsB2TJiXbAGyFl8joOc+gPx+lzQmII1AQPmdDg69U QeW8KThm+weQGO7XZ5UV1HkXISPP7SNcvuCw5VXN+rXlEMqtbcaJwaQuiIOhpWU= =t7d0 -----END PGP SIGNATURE----- From leigh.sharpe at gmail.com Sun Nov 14 21:58:44 2010 From: leigh.sharpe at gmail.com (Leigh Sharpe) Date: Mon, 15 Nov 2010 16:58:44 +1100 Subject: [Melbourne-pm] programming tutorials: Perl In-Reply-To: <4CE0C9B9.7000603@ozemail.com.au> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> Message-ID: On Mon, Nov 15, 2010 at 4:48 PM, john thornton wrote: > The only part that confuses me is that if > > # is a comment > > then why does the shebang line have any influence: > > #!/usr/bin/perl > > or as a variant to show warnings for code > > #!/usr/bin/perl -w > > The shebang line is treated like a comment by the perl interpreter if invoked via perl yourscript.pl But not by the OS when ivoked via ./yourscript.pl On a linux system, when you invoke a script from the command line, your OS looks for a shebang line to see what interpreter it should use for your script. This could be perl (#!/usr/bin/perl) or bash (#!/bin/bash), or any of hundreds of others. The -w switch is passed to the interpreter in this case. The same applies for a CGI. Apache, for example, looks for a shebang line to see which interpreter should be invoked to run your CGI. It is also possible to write a CGI in bash and use #!/bin/bash as the shebang line. Or any other interpreter for that matter. The above doesn't apply to Windows, however. Hope this clears it up a bit. Leigh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel at rimspace.net Sun Nov 14 22:09:00 2010 From: daniel at rimspace.net (Daniel Pittman) Date: Mon, 15 Nov 2010 17:09:00 +1100 Subject: [Melbourne-pm] programming tutorials: Perl In-Reply-To: <4CE0C9B9.7000603@ozemail.com.au> (john thornton's message of "Mon, 15 Nov 2010 16:48:41 +1100") References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> Message-ID: john thornton writes: > Thanks very much for that. I went to the site and downloaded the perl > training book. Perldocs...so many. > > The only part that confuses me is that if > > # is a comment > > then why does the shebang line have any influence: > > #!/usr/bin/perl It has no influence on *Perl*. That magic incantation is a Unix feature, not a Perl feature[1]. Anyway, the particular bit of magic is: When Linux tries to run an executable that starts with that line, it reads out the content and transforms this: /path/to/example/with/shebang ...into this... /usr/bin/perl -w /path/to/example/with/shebang ...automatically. From a Perl point of view it then behaves exactly the way it would if you wrote that command out longhand. Regards, Daniel Footnotes: [1] ...although IIRC it has some magic on some platforms. Oh, well. -- ? Daniel Pittman ? daniel at rimspace.net ? +61 401 155 707 ? made with 100 percent post-consumer electrons From alecclews at gmail.com Sun Nov 14 22:09:33 2010 From: alecclews at gmail.com (Alec Clews) Date: Mon, 15 Nov 2010 17:09:33 +1100 Subject: [Melbourne-pm] The magic of shebang (was Re: programming tutorials: Perl) In-Reply-To: <4CE0C9B9.7000603@ozemail.com.au> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> Message-ID: <1289801373.2215.39.camel@k13> On Mon, 2010-11-15 at 16:48 +1100, john thornton wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Thanks very much for that. I went to the site and downloaded the perl > training book. Perldocs...so many. > > The only part that confuses me is that if > > # is a comment > > then why does the shebang line have any influence: > > #!/usr/bin/perl > > or as a variant to show warnings for code > > #!/usr/bin/perl -w > > I am using to using # to "comment out" configuration files in Linux > for setting up mysql and so on. the shebang notation (#!) is specific to UNIX (and hence Linux) The #! is actually interpreted by the kernel and tells it which interpreter to use (in this case Perl) Perl ignores the line[1] See also http://en.wikipedia.org/wiki/Shebang_(Unix) [1] That was a lie. As a special case Perl will look at the line and use any flags it sees. e.g. #!/bin/env perl -p will switch on the pseudo sed mode -- Alec Clews Personal Melbourne, Australia. Jabber: alecclews at jabber.org.au PGPKey ID: 0x9BBBFC7C Blog http://alecthegeek.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From alecclews at gmail.com Sun Nov 14 22:20:48 2010 From: alecclews at gmail.com (Alec Clews) Date: Mon, 15 Nov 2010 17:20:48 +1100 Subject: [Melbourne-pm] The magic of shebang (was Re: programming tutorials: Perl) In-Reply-To: <1289801373.2215.39.camel@k13> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> <1289801373.2215.39.camel@k13> Message-ID: <1289802048.2215.41.camel@k13> Sorry -- correction below On Mon, 2010-11-15 at 17:09 +1100, Alec Clews wrote: > On Mon, 2010-11-15 at 16:48 +1100, john thornton wrote: > > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > Thanks very much for that. I went to the site and downloaded the perl > > training book. Perldocs...so many. > > > > The only part that confuses me is that if > > > > # is a comment > > > > then why does the shebang line have any influence: > > > > #!/usr/bin/perl > > > > or as a variant to show warnings for code > > > > #!/usr/bin/perl -w > > > > I am using to using # to "comment out" configuration files in Linux > > for setting up mysql and so on. > > > the shebang notation (#!) is specific to UNIX (and hence Linux) > > The #! is actually interpreted by the kernel and tells it which > interpreter to use (in this case Perl) > > Perl ignores the line[1] > > See also http://en.wikipedia.org/wiki/Shebang_(Unix) > > > [1] That was a lie. As a special case Perl will look at the line and > use any flags it sees. e.g. > > #!/bin/env perl -p #! /usr/bin/env perl -p NB using this form of shebang is (supposedly) more portable, although I have had problems on some systems.... > > will switch on the pseudo sed mode > > > -- > Alec Clews > Personal Melbourne, Australia. > Jabber: alecclews at jabber.org.au PGPKey ID: 0x9BBBFC7C > Blog http://alecthegeek.wordpress.com/ > > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm -- Alec Clews Personal Melbourne, Australia. Jabber: alecclews at jabber.org.au PGPKey ID: 0x9BBBFC7C Blog http://alecthegeek.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From jdthornton at ozemail.com.au Sun Nov 14 22:22:10 2010 From: jdthornton at ozemail.com.au (john thornton) Date: Mon, 15 Nov 2010 17:22:10 +1100 Subject: [Melbourne-pm] The magic of shebang (was Re: programming tutorials: Perl) In-Reply-To: <1289801373.2215.39.camel@k13> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> <1289801373.2215.39.camel@k13> Message-ID: <4CE0D192.30505@ozemail.com.au> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks for that. A few things to try out in Linux [Fedora 14] or Windows with Strawberry Perl. Andrew -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJM4NGSAAoJEHBYxueRMf9Hp08H/3XBy5sr6KS67+60+g9j0XzG dPiYl77FhneisXdYwiuGMFtXezqCwv6Ganr1DArmMX1inPczbGjMvj6E4sPvTWrL YBh5QChlKHOqdrh40dNXzWdmgC4phGsGLNBMC+AiAaw6PBAWCSFRmBI1ukExpdD4 lCcEYTQ930Ysw4RHlj+Hi+O4MW7XfzOuByMzCLJlWlCgZL5gAYylvMXTKn/VxWTh rzcqdW5vA+LCfaX80V7GbQyeVYt1AuTL5Ta1AkRn1vheM57NwkDcLKsnr5z7gKo+ z7pJEowHjzjRogf1f/jO7gGQBgeq3UWV4WNxJ48Au+BG3jR33DoEPCklxMm4/YQ= =HMb2 -----END PGP SIGNATURE----- From jarich at perltraining.com.au Tue Nov 16 04:25:55 2010 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Tue, 16 Nov 2010 23:25:55 +1100 Subject: [Melbourne-pm] programming tutorials: Perl In-Reply-To: <4CE0C9B9.7000603@ozemail.com.au> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> Message-ID: <4CE27853.1010100@perltraining.com.au> john thornton wrote: > a bad tutorial. I don't give up on any language easily. Except maybe > bash with its 0 and 1 the wrong way around for truth tables. Even this does actually make sense if someone explains why. Consider the following problem: You are running a process. Two broad categories of things can happen: 1. runs to completion and finishes successfully 2. it fails to run to completion or finish successfully for some reason. In many ways, 1. is boring. Either it succeeds or it doesn't. True or false. However 2. is really interesting. Did it get to completion? If not, why not? Why didn't it succeed? If we flag success with 0, we can then leave open *all* of the positive integers as answers to what went wrong to cause the second situation. For example; grep returns 0 to say it ran to completion and found the thing you were looking for. It returns 1 to say it ran to completion but did not find the thing you were looking for, and 2 for all other situations (errors). Thus if you're running grep and you only care whether the string exists in the file, you check it against 0. On the other hand return values for mount are much more interesting: 0 success 1 incorrect invocation or permissions 2 system error (out of memory, cannot fork, no more loop devices) 4 internal mount bug or missing nfs support in mount 8 user interrupt 16 problems writing or locking /etc/mtab 32 mount failure 64 some mount succeeded So, as you can see, success = 0 is logical if you want to make it possible to signal further information with your exit values. Once you have this extra information you can write more robust scripts which can handle some possible errors rather than just giving up on failure because the reason for failure was unknown. All the best, J From wigs at stirfried.org Tue Nov 16 15:22:38 2010 From: wigs at stirfried.org (wigs at stirfried.org) Date: Wed, 17 Nov 2010 10:22:38 +1100 Subject: [Melbourne-pm] The magic of shebang (was Re: programming tutorials: Perl) In-Reply-To: <1289801373.2215.39.camel@k13> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> <1289801373.2215.39.camel@k13> Message-ID: <20101116232238.GA9373@stirfried.org> On Mon, Nov 15, 2010 at 05:09:33PM +1100, Alec Clews wrote: > [1] That was a lie. As a special case Perl will look at the line and use > any flags it sees. Just like English there are always exceptions to rules in Perl. There is at least one other special case where perl does not ignore lines starting with a '#'. Specifically, the '#line' pragma. This tells the perl compiler to reset the source-code line counter. For example: 01 #!/bin/env perl -p 02 use strict; 03 04 #line 1001 05 my $x = 2; 05 $m = 1; If you run that code an error will be reported in line 1002, and not line 5 as you would otherwise expect. -- Wigs From mathew.blair.robertson at gmail.com Tue Nov 16 15:34:48 2010 From: mathew.blair.robertson at gmail.com (Mathew Robertson) Date: Wed, 17 Nov 2010 10:34:48 +1100 Subject: [Melbourne-pm] The magic of shebang (was Re: programming tutorials: Perl) In-Reply-To: <20101116232238.GA9373@stirfried.org> References: <4CE0953B.7070605@ozemail.com.au> <20101115023042.GA27578@opal.ai.ki> <4CE0C9B9.7000603@ozemail.com.au> <1289801373.2215.39.camel@k13> <20101116232238.GA9373@stirfried.org> Message-ID: And just to be pedantic, dont forget $#var... eg: my @list; foreach (0..$#list) ... regards, Mathew Robertson On 17 November 2010 10:22, wrote: > On Mon, Nov 15, 2010 at 05:09:33PM +1100, Alec Clews wrote: > > [1] That was a lie. As a special case Perl will look at the line and use > > any flags it sees. > > Just like English there are always exceptions to rules in Perl. There is > at > least one other special case where perl does not ignore lines starting with > a > '#'. Specifically, the '#line' pragma. > > This tells the perl compiler to reset the source-code line counter. For > example: > > 01 #!/bin/env perl -p > 02 use strict; > 03 > 04 #line 1001 > 05 my $x = 2; > 05 $m = 1; > > If you run that code an error will be reported in line 1002, and not line 5 > as > you would otherwise expect. > > -- > Wigs > _______________________________________________ > Melbourne-pm mailing list > Melbourne-pm at pm.org > http://mail.pm.org/mailman/listinfo/melbourne-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From toby.corkindale at strategicdata.com.au Tue Nov 16 16:20:14 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 17 Nov 2010 11:20:14 +1100 Subject: [Melbourne-pm] OSDC Perl BOF Message-ID: <4CE31FBE.1090701@strategicdata.com.au> Hello everyone, I hope it's OK for me to cross-post this far and wide. There has been some discussion between the Adelaide and Melbourne perlmongers about having a Perl BoF meet during the OSDConference next week, and I'd like to extend that to other Perl mongers. The conference dinner is on Wednesday, and I gather some visitors will be flying home straight after the conference on Friday, so at this stage it looks like Thursday night is the night. I wondered, would visitors to Melbourne be interested in sticking close to the conference venue (eg. the "Boiler Bar") or striking out further into Melbourne (perhaps Collingwood or Fitzroy, or the CBD)? Cheers, Toby From toby.corkindale at strategicdata.com.au Tue Nov 16 16:53:07 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 17 Nov 2010 11:53:07 +1100 Subject: [Melbourne-pm] Melbourne Perl mongers' December meet - ideas? Message-ID: <4CE32773.3050705@strategicdata.com.au> Greetings Perl Mongers! The next Melbourne Perl Mongers meeting will be on December the 8th at 6:30pm. Since it will be December, I wondered if we'd like to do anything different for the "xmas meet"? Cheers, Toby From shlomif at iglu.org.il Thu Nov 18 04:43:26 2010 From: shlomif at iglu.org.il (Shlomi Fish) Date: Thu, 18 Nov 2010 14:43:26 +0200 Subject: [Melbourne-pm] http://perl.net.au/ is Being Heavily Spammed Message-ID: <201011181443.27187.shlomif@iglu.org.il> Hi all, http://perl.net.au/ is being heavily spammed at present. Someone needs to clean the spammed pages and add the spamming domains to the blacklist. I volunteer to do it, but I don't know exactly how. Can anyone provide any insight? Regards, Shlomi Fish (who spent some time cleaning up wiki spam from wikis he maintains). -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ List of Portability Libraries - http://shlom.in/port-libs She's a hot chick. But she smokes. She can smoke as long as she's smokin'. Please reply to list if it's a mailing list post - http://shlom.in/reply . From stephen at sydney.pm.org Thu Nov 18 05:05:49 2010 From: stephen at sydney.pm.org (Stephen Steneker) Date: Fri, 19 Nov 2010 00:05:49 +1100 Subject: [Melbourne-pm] http://perl.net.au/ is Being Heavily Spammed In-Reply-To: <201011181443.27187.shlomif@iglu.org.il> References: <201011181443.27187.shlomif@iglu.org.il> Message-ID: > http://perl.net.au/ is being heavily spammed at present. Someone needs to > clean the spammed pages and add the spamming domains to the blacklist. I > volunteer to do it, but I don't know exactly how. > > Can anyone provide any insight? Hi Shlomi, Thanks for reporting :) You could ping Paul or Jacinta on #Perlnet (irc) as they are the main custodians. I also have perms to rollback .. doing so now. The Perlnet wiki has gone unloved for a while. Was originally left relatively open and captcha-free to encourage contributions. Perhaps could be locked down a bit more to avoid given the spambots free googlejuice. Cheers, Stephen From kim at hawtin.net.au Tue Nov 23 17:04:05 2010 From: kim at hawtin.net.au (Kim Hawtin) Date: Wed, 24 Nov 2010 12:04:05 +1100 Subject: [Melbourne-pm] [adelaide.pm] OSDC Perl BOF In-Reply-To: <4CE31FBE.1090701@strategicdata.com.au> References: <4CE31FBE.1090701@strategicdata.com.au> Message-ID: <4CEC6485.5030307@hawtin.net.au> On 17/11/10 11:20, Toby Corkindale wrote: > Hello everyone, > I hope it's OK for me to cross-post this far and wide. > > There has been some discussion between the Adelaide and Melbourne > perlmongers about having a Perl BoF meet during the OSDConference next > week, and I'd like to extend that to other Perl mongers. > > The conference dinner is on Wednesday, and I gather some visitors will > be flying home straight after the conference on Friday, so at this stage > it looks like Thursday night is the night. > > I wondered, would visitors to Melbourne be interested in sticking close > to the conference venue (eg. the "Boiler Bar") or striking out further > into Melbourne (perhaps Collingwood or Fitzroy, or the CBD)? The boiler room is conveniently right next to the convent bakery as we found out last night. So there seem to be a number of eat streets about locally... thoughts? regards, Kim From tjc at wintrmute.net Tue Nov 23 17:16:48 2010 From: tjc at wintrmute.net (Toby Wintermute) Date: Wed, 24 Nov 2010 12:16:48 +1100 Subject: [Melbourne-pm] OSDC Perl BOF In-Reply-To: References: Message-ID: On 24 November 2010 12:04, Kim Hawtin wrote: > On 17/11/10 11:20, Toby Corkindale wrote: >> Hello everyone, >> I hope it's OK for me to cross-post this far and wide. ..and now to the OSDC Delegates list too. >> There has been some discussion between the Adelaide and Melbourne >> perlmongers about having a Perl BoF meet during the OSDConference next >> week, and I'd like to extend that to other Perl mongers. >> >> The conference dinner is on Wednesday, and I gather some visitors will >> be flying home straight after the conference on Friday, so at this stage >> it looks like Thursday night is the night. >> >> I wondered, would visitors to Melbourne be interested in sticking close >> to the conference venue (eg. the "Boiler Bar") or striking out further >> into Melbourne (perhaps Collingwood or Fitzroy, or the CBD)? > > The boiler room is conveniently right next to the convent bakery as we found > out last night. So there seem to be a number of eat streets about locally... > thoughts? Both the bakery and Lentil as Anything sound good to me, at least, and you have to admit they are convenient :) I haven't tried either myself. Do you think they will cope with a big crowd of Perlmongers and presumably other OSDC folk though? Looking forward to catching up with the interstate Perl mongers tomorrow evening, Toby -- Turning and turning in the widening gyre The falcon cannot hear the falconer Things fall apart; the center cannot hold Mere anarchy is loosed upon the world From Martin.G.Ryan at team.telstra.com Sun Nov 28 10:34:55 2010 From: Martin.G.Ryan at team.telstra.com (Ryan, Martin G) Date: Mon, 29 Nov 2010 05:34:55 +1100 Subject: [Melbourne-pm] Recall: AI Contest - Yeeah Haah !! Message-ID: <589EE331794E0B4DA62A9ADE89BCB4057DAC034638@WSMSG3103V.srv.dir.telstra.com> Ryan, Martin G would like to recall the message, "[Melbourne-pm] AI Contest - Yeeah Haah !!". From toby.corkindale at strategicdata.com.au Tue Nov 30 16:59:23 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 01 Dec 2010 11:59:23 +1100 Subject: [Melbourne-pm] Up to date and consistent CPAN mirror? Message-ID: <4CF59DEB.9090402@strategicdata.com.au> Hey guys, I'm using iiNet's CPAN mirror (ftp.iinet.net.au) as it's "free" bandwidth. However their mirroring seems broken; I'm apparently missing a module that was uploaded to CPAN a week ago, yet still getting other modules which were uploaded more recently and reference them. >.< As you can imagine, this is a pain. Maybe I've just hit a weird edge case, but I wondered what the collective wisdom in Victoria is for local CPAN mirrors? Cheers, Toby From Martin.G.Ryan at team.telstra.com Tue Nov 30 17:13:56 2010 From: Martin.G.Ryan at team.telstra.com (Ryan, Martin G) Date: Wed, 1 Dec 2010 12:13:56 +1100 Subject: [Melbourne-pm] Up to date and consistent CPAN mirror? In-Reply-To: <4CF59DEB.9090402@strategicdata.com.au> References: <4CF59DEB.9090402@strategicdata.com.au> Message-ID: <589EE331794E0B4DA62A9ADE89BCB4057DAC83A7E2@WSMSG3103V.srv.dir.telstra.com> > ... but I wondered what the collective wisdom in Victoria is for local CPAN mirrors? I note you preference for a free-bandwidth site, but I've always used mirror.aarnet.edu.au without trouble. Regards, Martin From toby.corkindale at strategicdata.com.au Tue Nov 30 20:10:50 2010 From: toby.corkindale at strategicdata.com.au (Toby Corkindale) Date: Wed, 01 Dec 2010 15:10:50 +1100 Subject: [Melbourne-pm] Up to date and consistent CPAN mirror? In-Reply-To: <4CF5A4CC.9020204@strategicdata.com.au> References: <4CF59DEB.9090402@strategicdata.com.au> <4CF5A4CC.9020204@strategicdata.com.au> Message-ID: <4CF5CACA.7070503@strategicdata.com.au> On 01/12/10 12:28, Andrew Pam wrote: > On 01/12/10 11:59, Toby Corkindale wrote: >> However their mirroring seems broken; I'm apparently missing a module >> that was uploaded to CPAN a week ago, yet still getting other modules >> which were uploaded more recently and reference them.>.< > > Occasionally I've noticed their Ubuntu repo has the same problem. And just now it gave me a few 500 Internal Server Errors, and has since started Refusing Connections altogether! >> As you can imagine, this is a pain. Maybe I've just hit a weird edge >> case, but I wondered what the collective wisdom in Victoria is for local >> CPAN mirrors? > > Here's what I use at the moment: > > 0 [ftp://mirror.internode.on.net/pub/cpan/] > 1 [http://cpan.mirror.aussiehq.net.au/] > 2 [ftp://mirror.as24220.net/cpan/] Thanks Andrew, -Toby