[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4586: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4588: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4589: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4590: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
AI Challenge Forums • View topic - BFS leading to timeout ? python

It is currently Mon Jun 18, 2018 12:11 am Advanced search

BFS leading to timeout ? python

Topics about starter packages, visualizer or any other third party tools.
Please submit new language requests in the Language Request Forum.

BFS leading to timeout ? python

Postby adrian » Thu Oct 27, 2011 6:06 am

I'm attempting to implement a bfs, it seems to work up until turn 6, then it time outs, but I can't figure out why

I get this put from the console:
turn 0 stats: [1,1,0] 0 [1,1] - 18 0 None [1,1] [1,1] [1,1] 0 None
turn 1 bot 0 invalid actions:
start # unknown action
end # unknown action
turn 1 stats: [1,1,0] 0 [1,1] - 16 1 [0,0] [1,1] [1,1] [1,1] 1 [0,1]
...
turn 5 bot 0 invalid actions:
start # unknown action
end # unknown action
turn 5 stats: [4,4,0] 0 [1,1] - 12 1 [0,0] [1,1] [1,1] [1,1] 1 [0,1]
turn 6 bot 0 timed out
turn 6 stats: [4,4,0] 0 [0,1] - 12 1 [0,0] [0,1] [1,1] [1,1] 1 [0,1]

I get start and end messages up until round 6, and the start and end messages are the first and last line of the mybot's do turn method. What I don't understand is how the bfs could timeout the bot if the bot does not even execute the first line of its do_turn method, I would think that that means that the bfs is never run.

also I'm running this using the command given in tutorial.sh

my BFS:
def distance(self, loc1, loc2):
'calculate the closest distance between to locations'
fringe = util.Queue()
startState = (loc1)

fringe.push((startState, 0))
explored = set([])

nextNode = None
while True :
if fringe.isEmpty() :
return 'failure'
nextNode = fringe.pop()
if not nextNode[0] in explored :
explored.add(nextNode[0])
nextPositions = self.getOpenLocations(nextNode[0])
for nextPosition in nextPositions :
if nextNode[0] == loc2 :
return nextNode[1]
fringe.push( ( nextPosition, nextNode[1] + 1 ))
[/color]
def getOpenLocations(self, loc):
openLocations = []
openLocations.append(self.destination(loc, 'n') )
openLocations.append(self.destination(loc, 'e') )
openLocations.append(self.destination(loc, 's') )
openLocations.append(self.destination(loc, 'w') )
adrian
Cadet
 
Posts: 4
Joined: Thu Oct 27, 2011 5:58 am

Re: BFS leading to timeout ? python

Postby Janzert » Thu Oct 27, 2011 11:41 pm

Make sure you're doing a flush after printing your debug output. Without that it could be that it is getting printed but you're just not seeing it.
Janzert
Contest Organizer
 
Posts: 271
Joined: Sun Feb 07, 2010 1:59 am

Re: BFS leading to timeout ? python

Postby adrian » Fri Oct 28, 2011 7:21 am

So you saying that it is really timing out at turn 5, and somehow still printing end?

Also how do you flush?

Thanks for the help
adrian
Cadet
 
Posts: 4
Joined: Thu Oct 27, 2011 5:58 am

Re: BFS leading to timeout ? python

Postby tmc » Fri Oct 28, 2011 10:26 am

tmc
Brigadier-General
 
Posts: 101
Joined: Fri Oct 28, 2011 8:42 am

Re: BFS leading to timeout ? python

Postby jlgrall » Fri Oct 28, 2011 11:16 am

Well, I would say that flushing is even more needed if it's buffered. You don't want your "go" to stay in the buffer waiting for more text to be send, you want it to be sent right now, before turn time limit arrives !!! :)
jlgrall
Lieutenant-Colonel
 
Posts: 41
Joined: Sun Oct 23, 2011 11:26 am

Re: BFS leading to timeout ? python

Postby tmc » Fri Oct 28, 2011 12:01 pm

The starter package ants.py flushes after every order and after "go". Otherwise every bot would time out.

adrian: No, the timeout is surely during turn 6.
tmc
Brigadier-General
 
Posts: 101
Joined: Fri Oct 28, 2011 8:42 am

Re: BFS leading to timeout ? python

Postby adrian » Sat Oct 29, 2011 8:38 am

Ok if it is during turn 6, how is my distance method timing my bot out, if the first line of do_turn is never executed. Or do print statements only get printed after the whole turn is completed?
adrian
Cadet
 
Posts: 4
Joined: Thu Oct 27, 2011 5:58 am

Re: BFS leading to timeout ? python

Postby adrian » Sat Oct 29, 2011 9:03 am

I looked into this more, and I know see that if the bot times out during a turn, nothing is printed during that turn. Is there some way that we can print stuff, so that we can debug. Its hard to tell why things don't work without some way to see whats going on.
adrian
Cadet
 
Posts: 4
Joined: Thu Oct 27, 2011 5:58 am

Re: BFS leading to timeout ? python

Postby Parasprites » Sat Oct 29, 2011 1:53 pm

You can modify engine.py to print out the bots output immediately.
Parasprites
Major-General
 
Posts: 224
Joined: Mon Oct 24, 2011 3:08 pm

Re: BFS leading to timeout ? python

Postby rio.ant » Thu Dec 01, 2011 2:09 am

rio.ant
Captain
 
Posts: 20
Joined: Fri Nov 11, 2011 4:54 am

Next

Return to Starter Packages & Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron