16
Programming / Re: Trouble implementing A*
« on: October 06, 2012, 12:37:15 PM »
Interesting.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
def CanSee(self, o):
#Returns true if this fighter can see the object
monster = self.owner
if o.fighter:
Object = o.owner
else:
Object = o
libtcod.line_init(monster.x, monster.y, Object.x, Object.y)
x,y=libtcod.line_step()
while (not x is None ):
for object in objects:
if map[x][y].blocked == False:
if object.x == x and object.y == y:
return True
x,y=libtcod.line_step()
return False
class AI_Evaluate:
#AI Component - Creature is evaluating it's situation
creature = self.owner
myobjects = [] #a list of all the objects the creature can see
#get an FOV for the creature
my_fov = libtcod.map_new(MAP_WIDTH, MAP_HEIGHT)
for y in range(MAP_HEIGHT):
for x in range(MAP_WIDTH):
for object in objects:
if self.x = x:
if self.y = y:
myobjects.append(object)
for object in myobjects:
if object != None:
#assign need values
class AI_Evaluate
#AI Component - Creature is evaluating it's situation
objects = [] #a list of all the objects the creature can see
#get an FOV for the creature
my_fov = libtcod.map_new(MAP_WIDTH, MAP_HEIGHT)
for y in range(MAP_HEIGHT):
for x in range(MAP_WIDTH):
libtcod.map_set_properties(my_fov, self.x, self.y, not map[x][y].block_sight, not map[x][y].blocked)
for y in range(MAP_HEIGHT):
for x in range(MAP_WIDTH):
#visible = libtcod.map_is_in_fov(my_fov, x, y)
#if visible:
#if there is an object here:
#objects.append(object)