[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 - Improved Python + NumPy starter package

It is currently Thu Oct 18, 2018 1:46 am Advanced search

Improved Python + NumPy starter package

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

Improved Python + NumPy starter package

Postby tmc » Fri Oct 28, 2011 2:51 pm

Hi all, I've put together an extended python starter package that uses NumPy to store the map and has several other improvements to ants.py, such as tracking the visible tiles and non-visible food and hills, and better map printing. Quote, "NumPy is the fundamental package needed for scientific computing with Python," especially for dealing with arrays. Numpy is not a standard module, so that part at least doesn't belong in the official starter pack. Anyone using numpy probably knows what they're doing, but maybe I can encourage some new numpy users by publishing this ;), as well as saving some people a few minutes. I've also included a few extra example functions in a separate file.



To quote the readme:

These are the significant changes from ants.py in the official Python starter
package:

-ants.map is now a 2D numpy array. Note that writing map[r,c] is a bit
faster than map[r][c]. More importantly, you can index by a position directly:
map[pos]. Yay!
However, indexing a numpy array is sadly 10x slower than indexing a list of
lists, so it would be a good idea to copy the map back to a temporary list of
lists each turn if you want to do lots of indexing (and if you're not... well,
what are you doing?!).
-Tiles in ants.map are now UNSEEN instead of LAND if you've never seen them.
-ants.visible is a 2D numpy array of booleans, marking the tiles visible this
turn, instead of a function.
-The locations of food and of ant hills are now remembered even when they aren't
visible. They are automatically forgotten if their tile becomes visible but
they've disappeared.
-ants.turn tracks the turn number and ants.turns the turn limit.
-ants.neighbours and ants.neighbours_and_dirs return lists of the four tiles
surrounding a tile, or (position, direction) tuples.
-ants.render_text_map is improved; in the official package it doesn't
show anthills (or unseen tiles of course).
-ants.issue_order can now called like ants.issue_order(ant_loc, direction) or
ants.issue_order(ant_loc, destination) rather than just
ants.issue_order((ant_loc, direction)).
-There's a debug() function in ants.py for convenience.

MyBot.py is identical.

See sample.py for some example usage of numpy. I'm not actually recommending you
use the BFS function therein directly for pathing to food, but it's a decent
start for a simple bot and at least one current top 10 bot is that stupid! You
might find some other use...
tmc
Brigadier-General
 
Posts: 101
Joined: Fri Oct 28, 2011 8:42 am

Re: Improved Python + NumPy starter package

Postby slug » Tue Nov 15, 2011 6:17 pm

Kina new to this. Will NumPy (and SciPy) be supported on the server?
slug
Cadet
 
Posts: 6
Joined: Thu Nov 10, 2011 8:36 am

Re: Improved Python + NumPy starter package

Postby mac » Wed Nov 16, 2011 8:12 am

Last edited by mac on Wed Nov 16, 2011 8:16 am, edited 1 time in total.
mac
Brigadier-General
 
Posts: 151
Joined: Mon Oct 31, 2011 6:39 am

Re: Improved Python + NumPy starter package

Postby mac » Wed Nov 16, 2011 8:15 am

mac
Brigadier-General
 
Posts: 151
Joined: Mon Oct 31, 2011 6:39 am

Re: Improved Python + NumPy starter package

Postby kirnatbkdotru » Sun Dec 25, 2011 2:30 pm

kirnatbkdotru
Cadet
 
Posts: 7
Joined: Sat Nov 05, 2011 12:36 pm


Return to Starter Packages & Tools

Who is online

Users browsing this forum: No registered users and 3 guests

cron