コード例 #1
0
 def __init__(self, parent=None):
     super(MainWindow, self).__init__()
     QtWidgets.QMainWindow.__init__(self)
     #Importando el archivo .css
     instructions = Instructions()
     with open("MainWindow.css") as f:
         self.setStyleSheet(f.read())
     self.setupUi(self)
     self.setWindowIcon(QIcon("logo.png"))
     self.instructions = QLabelClickable("Instrucciones...")
     self.instructions.clicked.connect(lambda: instructions.show())
     self.layout.addWidget(self.instructions)
     #Lo que va a aparecer en cada QPlainText cuando esté vacío
     self.array = ""
     self.roads = ""
     self.edge_labels = {}
     self.characters.setTabStopWidth(
         self.characters.fontMetrics().width(" ") * 10)
     self.characters.setPlaceholderText(
         "Ingrese vértices, aristas y caracteristicas.")
     self.root_node.setPlaceholderText("Nodo Origen")
     self.last_node.setPlaceholderText("Nodo Destino")
     self.load_file.clicked.connect(self.loadFile)
     self.create_map.clicked.connect(self.passToOpen)
     self.create_table.clicked.connect(self.openTable)
     #self.converter()
     self.setFocus()
コード例 #2
0
def main():
    
    #global donePlaying 
    #global titleScreen
    #global howToPlay
    #global mainGame
    #global gameOver
    #global creditScreen
    #global startMenu
    #global menu
    #global clearSprites
    
    while Globals.donePlaying != True:
        print Globals.donePlaying
        if Globals.titleScreen == True:
            Title.title()
        elif Globals.howToPlay == True:
            Instructions.instructions()
        elif Globals.mainGame == True:
            Game.game()
        elif Globals.pauseMenu == True:
            PauseMenu.pausemenu()
        elif Globals.gameOver == True:
            GameOver.gameover()
        elif Globals.creditScreen == True:
            Credits.credits()
        elif Globals.winScreen == True:
            Win.win()
コード例 #3
0
 def evalToRegInstr(self, p, reg):
     try:
         isInitialized = self.identifier.declaration.initialized
         if isInitialized == False:
             raise Exception("Variable '%s' is not initialized" % self.identifier.pidentifier)
         if isinstance(self.identifier, ArrayAccess):
             return Instructions.LOAD_ARRAY_VALUE_TO_REGISTER(p, self.identifier, reg)
         return Instructions.LOAD_IDENTIFIER_VALUE_TO_REGISTER(p, self.identifier, reg)
     except Exception as err:
         raise Exception(str(err) + " at line %i" % self.lineNumber)
コード例 #4
0
 def evalToRegInstr(self, p, reg):
     if self.operator == '+':
         return Instructions.PLUS(p, self.left, self.right, reg)
     if self.operator == '-':
         return Instructions.MINUS(p, self.left, self.right, reg)
     if self.operator == '*':
         return Instructions.TIMES(p, self.left, self.right, reg)
     if self.operator == '/':
         return Instructions.DIVIDE(p, self.left, self.right, reg)
     if self.operator == '%':
         return Instructions.MODULO(p, self.left, self.right, reg)
     else:
         raise Exception("Operator '%s' not defined" % self.operator)
コード例 #5
0
ファイル: Identifier.py プロジェクト: kestarumper/jftt
    def memAddressToReg(self, p, reg1, reg2):
        declaration = self.declaration

        if not declaration.isArray():
            raise Exception("'%s' is not an Array" % declaration.pidentifier)

        memoryId = MemoryManager.getBlockId(self.pidentifier)
        arrRangeFrom = declaration.rangeFrom
        arrRangeTo = declaration.rangeTo
        offset = self.index - arrRangeFrom
        if offset < 0 :
            raise Exception("Array out of bounds. Given %i, but range is (%i:%i)" % (self.index, arrRangeFrom, arrRangeTo))
        Instructions.setRegisterConst(p, reg2, offset)
        Instructions.setRegisterConst(p, reg1, memoryId)
        Instructions.ADD(p, reg1, reg2)
コード例 #6
0
def p_unset(p):
    'unset              :   R_UNSET S_L_PAR register S_R_PAR S_SEMICOLON'
    node_index = inc()
    dot.node(node_index, 'unset()')
    dot.edge(node_index, p[3].node_index)
    p[0] = Instructions.Unset(node_index, p[3])
    p[0].lineno = p.slice[1].lineno
コード例 #7
0
def p_print(p):
    'print              :   R_PRINT S_L_PAR operand S_R_PAR S_SEMICOLON'
    node_index = inc()
    dot.node(node_index, 'print()')
    dot.edge(node_index, p[3].node_index)
    p[0] = Instructions.Print(node_index, p[3])
    p[0].lineno = p.slice[1].lineno
コード例 #8
0
def p_main(p):
    '''main             :   R_MAIN S_COLON list_instr
                        |   R_MAIN error list_instr'''
    node_index = inc()
    dot.node(node_index, 'main')
    dot.edge(node_index, p[3].node_index)
    p[0] = Instructions.Main(node_index, p[3].instructions_list)
コード例 #9
0
def p_label(p):
    '''label            :   LABEL_NAME S_COLON list_instr
                        |   LABEL_NAME error list_instr'''
    node_index = inc()
    dot.node(node_index, p.slice[1].value)
    dot.edge(node_index, p[3].node_index)
    p[0] = Instructions.Label(node_index, p[1], p[3].instructions_list)
コード例 #10
0
    def listen(self):
        instructions = Instructions.Instructions("instructions_pl.txt",
                                                 "instrukcje gry")

        try:
            self.move_ = ''
            os.system('python run_sarmata.py')
            f = open("result.txt", "r")
            self.message_ = f.read()
            if self.message_ == "otwórz instrukcje" or self.message_ == "pokaż instrukcje":
                instructions.show_instructions()
            elif self.message_ == "poddaję się" or self.message_ == "poddaj się" \
                    or self.message_ == "zakończ grę" or self.message_ == "koniec gry":
                sys.exit(1)
            elif self.message_ == "repeat":
                winsound.PlaySound("repeat_pl.wav", winsound.SND_FILENAME)
                self.listen()
            elif self.message_ == "pokaż dostępne ruchy" or self.message_ == "pokaż możliwe ruchy":
                winsound.PlaySound("ask_of_figure_pl.wav",
                                   winsound.SND_FILENAME)
                self.checking_ = True
                self.listen()
            elif self.checking_:
                self.move_ = self.converter_.convert_pos(c=self.message_)
            else:
                self.move_ = self.converter_.convert(c=self.message_)
            f.close()

        except:
            if self.message_ == "poddaję się" or self.message_ == "poddaj się" \
                    or self.message_ == "zakończ grę" or self.message_ == "koniec gry" or self.message_ == "koniec":
                sys.exit(1)
コード例 #11
0
 def __init__(self):
     self.instructions_ = Instructions.Instructions("instructions_pl.txt",
                                                    "Instrukcje gry")
     self.instructions_.show_instructions()
     self.chess_engine_ = ChessEngine.ChessEngine(True)
     self.gui_ = GUI.GUI()
     self.converter_ = ChessConverter.ChessConverter()
コード例 #12
0
 def test_modificationGrid(self):
     instructionList = ["switch", 1, 1, 2, 2]
     inputInstruction = Instructions.Instruction(instructionList)
     inputGrid = {
         (0, 0): False,
         (0, 1): False,
         (0, 2): False,
         (1, 0): False,
         (1, 1): False,
         (1, 2): False,
         (2, 0): False,
         (2, 1): False,
         (2, 2): False
     }
     outputGrid = {
         (0, 0): False,
         (0, 1): False,
         (0, 2): False,
         (1, 0): False,
         (1, 1): True,
         (1, 2): True,
         (2, 0): False,
         (2, 1): True,
         (2, 2): True
     }
     self.assertEqual(
         Modification.modificationGrid(inputInstruction, inputGrid),
         outputGrid)
コード例 #13
0
def p_if(p):
    'if                 :   R_IF S_L_PAR expression S_R_PAR goto'
    node_index = inc()
    dot.node(node_index, 'if')
    dot.edge(node_index, p[3].node_index)
    dot.edge(node_index, p[5].node_index)
    p[0] = Instructions.If(node_index, p[3], p[5])
    p[0].lineno = p.slice[1].lineno
コード例 #14
0
def p_assignation(p):
    '''assignation      :   register S_EQUAL expression S_SEMICOLON'''
    node_index = inc()
    dot.node(node_index, '=')
    dot.edge(node_index, p[1].node_index)
    dot.edge(node_index, p[3].node_index)
    p[0] = Instructions.Assignation(node_index, p[1], p[3])
    p[0].lineno = p[1].lineno
コード例 #15
0
def p_goto(p):
    'goto               :   R_GOTO LABEL_NAME S_SEMICOLON'
    node_index = inc()
    dot.node(node_index, 'goto')
    node_lbl_index = inc()
    dot.node(node_lbl_index, p.slice[2].value)
    dot.edge(node_index, node_lbl_index)
    p[0] = Instructions.GoTo(node_index, p.slice[2].value)
    p[0].lineno = p.slice[1].lineno
コード例 #16
0
def toAssembly(lines):
    commands = []
    for line, lineno in lines:
        try:
            cmd = Instructions.new(line)
            commands.append(cmd)
        except SyntaxError as ex:
            ex.lineno = lineno
            raise ex
    return commands
コード例 #17
0
def sumLED(gridSize, theSource):  #int, str
    theGrid = Grid.Grid(gridSize).grid
    theSource = urllib.request.urlopen(theSource)
    for line in theSource:
        theLine = str(line, 'utf-8')
        #formatting
        theLine = Instructions.instructionFormat(theLine)
        #test
        if not Instructions.instructionValidTypes(theLine):
            pass
        else:
            theLine = Instructions.instructionValidRange(theLine, gridSize)
            if not Instructions.instructionValidOrder(theLine):
                pass
            else:
                theLine = Instructions.Instruction(theLine)
                theGrid = Modification.modificationGrid(theLine, theGrid)
    gridSum = sum(theGrid.values())
    return gridSum
コード例 #18
0
	def DecodeCode(self):
		newCode = []
		for line in self.Code:
			for directive, value in self.Directives.iteritems():
				extracted = [piece for piece in re.split("\[|\]| |,|\t|\+", line.String)] # Split the instruction by spaces, commas, and brackets
				if directive in extracted:
					line.String = line.String.replace(directive, value)
			if line.String.strip().endswith(':'):
				Common.Error(line, "Label must be on the same line as an instruction")
			self.Instructions.append(Instructions.DecodeLine(line))
			newCode.append(line)
		self.Code = newCode
コード例 #19
0
def p_list_instr_p_instr(p):
    'list_instr_p       :   instr list_instr_p'
    node_index = inc()
    instructions = [p[1]] + p[2].instructions_list
    dot.node(node_index, 'instruction')
    dot.edge(node_index, p[1].node_index)
    p[0] = Instructions.InstructionsList(node_index, instructions)
    try:
        'para vincular la posible lista de instrucciones'
        dot.edge(node_index, p[2].node_index)
    except AttributeError:
        '''es la última instrucción por lo que list_instr_p produce epsilon
コード例 #20
0
def p_list_label(p):
    'list_label         :   label list_label_p'
    node_index = inc()
    dot.node(node_index, 'label_list')
    labels = [p[1]] + p[2].list_label
    dot.edge(node_index, p[1].node_index)
    p[0] = Instructions.LabelList(node_index, labels)
    try:
        'para vincular la posible lista de labels'
        dot.edge(node_index, p[2].node_index)
    except AttributeError:
        '''es la última instrucción por lo que list_label_p produce epsilon
コード例 #21
0
ファイル: Menu.py プロジェクト: BitBallers/GammaRayKitten
 def event(self, event):
     if event.type == PG.MOUSEBUTTONDOWN:
         if self.selected[0]:
             G.Globals.STATE = StoryBoard.StoryBoard(
                 "story_texts/intro.txt", self.images)
         if self.selected[1]:
             G.Globals.STATE = Instructions.Instructions()
         if self.selected[2]:
             G.Globals.STATE = Options.Options()
         if self.selected[3]:
             G.Globals.STATE = Score.Score()
         if self.selected[4]:
             G.Globals.RUNNING = False
コード例 #22
0
 def test_Instruction(self):
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).instruction,
         ["switch", 1, 2, 3, 4])
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).command, "switch")
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).start, (1, 2))
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).end, (3, 4))
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).x1, 1)
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).y1, 2)
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).x2, 3)
     self.assertEqual(
         Instructions.Instruction(["switch", 1, 2, 3, 4]).y2, 4)
コード例 #23
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        self.SetBackgroundColour("#f0f0f0")

        #-------------------------------------------------------------------

        self.stbx1 = Instructions.My_StaticBox(self)
        self.stbx2 = ArgumentOne.My_StaticBox(self)
        self.stbx3 = ArgumentTwo.My_StaticBox(self)
        self.stbx4 = ArgumentThree.My_StaticBox(self)
        self.stbx5 = ArgumentFour.My_StaticBox(self)
        self.stbx6 = ArgumentFive.My_StaticBox(self)
        self.stbx7 = Eflags.My_StaticBox(self)

        stbx1Sizer = wx.BoxSizer(wx.HORIZONTAL)
        stbx2Sizer = wx.BoxSizer(wx.HORIZONTAL)
        stbx3Sizer = wx.BoxSizer(wx.HORIZONTAL)
        stbx4Sizer = wx.BoxSizer(wx.HORIZONTAL)

        stbx1Sizer.Add(self.stbx1, 1, wx.EXPAND | wx.ALL, 0)
        stbx2Sizer.Add(self.stbx2, 1, wx.EXPAND | wx.ALL, 0)
        stbx2Sizer.Add(self.stbx3, 1, wx.EXPAND | wx.ALL, 0)
        stbx3Sizer.Add(self.stbx4, 1, wx.EXPAND | wx.ALL, 0)
        stbx3Sizer.Add(self.stbx5, 1, wx.EXPAND | wx.ALL, 0)
        stbx4Sizer.Add(self.stbx6, 1, wx.EXPAND | wx.ALL, 0)
        stbx4Sizer.Add(self.stbx7, 1, wx.EXPAND | wx.ALL, 0)

        #----------

        stbxSizer = wx.BoxSizer(wx.VERTICAL)

        stbxSizer.Add(stbx1Sizer, 1, wx.EXPAND | wx.ALL, 0)
        stbxSizer.Add(stbx2Sizer, 1, wx.EXPAND | wx.ALL, 0)
        stbxSizer.Add(stbx3Sizer, 1, wx.EXPAND | wx.ALL, 0)
        stbxSizer.Add(stbx4Sizer, 1, wx.EXPAND | wx.ALL, 0)

        #----------

        self.SetAutoLayout(True)
        self.SetSizer(stbxSizer)
        stbxSizer.Fit(self)
コード例 #24
0
ファイル: Condition.py プロジェクト: kestarumper/jftt
 def generateCode(self, p):
     if self.operator == '>':
         return Instructions.CONDITION_GT(p, self.left, self.right)
     if self.operator == '>=':
         return Instructions.CONDITION_GEQ(p, self.left, self.right)
     if self.operator == '<':
         return Instructions.CONDITION_LT(p, self.left, self.right)
     if self.operator == '<=':
         return Instructions.CONDITION_LEQ(p, self.left, self.right)
     if self.operator == '=':
         return Instructions.CONDITION_EQ(p, self.left, self.right)
     if self.operator == '!=':
         return Instructions.CONDITION_NEQ(p, self.left, self.right)
     else:
         raise Exception("Undefined CONDITION operator '%s'" %
                         self.operator)
コード例 #25
0
ファイル: Identifier.py プロジェクト: kestarumper/jftt
    def memAddressToReg(self, p, reg1, reg2):
        declaration = self.declaration

        if not declaration.isArray():
            raise Exception("'%s' is not an Array" % declaration.pidentifier)

        memoryId = declaration.memoryId
        arrRangeFrom = declaration.rangeFrom
        arrRangeTo = declaration.rangeTo

        indexIdentifier = Identifier(self.index)

        # tab(5:15)         [memoryId:memoryId+10]
        # a := 7
        # tab(a)
        Instructions.LOAD_IDENTIFIER_VALUE_TO_REGISTER(p, indexIdentifier, reg2)  # reg2 = a.value
        Instructions.setRegisterConst(p, reg1, arrRangeFrom)                      # reg1 = arrRangeFrom
        Instructions.SUB(p, reg2, reg1)                                           # reg2 = reg2 - reg1 // offset
        Instructions.setRegisterConst(p, reg1, memoryId)                          # reg1 = memoryId
        Instructions.ADD(p, reg1, reg2)                                           # reg1 = reg1 + reg2 // memid + offset
コード例 #26
0
 def test_modificationEntry(self):
     self.assertEqual(
         Modification.modificationEntry(
             Instructions.Instruction(["on", 1, 2, 3, 4]), True), True)
     self.assertEqual(
         Modification.modificationEntry(
             Instructions.Instruction(["off", 1, 2, 3, 4]), True), False)
     self.assertEqual(
         Modification.modificationEntry(
             Instructions.Instruction(["on", 1, 2, 3, 4]), False), True)
     self.assertEqual(
         Modification.modificationEntry(
             Instructions.Instruction(["off", 1, 2, 3, 4]), False), False)
     self.assertEqual(
         Modification.modificationEntry(
             Instructions.Instruction(["switch", 1, 2, 3, 4]), True), False)
     self.assertEqual(
         Modification.modificationEntry(
             Instructions.Instruction(["switch", 1, 2, 3, 4]), False), True)
コード例 #27
0
ファイル: emulator.py プロジェクト: birdoggydog/ARM-Emulator
def main():
	
	global mode, usr, syst,svc,abt,und,irq,fiq, abtRegister, usrRegister, svcRegister, fiqRegister,irqRegister,undRegister,systRegister 

	global ADC, ADD, AND, BIC, CMN, CMP, EOR, MOV, MVN,ORR, RSB, RSC, SBC, SUB, TEQ, TST, ADC, ADD, AND, BIC, CMN, CMP, EOR, MOV, MVN,ORR, RSB, RSC, SBC, SUB, TEQ, TST,COND
	global MRS, MSR , BX, CLZ, BLX2, BLX1,LDR, LDRB
	global LDRBT,LDRH,LDRSB,LDRSH,LDRT,STR,STRB,STRBT,STRH,STRTMLA,MUL,SMLAL,SMULL,UMLAL,UMULL, LDM1, LDM2, LDM3, STM1, STM2 
	global LR,PC,CPSR,SPSR
	addMode = 0
	
	usr = 0
	syst = 1
	svc = 2
	abt = 3
	und = 4
	irq = 5
	fiq = 6
	mode = usr
	LR = 14
	PC = 15     
	CPSR = 16
	SPSR = 17	

	## will add ability to pass in file name as arguement.	
	#filename = 'code/template.machine'
	#filename = 'code/instTests/adc/adc.test'
	# inits our regs	
	register = regInit()
	# inits our memory
	
	# sets the registers up
	register = setMode(mode, usr, register)
	# ganks a binary, converts to hex

	#g = g[0].strip("\n")
	#	print()
	#	print(g)
	
	Memory, register[PC] = elf.loadfile(sys.stdin.readlines()[0].strip("\n"))

	#print(hex(entry))
	#print(Memory)

	ADC, ADD, AND, BIC, CMN, CMP, EOR, MOV, MVN,ORR, RSB, RSC, SBC, SUB, TEQ, TST = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
			# Misc Insts, Branching.

	MRS, MSR , BX, CLZ, BLX2, BLX1, BBL = 17,18,19,20,21,22,48
			# Multiplies:

	MLA,MUL,SMLAL,SMULL,UMLAL,UMULL = 23,24,25,26,27,28
			## load/store mults:
	
	LDM1, LDM2, LDM3, STM1, STM2 = 29,30,31,32,33
			# extra load/store instructions:
	
	LDR, LDRB, LDRBT,LDRH,LDRSB,LDRSH,LDRT,STR,STRB,STRBT,STRH,STRT= 34,35,36,37,38,39,40,41,42,43,44,45
	DP32BitImmediate = 0
	DPImmediateShift= 1 
	DPRegShift = 2
	MLSImmOffIndex = 3
	MLSRegOffIndex = 4
	LSImmOffIndex = 5
	LSRegOffIndex = 6
	LSScaleRegOffIndex = 7		
	LSMultiple = 8
	UND = 96
	IRREL = 10
	UNPRED = 99
	BKPT = 98
	SWI = 97
	PC = 15
	CPSR = 16
	SPSR = 17
	COND = 0
	#barrelShifter = BarrellShifter()
	#register[PC] = 0x8054
	while True:  # represents the main loop
		
		for i in range(16):
			print("R[{0}] :".format(i),hex(register[i]))
		word = fetch(Memory, register)

		addMode = BarrellShifter.determineMode(word)
		inst = Instructions.parseInstruction(word)
		
		register[PC] = register[PC] +4
		instStr = setInstString(inst)
		if inst == BKPT or inst == SWI:
			handleException(word,inst,addMode)

		else:
			if addMode == DP32BitImmediate or addMode == DPImmediateShift or addMode == DPRegShift:
				shifter_operand, shifter_carry_out, register = BarrellShifter.do_data_proc(word,addMode,inst,register)
				register = Instructions.do_dp(shifter_operand,shifter_carry_out,register,inst,word)
			
			elif addMode == MLSImmOffIndex or addMode == MLSRegOffIndex:
				address,register = BarrellShifter.do_misc_l_s(word,addMode,inst,register)
				register, Memory = Instructions.do_LS(address,Memory,register,inst,word)

			elif addMode == LSMultiple:
				start_address,end_address,register = BarrellShifter.do_l_s_mult(word,addMode,inst,register)
				Memory, register = Instructions.do_LSM(start_address,end_address,Memory,register,inst,word)
			
			elif addMode == LSImmOffIndex or addMode == LSRegOffIndex or addMode == LSScaleRegOffIndex:
				address, register = BarrellShifter.do_l_s(word,addMode,inst,register)
				register, Memory = Instructions.do_LS(address,Memory,register,inst,word)
			elif inst >22 and inst <29:
				register =  Instructions.do_multiplies(Memory,register,word,inst,addMode)
			else: 
				register = Instructions.do_misc(Memory,register,word,inst,addMode)
			print("Word: ", bin(word),". Add Mode: ", addMode, "Inst: ", instStr)
コード例 #28
0
def RUN():
    global SignalValue
    FPSclock = pygame.time.Clock()
    FPSclock.tick(FPS)
    StimList = LoadStim(LanuageNumber)
    BaseStim = LoadBaseStim(LanuageNumber)
    mRT = []
    mAcc = []
    while True:
        [ConsentScreen(i) for i in range(2)]
        [Instructions(i) for i in range(28)]
        for block in range(Blocks):
            RT              = []
            Acc             = []
            RspList         = []
            AngleList       = []
            CndList         = []
            MouseList       = []
            SignalContrast  = []
            ContrastListN   = []
            MovementOnset   = []
            TimeInMotion    = []
            for trial, contrastN in cnd_list_contrasts(Trials,blockN=block):
                if trial == 111:
                    nRT = np.asarray(RT); nAcc = np.asarray(Acc)
                    mRT.append( np.mean( np.abs( nRT[nRT > -Max_Stim_Time] ) ) / 1000 ) # Mean RT excluding Timeouts
                    mAcc.append( np.mean( nAcc ) * 100 )
                    
                    SaveDict                            = OrderedDict()
                    SaveDict['NativeLangNumber']        = [NativeNumber] * len(RT)
                    SaveDict['LanuageNumber']           = [LanuageNumber] * len(RT)
                    SaveDict['SessionNumber']           = [SessionNumber] * len(RT)
                    SaveDict['Block']                   = [block]*len(RT)
                    SaveDict['TrialNum']                = list(range(1,len(RT)+1))
                    SaveDict['ConditionNumber']         = CndList
                    SaveDict['Response']                = RspList
                    SaveDict['Accuracy']                = Acc
                    SaveDict['RT']                      = RT
                    SaveDict['MovementOnsetTime']       = MovementOnset
                    SaveDict['TimeInMotion']            = TimeInMotion
                    SaveDict['SignalContrast']          = SignalContrast
                    SaveDict['SignalContrastNumber']    = ContrastListN

                    SaveDict['StimDisplayTime']         = [Stim_Display_Time] * len(RT)
                    SaveDict['MaskTime']                = [Mask_Time] * len(RT)
                    SaveDict['MaxResponseTime']         = [Max_Stim_Time] * len(RT)
                    
                    SaveDict['MousePositionXY']         = MouseList
                    SaveDict['MouseAngle']              = AngleList
                    SaveDict['WheelOrder']              = [WheelOrder] * len(RT)
                    SaveDict['NoiseMuSigma']            = zip([NoiseMu], [NoiseSigma]) * len(RT)
                    
                    SaveDict['ParticipantID']           = [ParticipantID]*len(RT)
                    SaveDict['LanuageTested']           = [PartPrefix] * len(RT)
                    SaveDict['SessionTested']           = [SessionLetter] * len(RT)
                    SaveDict['NativeLanuage']           = [NativeLanuage] * len(RT)
                    SaveDict['Date']                    = [Date] * len(RT)
                    SaveDict['ResponseDevice']          = [Device] * len(RT)
                    
                    Save(block, SaveDict)
                    Feedback( block, mRT, mAcc )

                    if block == 0:
                        SignalValue = int(round(np.mean(SignalContrast[-30:]))) # Changed to -30 rather than -20 during piloting
                        ConstantSignalValue = SignalValue
                    
                else:
                    if block > 0:
                        # 3-x-1 Design
                        SignalValue = range(ConstantSignalValue-NContrastLevels+2, ConstantSignalValue+2)[contrastN] 
                    else:
                        contrastN = 0
                    pre_trial_screen()
                    DrawNoisyStim( trial, BaseStim, Signal=SignalValue, mu=NoiseMu, sigma=NoiseSigma, UPDATE=True )
                    wait_time(Stim_Display_Time) # Non-Response Interval
                    DisplayMask(MaskD, FigSize)
                    wait_time(Mask_Time) # Mask Display
                    DrawWheel(LoadedStimList=StimList) # RTI begins
                    if JOYSTICK == []:
                        Signal = MouseResponse( trial, block, InnerRadius, RT, Acc, RspList, AngleList, MouseList, Signal=SignalValue, MouseStart=MovementOnset, MotionRT=TimeInMotion )
                    else:
                        JoystickResponse( trial, block, InnerRadius, RT, Acc, RspList, AngleList, MouseList )

                    CndList.append( trial )
                    SignalContrast.append(SignalValue)
                    ContrastListN.append( contrastN )
                    SignalValue = Signal
コード例 #29
0
ファイル: OmniTank_menu.py プロジェクト: Bredgren/OmniTank
def menu():
    pygame.init()
    Rect = screen.get_rect()
    pygame.mouse.set_visible(True)

    top = (367, 311)
    second = (367, 363)
    third = (367, 413)
    bottom = (367, 465)
    x_left = 367
    x_right = 657
    selection = ''
    playsound = False
    running = True
    mus_pause = False

    #images
    selectionbar_file_name = os.path.join("img","selection_outline.png")
    outline = pygame.image.load(selectionbar_file_name)

    icon_img = os.path.join("img", "icon.png")
    icon = pygame.image.load(icon_img)
    pygame.display.set_icon(icon)

    # Create background
    returnscreen()

    # Load sounds
    roll_over_sound = load_sound('menu_rollover.wav')
    click_sound = load_sound('menu_click.wav')

    #load/start music
    pygame.mixer.music.load(os.path.join('snd', 'Mechanolith.mp3'))
    pygame.mixer.music.play(-1)

    all = pygame.sprite.RenderUpdates()

    MenuOutline.containers = all

    while running:
        time_passed = clock.tick(60)

        in_box1 = (pygame.mouse.get_pos()[0] <= x_right and
                   pygame.mouse.get_pos()[0] >= x_left and
                   pygame.mouse.get_pos()[1] <= 351 and
                   pygame.mouse.get_pos()[1] >= 311)
        in_box2 = (pygame.mouse.get_pos()[0] <= x_right and
                   pygame.mouse.get_pos()[0] >= x_left and
                   pygame.mouse.get_pos()[1] <= 402 and
                   pygame.mouse.get_pos()[1] >= 363)
        in_box3 = (pygame.mouse.get_pos()[0] <= x_right and
                   pygame.mouse.get_pos()[0] >= x_left and
                   pygame.mouse.get_pos()[1] <= 452 and
                   pygame.mouse.get_pos()[1] >= 413)
        in_box4 = (pygame.mouse.get_pos()[0] <= x_right and
                   pygame.mouse.get_pos()[0] >= x_left and
                   pygame.mouse.get_pos()[1] <= 505 and
                   pygame.mouse.get_pos()[1] >= 465)
        # Sound
        if (in_box1 or in_box2 or in_box3 or in_box4) and playsound:
            roll_over_sound.play()
            playsound = False
        if not (in_box1 or in_box2 or in_box3 or in_box4):
            playsound = True


        # User Input
        for event in pygame.event.get():
            if in_box1:
                MenuOutline(top, outline, x_right, x_left, 351, 311)
                selection = 'start game'
            elif in_box2:
                MenuOutline(second, outline, x_right, x_left, 402, 363)
                selection = 'instructions'
            elif in_box3:
                MenuOutline(third, outline, x_right, x_left, 452, 413)
                selection = 'highscores'
            elif in_box4:
                MenuOutline(bottom, outline, x_right, x_left, 505, 465)
                selection = 'quit'
            else:
                selection = ''
            if event.type == MOUSEBUTTONDOWN:
                if selection == 'start game':
                    click_sound.play()
                    game = color_choice.color_choice()
                    returnscreen()
                elif selection == 'instructions':
                    click_sound.play()
                    instructions = Instructions.instructions()
                    returnscreen()
                elif selection == 'highscores':
                    click_sound.play()
                    highscores = Highscores.highscores(None, 0)
                    returnscreen()
                elif selection == 'quit':
                    click_sound.play()
                    pygame.time.delay(300)
                    running = False
            if event.type == KEYDOWN:
                if event.key == K_m:
                    if mus_pause:
                        mus_pause = False
                        pygame.mixer.music.unpause()
                    else:
                        mus_pause = True
                        pygame.mixer.music.pause()

        all.clear(screen, background)
        all.update()
        dirty = all.draw(screen)
        pygame.display.update(dirty)

    sys.exit(0)
コード例 #30
0
 def showInstructions(self):
     Instructions(self)
コード例 #31
0
eventRecorder = Data_Handler(savePath)
eventRecorder.Competitive = expInfo['Competitive']
games = Game(window, savePath, eventRecorder)

if expInfo['Restart?'] != 'No':
    restart = True

else: # dont want to restart (broke during tutorial)
    if expInfo['skipIntro'] == 'No': # do want to skip intro
        if 'Temp' in os.listdir(os.path.expanduser('~') + '/Desktop'):
            shutil.rmtree(savePath)
            print 'here'
    os.mkdir(savePath) # if subject did not restart, make a new temporary savepath dir.
    restart = False

    Instructions.Run_AllIntro(window, savePath,expInfo['skipIntro'],expInfo['Competitive'])
    games.window.flip()
    # Wait for main experiment to begin and tell server ready to play.
    visual.TextStim(win = window, text = 'Please wait while all participants ' +
                    'complete the instructions.\n\nThe game will begin shortly.').draw()
    games.window.flip()
    gamesock.sendto(expInfo['ContactID']+'-'+expInfo['Computer'],Mother)
    gamesock.setblocking(1)
    # When task begins server sends the subject their ID.
    SubjID = gamesock.recvfrom(100)[0]
    eventRecorder.clock.reset()

#___________________________________ LET THE GAMES BEGIN ___________________________________
while 1:
    # Ask for new game
    if restart:
コード例 #32
0
BetweenText = []
txt = 'This is the end of the first round of tasks. There will be two more rounds similar to this one. \n\n'
#txt += 'In the "DOES IT HAVE MEANING?" task, please respond as quickly as possible. '
#txt += '\n\nThe Q key will always correspond to "' + responses[0] 
#txt += '" and the P key to "' + responses[1] + '". Make sure your index fingers rest on these keys.\n\n'
txt += 'Take a short break if you want to. Press any key to continue to the next block of the experiment.'
BetweenText.append(txt)
txt = 'This is the end of the second round of tasks. There will be one more round similar to this one. \n\n'
#txt += 'In the "DOES IT HAVE MEANING?" task, please respond as quickly as possible. '
#txt += '\n\nThe Q key will always correspond to "' + responses[0] 
#txt += '" and the P key to "' + responses[1] + '". Make sure your index fingers rest on these keys.\n\n'
txt += 'Take a short break if you want to. Press any key to continue to the next block of the experiment.'
BetweenText.append(txt)

instr = Instructions.Instructions(myWin,responses)
instr.Run()

for tsk in range(3):
    if tsk == 1:
        # priming
        instructions.setText(ImageReelText)
        instructions.draw()
        myWin.flip()
        event.waitKeys()
        myWin.flip()
        #core.wait(interTaskTime-.5)
        #myWin.flip()
        core.wait(0.5)
        task = ImageReelTask.Task(myWin,"Files/images/" + imageFolders[taskOrder[tsk]-1])
    else: