Skip to content

Commit

Permalink
Merge remote branch 'upstream/simpleants' into simpleants
Browse files Browse the repository at this point in the history
Conflicts:
	map.py
  • Loading branch information
unknown authored and unknown committed Feb 6, 2011
2 parents 73bf6e5 + 0e0c4ea commit f118a82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Empty file removed README
Empty file.
6 changes: 6 additions & 0 deletions README.md
@@ -0,0 +1,6 @@
Ants
====

* Game from AI Challenge *

This code will provide the basis for the ants challenge. It will later be merged in a contest framework.
10 changes: 6 additions & 4 deletions map.py
Expand Up @@ -11,14 +11,15 @@ def __init__(self, filename):
self.passable = []
self.ants = AntList()
image = Image.open(filename)
img = image.load()
(self.width, self.height) = image.size
self.num_players = 0
self.land_area = 0
self.water_area = 0
for x in range(self.width):
self.passable.append([])
for y in range(self.height):
pixel = image.getpixel((x, y))
pixel = img[x,y]
if pixel[0] > 0:
self.passable[x].append(True)
self.num_players += 1
Expand Down Expand Up @@ -56,15 +57,16 @@ def render(self):
(128, 128, 128)
]
image = Image.new("RGB", ((self.width, self.height)))
img = image.load()
for x in range(self.width):
for y in range(self.height):
ant = self.ants.get_by_location(x, y)
if ant is not None:
image.putpixel((x, y), player_colors[ant.owner])
img[x, y] = player_colors[ant.owner]
elif self.passable[x][y]:
image.putpixel((x, y), land_color)
img[x, y] = land_color
else:
image.putpixel((x, y), water_color)
img[x, y] = water_color
return image

def remaining_players(self):
Expand Down

0 comments on commit f118a82

Please sign in to comment.