Older Contests
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP ContestsOlder Contests

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 23rd, 2004, 08:51 PM
ermau ermau is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 ermau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
[appleeaters]Library

I personally have a few issues with this library. I know the library used in the contest will be different, I hope it has a major speed up. This library is very slow, and written fairly poorly as far as speed goes, and considering that's a factor I am displeased.

I know that the startup wont penalize us, but the move function could be faster. For example, WHY in the world would it loop through all the robots multiple times? It's much faster to store the x,y coordinates as the key of the robots array, and then do simple isset()s on an array in ONE foreach, rather than having to loop multiple times. Especially why in the world would it report the closest robot when it doesn't even make that information available to the program, but just to output it?

The use of double quotes all over the place slows it down. As does using for loops rather than a while loop

php Code:
Original - php Code
  1.  
  2. $num = count($array);
  3. $i=-1;
  4. while (++$i<$num)
  5. {
  6. // insert code
  7. }

is much faster than:
php Code:
Original - php Code
  1.  
  2. for($i=0; $i<count($array); $i++)
  3. {
  4.  // insert code
  5. }

For multiple reasons, checking against a variable is much faster than running a function and checking against its returned value each loop. Preincrimenting is also faster than postincrimenting.

Also, count variables are made, but aren't even used in other places where they could be, and aren't made available.
Example:
php Code:
Original - php Code
  1.  
  2. $robotcount=mt_rand(1,round($width*$height/100));

A robot count is made, but not used where it could be, such as in the output right after that. In addition, it's not made available in the game array, so we can not use that information, and have to waste more time using a count, that can get costly with arrays of 10k units (which that limit is rediculous. I've had start times of 50 seconds by itself, even if move doesnt do all of what start does, thats probably only 20 seconds or so less... 30 seconds a move? Rediculous.)

Also, why use second variables? We have a memory limit, why create secondary variables ($height,$width) rather than using the variable itself, saving memory ($this->game['height']).

I really think the library should be reevaluated (possibly recoded), and redistributed and then a version of that be used for the competition. It's way too slow. Besides, as has been stated, there's an error with the distance formula in some cases anyways.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP ContestsOlder Contests > [appleeaters]Library


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway