Module playerai :: Class ComputerPlayer
[hide private]
[frames] | no frames]

Class ComputerPlayer

source code

                  object --+        
                           |        
pyglet.event.EventDispatcher --+    
                               |    
           cocos.layer.Layer --+    
                               |    
               player_new.Player --+
                                   |
                                  ComputerPlayer

The premise of this AI is to use a FINITE STATE MACHINE to react "intelligently" to a human player. The states of this machine are defined below. An "N-Gram" will be used to collect data about player moves. The "A-Star" pathfinding algorithm will be employed to find the most efficient way to attack. The AI will prioritize vertices containing human-built troops based on a "heatmap", which allows the AI to prioritize resources and its own troops.

Instance Methods [hide private]
 
__init__(self, ID)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
scan(self) source code
 
scan_all_vertices(self) source code
 
trigger(self) source code
 
mathematical_probability(self, boundary=50) source code
 
random_search_and_destroy(self) source code
 
swarm_vertex(self, swarmCompletion, swarmVertex=None) source code
 
build_a_troop(self, unitType, locationVid) source code
 
get_closest_empty_vertex(self) source code
 
grab_inactive_troop(self) source code
 
marshall_troops(self, swarmNumber=0) source code
 
swarm_attack(self, attackFromPosition) source code
 
get_closest_safe_adjacent_vertex(self, vidOfInterest, safe=True) source code
 
check_if_valid_for_attack(self, attacker, victim) source code
 
perform_single_target_attack(self, victim="void", attacker="void") source code
 
perform_single_target_random_move(self, destination=0, troopToMove=0) source code
 
check_defenses(self) source code
 
defend_our_server(self) source code
 
attack_with_list_of_troops(self, victimList) source code
 
get_units_within_attacking_distance(self, passVertex) source code
 
reassign_troops(self) source code
 
perform_defensive_reaction(self) source code
 
ai_loop(self, dt) source code
 
select_target(self, unit) source code

Inherited from player_new.Player: set_unit_uid

Inherited from pyglet.event.EventDispatcher: dispatch_event, event, pop_handlers, push_handlers, remove_handler, remove_handlers, set_handler, set_handlers

Inherited from pyglet.event.EventDispatcher (private): _get_handlers, _raise_dispatch_exception

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from pyglet.event.EventDispatcher: register_event_type

Class Variables [hide private]

Inherited from pyglet.event.EventDispatcher (private): _event_stack

Instance Variables [hide private]
  buildLimit
# DISCARDED CODE --------------------------------------------------------------------------------- #for slot in vertex.troopSlots.values(): #for slot in vertex.troopSlots.values(): ## /print "At vertex ", vertex.vid, " there is a ", vertex.building, " with this stuff ", slot.troop
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, ID)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

Instance Variable Details [hide private]

buildLimit


# DISCARDED CODE ---------------------------------------------------------------------------------
#for slot in vertex.troopSlots.values():
#for slot in vertex.troopSlots.values():
## /print "At vertex ", vertex.vid, " there is a ", vertex.building, " with this stuff ", slot.troop

# A GOOD SET OF TROOPS: DOS,2 DOS,2 DOS,18 DOS,18 Ping,31 DOS,17 Ping,35 DOS,14 DOS,14 DOS,14 DOS,14 Ping,35 Ping,35 Ping,35 Ping,33 Ping,33

#self.human_troops = 0
#self.ai_troops = 0

#print self.troops
#for vertex in self.enemy.availableTroops[0].curVertex.adjacentVertices:
    #print vertex.troopSlots