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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #16  
Old July 14th, 2004, 07:07 PM
jcaughel jcaughel is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Buffalo, NY, USA
Posts: 283 jcaughel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 4 sec
Reputation Power: 2
Send a message via ICQ to jcaughel Send a message via AIM to jcaughel Send a message via Yahoo to jcaughel
[appleeaters]RE: How long?

I never got a chance to really delve into killing robots intentionally. It happens as a matter of course in this algorithm. Too much work, not enough play

http://jeff.caughel.net/robots.phps

-Jeff

Reply With Quote
  #17  
Old July 14th, 2004, 08:28 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
[appleeaters]RE: How long?

Great looking code!!

Reply With Quote
  #18  
Old July 15th, 2004, 04:44 PM
DDY DDY is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Rouen, 76, FRANCE
Posts: 25 DDY User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
[appleeaters]RE: How long?

my submit:
http://deaddy.no-ip.org/apples.phps

Reply With Quote
  #19  
Old July 16th, 2004, 10:18 PM
fidian fidian is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 45 fidian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[appleeaters]RE: How long?

I'll be posting my code online in the near future, but until then ...

I was wondering what people were using for an algorithm. Looking at lots of lines of code can sometimes make me go crazy unless I spend some serious time understanding it. For example, my algorithm:

Code:
mode = offense
while (1)
  if mode == offense
     offensive_move
  else
     defensive_move
loop

offensive_move:
divide area around robot into 16 segments (N, NNW, NW, WNW, W, etc.)
Find closest robot in each section
Find all apples that are between me and 1/2 distance to closest robot in that direction
From that apple, recursively search and see how many apples I can eat if I go that route.
If I found an apple that I can eat, move to apple
otherwise, defensive_move

defensive_move:
Determine closest robots, figure out "good" moves and how "good" they are (from 0 to 1)
Test each move
  add points for apples
  add points for robot collisions
  add points if I end up near a dead robot
move the best move

move: (can move a series of moves)
while (moves in series)
  if (too close to time limit*)
    suicide -- run to nearest robot
  else
    move to wherever.
loop


* the time limit is calculated thus:
60 sec - (last_move * distance)
last_move = time it took for last move plus a tiny amount to compensate for my code
distance = 1/2 the distance between bad robot and myself

I really like where I have the closest robots and I scan all apples to find any eatable apple. With that information, I can plot the best route to take ... but it didn't compensate for robots crasing into each other. Room for improvement.

When I get things ready, the web site will be http://rumkin.com/reference/php_contest/ with a link to the apple eating robot competition there.

Reply With Quote
  #20  
Old July 17th, 2004, 03:29 AM
jcaughel jcaughel is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Buffalo, NY, USA
Posts: 283 jcaughel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 4 sec
Reputation Power: 2
Send a message via ICQ to jcaughel Send a message via AIM to jcaughel Send a message via Yahoo to jcaughel
[appleeaters]RE: How long?

Well... mine was pretty straight forward.
find all live robots within M moves
in each of the 8 directions
find all apples within M/2 in each
of the directions, consider their
importance to be 1/D^2
find all dead robots within M/2 in
each direction, consider their
importance to be 1/D^2
if there are apples that can be reached,
go in the direction with the highest
score (sum of 1/D^2 for each apple)
else if there are dead robots that can
be reached,go in the direction with
the highest score (sum of 1/D^2 for
each dead robot) and try to stay
opposite the closest live robot
else move toward the nearest side toward
the point you just were at. (this
presumes that there will be lines of
robots horizontally or vertically at
that point x or y respectively.)


I wanted to be more agressive about killing robots... I just ran out of time to develop
the algroithm.

the 1/d^2 was arrived at empirically... for
those familiar with physics, I would appreciate
a detailed explanation of why that number works
better than others.

Thanks,

Jeff

Reply With Quote
  #21  
Old July 17th, 2004, 12:35 PM
daremon daremon is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 19 daremon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
[appleeaters]RE: How long?

Nice idea to describe our algorithms! Much easier than trying to understand code ;-) Here is mine:

I used a standard (?) AI algorithm, breadth first search of the game tree:

I use a 40x40 box around me. Anything outside that, is not taken into account.

I created an EvaluateBoard() function which gives an evaluation of how good things look in the current board. This function, takes the current 40x40 box, the starting number of apples and the starting number of live robots. It uses weights to give back the evaluation. 4 things are considered:
Total number of eaten apples (large is good)
Total number of killed robots (large is good)
Median distance from apples (small is good)
Median distance from robots (large is good)

I also have one (recursive) function that evaluates all available moves (1 to 9) then simulates robotslib for these moves and evaluates all new moves (1 to 9) then simulates robotslib for these moves and evaluates all new moves (1 to 9)...etc...you get the point...
In other words it plays ALL moves, then does the work of robotslib to get the new board and plays again ALL moves etc. I do this for a depth of 2 because larger depths need LOTS of time.

To find good weights for EvaluateBoard, i created a small test script that changed weights, played 30 games and recorded scores.

drm

Reply With Quote
  #22  
Old July 19th, 2004, 02:58 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
[appleeaters]RE: How long?

I tried a couple of different things.
Stuff I tried that just took way too long.
k-means clustering to find the best cluster of apples to go for.
alpha-beta search on the possible moves. Worked ok for a depth of 2-3 but higher than that was very painful to wait on.
evaluating all robots, apples on every move.

What seemed to work for me
Setup a move function that would try all valid moves and score the resulting game state.
I upped the score on a move for things like, moving in the direction of an apple I could actually reach. Killing the closest robot. Moving toward a dead robot. Moving toward the average point for robots on the same lines, and staying on the otherside of a deadrobot, and the closest live robot. Also added points for standing still.
Took the highest score and used that, otherwise teleported if the score was negative.
If there were no more teleports, then I made the move that would give me the most points, usually running into some robot.
I looked at a box around my guy and evaluated off of that to save time.

--Adam
Code at http://www.joannstevenson.com/robots/mine.phps

Reply With Quote
  #23  
Old July 19th, 2004, 07:57 PM
merdball merdball is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Phoenix, OR USA
Posts: 8 merdball User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
[appleeaters]RE: How long?

My original algorithm ended up being my last due to running out of time. Basically I had a recursive apple-searcher. It would find a path of a certain predefined depth that got the most apples in a row. Worked great for maps with too few robots, but with a depth greater than 3 apples, it just died... it was very depressing because it could have been better if I hadn't screwed up later on in trying to kill robots. The script I submitted doesn't even consider killing robots. In the end the old things I tweaked were some basic numbers for size of search and depth. For a map with lots of apples and few robots, it looked further away from player for viable apples. Not terribly useful, but it helped a bit.

My idea I worked on for like a week was to try and kill robots by using a dead robot. I ended up with an algorithm that first did a search for apples (as above), then if it couldn't find any it would simulate movements via a fake robotslib. It went two moves in the future, determined how many robots were killed in the best case, and chose that. If it ever found a dead robot within reach, it made a run for it and waited there until it was no longer safe.

I spent so much time on this algorithm that I didn't have time to do anything else once I found its huge flaw. For starters, just killing robots wasn't that good for determining a "best move". You guys had better ideas there - giving weights to getting nearer apples and whatnot. But my main mistake was thinking a dead robot would really be that useful. On maybe 1/10 the maps I messed with could I even get to a dead robot, and every time I did, I was able to get only a few kills before I got surrounded too badly and had to abandon it.

I will not win. But I did learn a bit.

Reply With Quote
  #24  
Old July 20th, 2004, 11:48 AM
mt1955 mt1955 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 15 mt1955 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
[appleeaters]RE: How long?

it is easier for me to describe an algorithm by pointing to the code than using words but it might be fun to give it a go...

- initialization
- for each possible move
- if the move is safe and in-bounds consider it
- if an apple is found there commit to that move
- if I didn't find any safe moves, then teleport if I can and there is adequate time remaining or move wherever it causes the most live robots to collide
- else for each safe move see if I can walk safely to any apples within a 17 move diagonal
- if I find more than one safe apple path choose the path that leads toward the most apples
- if I don't find any safe apple paths then select the move that causes the most live robots to collide
- if I don't find any moves that cause collisions then select the move that takes me away from robots or edges and toward the most apples
- after each the move check to see if I am running out of time and if so quit checking for apples/collisions and walk toward the nearest live robot.

... I think that's it.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP ContestsOlder Contests > [appleeaters]How long?


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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