示例#1
0
文件: evolve.py 项目: alx21/silevolve
from src import combathandler
from src import silconstants
from src import weaponlist

from src import funclist
from src import genetree

# all of the "from src" stuff is nonsense but I don't know what this package
# is called yet ...

from pyevolve import G1DList
from pyevolve import GSimpleGA
from pyevolve import Util

evolving_thug = character.Character(
    name="Geoff", weapons=[weaponlist.hth(), weaponlist.meleeWeapon(), weaponlist.gun()]
)

simple_thug = character.Character(name="Thug", weapons=[weaponlist.meleeWeapon()])


def eval_func(chromosome):

    # populate the AI functions!
    evolving_thug.fillSlots(chromosome)

    for i in range(0, 100):

        # one hundred combats for each contestant!

        evolving_thug.clear()
示例#2
0
                                init=(2,0),
                                health=2,
                                weapons=[weaponlist.staff,weaponlist.hth()] )
                            
# a note about the weapons in those two characters; weaponlist.hth() inits
# a new instance of the hth class, whereas the iron_fist is an object defined
# in weaponlist. Be careful with that since they can be overwritten. And if more
# than one person is assigned an object, remember that it is an object and not
# a primitive ... shouldn't be a problem with the weapons, but just a heads-up

# heh it could be a problem with the weapons. It just occurred to me that giving
# the 'AK' to more than one person would mean that enemies could be sharing a
# clip. We might wanna fix that at some point. :P

thug1 = character.Character( name="Thug 1",
        weapons=[weaponlist.gun(), weaponlist.hth(), weaponlist.meleeWeapon()])
            
thug2 = character.Character(name="Thug 2", weapons=[weaponlist.meleeWeapon()])
# the default character is a good basic thug.
# melee weapon defaults to a knife.
thug3 = character.Character(name="Thug 3", weapons=[weaponlist.gun()])
thug4 = character.Character(name="Thug 4", weapons=[weaponlist.gun()])
thug5 = character.Character(name="Thug 5", weapons=[weaponlist.gun()])
thug6 = character.Character(name="Thug 6", weapons=[weaponlist.gun()])
thug7 = character.Character(name="Thug 7", weapons=[weaponlist.gun()])




#'lambda:' just means "return the following simple expression" and is a function