コード例 #1
0
 def __init__(self):
     self.loading = LoadingScreen(self)
     self.camera = Camera(self)
     self.lighting = Lighting(self)
     self.balltable = BallTable(self)
     self.menu = Menu(self)
     self.decision = Decision(self)
     self.mousekey = MouseKey(self)
     self.shotStrength = ShotStrength(self)
     self.state = GameState.START
     self.mode = GameMode.TUTORIAL
     self.balls = [Ball(self)] * 16
     self.ballinHole = [None] * 16
     self.LastFrameTimePoint = 0
コード例 #2
0
def weaponMenuSelectWeapon(num, menu, char, wmenu):
    decision = Decision()
    panel = menu.panels[0]
    panel.clearOptions()
    panel.addOptions([Option("Yes", panel.osize, promptMenuYes, [decision]),\
                      Option("No", panel.osize, promptMenuNo, [decision])])
    menu.addText("Equip?", 0, 0)
    try:
        menu.run()
    except SystemExit:
        pass
    if decision.bool:
        char.equipWeapon(num)
    wpanel = wmenu.panels[0]
    sel = wpanel.selected
    weapon = char.weapons[sel]
    weaponMenuPrintWeapon(weapon, wmenu, char)
コード例 #3
0
def armorMenuSelectArmor(num, menu, char, amenu):
    decision = Decision()
    panel = menu.panels[0]
    panel.clearOptions()
    panel.addOptions([Option("Yes", panel.osize, promptMenuYes, [decision]),\
                      Option("No", panel.osize, promptMenuNo, [decision])])
    menu.addText("Equip?", 0, 0)
    try:
        menu.run()
    except SystemExit:
        pass
    if decision.bool:
        char.equipArmor(num)
    apanel = amenu.panels[0]
    sel = apanel.selected
    armor = char.armors[sel]
    armorMenuPrintArmor(armor, amenu, char)
コード例 #4
0
 def mainAI(self):
     """Run AI mode"""
     start = time.time()
     mainGrid = Grid()
     mainGrid.computerAddTile()
     aiPlayer = Decision()
     while not self.checkGameOver(mainGrid):
         print("\nCOMPUTER TURN:")
         mainGrid.computerAddTile()
         mainGrid.displayGrid()
         if not self.checkGameOver(mainGrid):
             move = aiPlayer.getMove(mainGrid)
             mainGrid.move(move)
             print("\nPLAYER TURN:")
             mainGrid.displayGrid()
     print("\nFINAL GRID:")
     mainGrid.displayGrid()
     end = time.time()
     scores = mainGrid.scores()
     print("Max score: ", mainGrid.getMaxTile())
     print("Total time: ", end - start)
     return scores, end - start
コード例 #5
0
import numpy as np
import Perception
import Decision
import Memory
import random
import gym
import Learning
import math
import naoenvSimulation
import matplotlib.pyplot as plt

camera = Perception.Camera()
memory = Memory.Memory(camera)
Perc = Perception.Ball(memory)
learning = Learning.Learning(memory)
Dec = Decision.Decision(memory, learning)


def createEnvironment(numberOfPossibleBalls, environment, center):
    #create some balls
    ball = [0, 0]
    gaze = [0, 0]
    while gaze[0] == 0 or gaze[1] == 0:
        ball[0] = random.randrange(environment[0], environment[1], 1)
        ball[1] = random.randrange(environment[2], environment[3], 1)
        #create the gaze
        gaze = [ball[0] - center[0], ball[1] - center[1]]

    #find the direction of the gaze
    directionx = 1
    directiony = 1
コード例 #6
0
    print "error was ", e
    sys.exit(1)

# disable ALAutonomousMoves bug
am = ALProxy("ALAutonomousMoves", ip, port)
am.setExpressiveListeningEnabled(False)
am.setBackgroundStrategy("none")

#######Global classes#######
camera = Perc.Camera()
memory = memo.Memory(camera)
facePerception = Perc.Face(memory)
gazeFollowing = Perc.Gaze(memory)
ballPerception = Perc.Ball(memory)
learning = Learn.Learning(memory)
decision = Deci.Decision(memory, learning)
motivation = Moti.Motivation(memory)
motorControl = MC.MotorControl(motionProxy, memory, facePerception, tts)

################################################################
# Main functions
################################################################


def setup():
    say("Setting up")
    postureProxy.goToPosture("Crouch", 0.6667)


def say(text):
    tts.say(text)