Пример #1
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        
        # Set up the user interface from Designer.
        self.setupUi(self)      
        
        # Make some local modifications.
        # set up the nature
        self.nature = Nature()
                
        # set up the map widget
        self.map = MapFrame(self.nature, self.frame)
        self.map.setGeometry(QtCore.QRect(0,0,800,600))

        # connect
        QtCore.QObject.connect(self.btnNewDay,QtCore.SIGNAL("clicked()"), self.slotMove)
        QtCore.QObject.connect(self.btnManyDays,QtCore.SIGNAL("clicked()"), self.slotMoveMany)
        QtCore.QObject.connect(self.btnSave,QtCore.SIGNAL("clicked()"), self.slotSave)
        QtCore.QObject.connect(self.btnLoad,QtCore.SIGNAL("clicked()"), self.slotLoad)
Пример #2
0
    def __init__(self, _name):

        self.myName = _name
        self.myIDNum = 0

        self.myNature = 0

        self.myLevel = 50

        self.myTypes = [0, 0]
        self.myMoves = [0, 0, 0, 0]

        self.myTurnsSleeping = 0
        self.mySleepTarget = 0
        self.badPoisonTurns = 0

        # choice garbage
        self.myChoiceID = 0
        self.myChoiceMade = False

        # normal, paralyzed(1), asleep(2), poisoned(3), bad poisoned(4), burned(5), frozen(6)
        self.myPrimaryStatus = 0
        self.isConfused = False
        self.isDrowsy = False

        if self.myName == "Poliwrath":
            # water fighting
            self.myTypes[0] = 10
            self.myTypes[1] = 1

            self.myNature = Nature(10)

            self.mySpeciesBaseStats = [90, 95, 95, 70, 90, 70]
            self.myEffortValues = [252, 0, 252, 0, 4, 0]
            self.myBaseStats = [0, 0, 0, 0, 0, 0]
            self.ApplyBaseStats()

            self.myItem = Item("Leftovers")

            self.myMoves[0] = Move(503)
            self.myMoves[1] = Move(509)
            self.myMoves[2] = Move(95)
            self.myMoves[3] = Move(182)

        elif self.myName == "Hitmonlee":
            # fighting
            self.myTypes[0] = 1
            self.myTypes[1] = -1

            self.myNature = Nature(3)

            self.mySpeciesBaseStats = [50, 120, 53, 35, 110, 87]
            self.myEffortValues = [252, 0, 252, 0, 4, 0]
            self.myBaseStats = [0, 0, 0, 0, 0, 0]
            self.ApplyBaseStats()

            self.myItem = Item("White Herb")

            self.myMoves[0] = Move(282)
            self.myMoves[1] = Move(370)
            self.myMoves[2] = Move(174)
            self.myMoves[3] = Move(444)

        elif self.myName == "Jumpluff":
            # flying grass
            self.myTypes[0] = 2
            self.myTypes[1] = 11

            self.myNature = Nature(13)

            self.mySpeciesBaseStats = [75, 55, 70, 55, 95, 110]
            self.myEffortValues = [0, 0, 4, 0, 252, 252]
            self.myBaseStats = [0, 0, 0, 0, 0, 0]
            self.ApplyBaseStats()

            self.myItem = Item("Red Card")

            self.myMoves[0] = Move(73)
            self.myMoves[1] = Move(79)
            self.myMoves[2] = Move(369)
            self.myMoves[3] = Move(512)

        elif self.myName == "Magcargo":
            # fire rock
            self.myTypes[0] = 9
            self.myTypes[1] = 5

            self.myNature = Nature(20)

            self.mySpeciesBaseStats = [60, 50, 120, 90, 80, 30]
            self.myEffortValues = [252, 0, 252, 0, 4, 0]
            self.myBaseStats = [0, 0, 0, 0, 0, 0]
            self.ApplyBaseStats()

            self.myItem = Item("Leftovers")

            self.myMoves[0] = Move(446)
            self.myMoves[1] = Move(281)
            self.myMoves[2] = Move(153)
            self.myMoves[3] = Move(436)

        elif self.myName == "Gorebyss":
            # water
            self.myTypes[0] = 10
            self.myTypes[1] = -1

            self.myNature = Nature(15)

            self.mySpeciesBaseStats = [55, 84, 105, 114, 75, 52]
            self.myEffortValues = [252, 0, 252, 0, 4, 0]
            self.myBaseStats = [0, 0, 0, 0, 0, 0]
            self.ApplyBaseStats()

            self.myItem = Item("White Herb")

            self.myMoves[0] = Move(58)
            self.myMoves[1] = Move(56)
            self.myMoves[2] = Move(504)
            self.myMoves[3] = Move(164)

        elif self.myName == "Whimsicott":
            # grass fairy
            self.myTypes[0] = 11
            self.myTypes[1] = 17

            self.myNature = Nature(10)

            self.mySpeciesBaseStats = [60, 67, 85, 77, 75, 116]
            self.myEffortValues = [252, 0, 252, 0, 4, 0]
            self.myBaseStats = [0, 0, 0, 0, 0, 0]
            self.ApplyBaseStats()

            self.myItem = Item("Choice Specs")

            self.myMoves[0] = Move(585)
            self.myMoves[1] = Move(412)
            self.myMoves[2] = Move(94)
            self.myMoves[3] = Move(369)

        self.myCurrentHealth = self.myBaseStats[0]

        self.ApplyNature()
Пример #3
0
from InfluenceLimiter import InfluenceLimiter
from BayesianGreedy import BayesianGreedy
from BetaDistribution import BetaDistribution
from Nature import Nature

K = 3
num_agents = 3
num_reports = 10
initial_reputations = 0.1

nature = Nature(num_agents, K)
theta = [0.1, 0.2, 0.8]
trust = [True, True, True]

nature.initialize_arms(theta)
nature.initialize_agents(trust, num_reports, initial_reputations)

print(nature.agency.agents[0].arm_dists[0].theta)
print(nature.agency.agents[0].arm_dists[1].theta)
print(nature.agency.agents[0].arm_dists[2].theta)

print(nature.agency.agents[1].arm_dists[0].theta)
print(nature.agency.agents[1].arm_dists[1].theta)
print(nature.agency.agents[1].arm_dists[2].theta)

print(nature.agency.agents[2].arm_dists[0].theta)
print(nature.agency.agents[2].arm_dists[1].theta)
print(nature.agency.agents[2].arm_dists[2].theta)

nature.agency.agent_reports = [[0.2, 0.1, 0.7], [0.1, 0.3, 0.9],
                               [0.2, 0.2, 0.6]]
Пример #4
0
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        
        # Set up the user interface from Designer.
        self.setupUi(self)      
        
        # Make some local modifications.
        # set up the nature
        self.nature = Nature()
                
        # set up the map widget
        self.map = MapFrame(self.nature, self.frame)
        self.map.setGeometry(QtCore.QRect(0,0,800,600))

        # connect
        QtCore.QObject.connect(self.btnNewDay,QtCore.SIGNAL("clicked()"), self.slotMove)
        QtCore.QObject.connect(self.btnManyDays,QtCore.SIGNAL("clicked()"), self.slotMoveMany)
        QtCore.QObject.connect(self.btnSave,QtCore.SIGNAL("clicked()"), self.slotSave)
        QtCore.QObject.connect(self.btnLoad,QtCore.SIGNAL("clicked()"), self.slotLoad)
    


    def show(self):
        QtGui.QMainWindow.show(self)
        self.showStatus()

    def slotMoveManyProfile(self):
        """
        for profiling,
        to use, rename slotMoveMany() to slotMoveManyReal()
        and rename this function to slotMoveMany()
        """
        profile.runctx('self.slotMoveManyReal()'
                       , vars(sys.modules[__name__])
                       , vars()
                       , 'profile.log')

    def slotMoveMany(self):
        """
        move many days
        """
        for _ in xrange(int(self.txtDays.text())):
            self.nature.newDay()
            self.map.drawImage()
            self.map.save()
        self.showStatus(save=False)
        os.system('eject')

    def slotMove(self):
        self.nature.newDay()
        self.showStatus()

    def showStatus(self, save=True):
        self.map.update()
        self.statusbar.showMessage('Day: %d  Grass: %d  Zebra: %d  Lion: %d  Time: %.3f' % \
                                   self.nature.getStats()[:5])
        if save:
            self.map.save()

    def slotSave(self):
        pickle.dump(self.nature, open('nature.pickle', 'w'), protocol=pickle.HIGHEST_PROTOCOL)
        self.statusbar.showMessage('Saved data!')

    def slotLoad(self):
        self.nature = pickle.load(open('nature.pickle'))
        self.showStatus(save=False)