示例#1
0
    def __init__(self, size, caption=None, win=None):
        Window.__init__(self, size, caption, win)
        self.background = GameData.image(GET_NAME_BGD_IMG)

        button_image = GameData.image(BUTTON_IMG)
        self.ok_button = Button(GN_OK_BTN_POS, button_image, self.buttons)

        self.return_data = "NO NAME"
示例#2
0
 def handleEvent(self, event):
     if event.type == KEYDOWN:
         if event.key == K_ESCAPE:
             self.running = False
             GameData.playSound(CLICK_SFX)
     elif event.type == MOUSEBUTTONDOWN:
         if event.button == LEFT_MOUSE:
             selection = self.selectedButton()
             if selection == self.main_menu_button:
                 self.running = False
示例#3
0
 def _handleInput(self):
     for event in pygame.event.get():
         if event.type == QUIT:
             sys.exit(0)
         elif event.type == KEYDOWN:
             if event.key == K_m:
                 GameData.toggleMusic()
         elif event.type == MOUSEBUTTONDOWN:
             if event.button == LEFT_MOUSE and self.selectedButton():
                 GameData.playSound(CLICK_SFX)
         self.handleEvent(event)
示例#4
0
    def _update(self, time_passed):
        pre_selected = self.selectedButton()
            
        self.buttons.update()
        
        post_selected = self.selectedButton()
            
        # Play sound when the mouse enters a button or enters a different button
        if post_selected and pre_selected != post_selected:
            GameData.playSound(ROLLOVER_SFX)

        self.update(time_passed)
def main():
    #import bogota.data
    options = DEFAULT_OPTIONS
    print 'Getting Data'
    #data = get_data(bogota.data.cn_all9, 0, normalise=50., seed=101)
    data = GameData('./all9.csv', 50.)
    train_data, test_data = data.train_test(0, seed=101)
    perf, par = train(
        options,
        [train_data.datalist(), test_data.datalist()], False)
    for k, v in par.iteritems():
        print k
        print v
示例#6
0
    def __init__(self):
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        self.connectionList = []
        self.gameData = GameData()
        self.calculationThread = GameCalculationThread(self.gameData)
        self.calculationThread.start()
示例#7
0
 def __init__(self):
     self.socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
     self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     
     self.connectionList = []
     self.gameData = GameData()
     self.calculationThread = GameCalculationThread( self.gameData, self.connectionList )
     self.calculationThread.start() 
示例#8
0
    def fold_function(k):  # k is the fold index
        data = GameData('./all9.csv', 50.)
        train_data, test_data = data.train_test(k, seed=seed)

        options['fold'] = k
        llk, best_par = train(options,
                              [train_data.datalist(),
                               test_data.datalist()], False)

        print "LLK: ", llk

        for kk, vv in best_par.items():
            temp = vv.tolist()
            del best_par[kk]
            best_par[kk] = temp
        log_fold(best_loss_filename, llk, k, options.get('model_seed', -99))

        with open(par_file % k, 'w') as f:
            json.dump(best_par, f)
示例#9
0
 def handleEvent(self, event):
     if event.type == KEYDOWN:
         if event.key == K_ESCAPE:
             self.running = False
             GameData.playSound(CLICK_SFX)
     elif event.type == MOUSEBUTTONDOWN:
         if event.button == LEFT_MOUSE:
             selection = self.selectedButton()
             self.delay() # Don't switch menus instantly
             if selection == self.start_button:
                 #color = self.color_choice_window.run()
                 #level, points = self.game_window.run(color)
                 #self.high_scores_window.run(level, points)
                 pass
             elif selection == self.instructions_button:
                 self.instructions_window.run()
             elif selection == self.highscores_button:
                 temp_level = 19 #TODO: remove when done testing
                 temp_points = 2
                 self.high_scores_window.run(temp_level, temp_points)
             elif selection == self.quit_button:
                 self.running = False
             # Must reset caption if another window changed it
             pygame.display.set_caption(self.caption)
示例#10
0
    def __init__(self, size, caption, other_window=None):
        if other_window:
            self.screen = other_window.screen
            self.clock = other_window.clock
        else:
            self.screen = pygame.display.set_mode(size)
            self.clock = pygame.time.Clock()

        self.caption = caption
        pygame.display.set_icon(GameData.image(ICON_IMG))
        
        self.fps = FPS
        self.running = True
        self.buttons = pygame.sprite.LayeredDirty()

        # This is returned by the run method
        self.return_data = None
示例#11
0
    def __init__(self, size, caption=None):
        Window.__init__(self, size, 'OmniTank Menu')
        self.background = GameData.image(MAIN_BGD_IMG)

        button_image = GameData.image(BUTTON_IMG)
        self.start_button = Button(MM_START_BTN_POS, button_image, self.buttons)
        self.instructions_button = Button(MM_INSTUC_BTN_POS, button_image, self.buttons)
        self.highscores_button = Button(MM_SCORES_BTN_POS, button_image, self.buttons)
        self.quit_button = Button(MM_QUIT_BTN_POS, button_image, self.buttons)

        self.instructions_window = InstructionsWindow(size, 'OmniTank Instructions', self)
        self.high_scores_window = HighScoresWindow(size, 'OmniTank High Scores', self)
        #self.color_choice_window = ColorChoiceWindow(size, 'OmniTank Color Choice', self)

        GameData.setMusicVolume(MUSIC_VOLUME)
        GameData.startMusic(BGD_MUSIC)
示例#12
0
    def __init__(self, size, caption=None, win=None):
        Window.__init__(self, size, caption, win)
        self.background = GameData.image(INSTRUCTIONS_BGD_IMG)

        button_image = GameData.image(BUTTON_IMG)
        self.main_menu_button = Button(I_RETURN_BTN_POS, button_image, self.buttons)
示例#13
0
from question_model import Question
from data import GameData
from quiz_brain import QuizBrain
from ui import QuizInterface

question_data = GameData().get_params()

question_bank = []
for question in question_data:
    question_text = question["question"]
    question_answer = question["correct_answer"]
    new_question = Question(question_text, question_answer)
    question_bank.append(new_question)

quiz = QuizBrain(question_bank)
quiz_ui = QuizInterface(quiz)