當前位置: 首頁>>代碼示例>>Python>>正文


Python score.Score類代碼示例

本文整理匯總了Python中score.Score的典型用法代碼示例。如果您正苦於以下問題:Python Score類的具體用法?Python Score怎麽用?Python Score使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Score類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: new_game

 def new_game(cls, player):
     """Creates and returns a new game"""
     # 'player' is actually a user.key value for the
     # relationship (KeyProperty) to the user entity
     # pacific=timezone('US/Pacific')
     now = datetime.datetime.now()
     game = Game(player=player)
     # print ('\nNew game object is :' + str(game) + '\n')
     # set up the score record
     game_key = game.put()
     score = Score(
         game_key=game_key,
         player=player,
         start_date=now,
         end_date=now,
         move_count=0,
         parent=game.key)
     score_key = score.put()
     game.score_key = score_key
     # set up the move records
     move_record = (Move(game_key=game_key))
     move_record_key = move_record.put()
     # print move_record_key
     move_record_keys = []
     move_record_keys.append(move_record_key)
     game.move_record_keys = move_record_keys
     # set the game number
     game.game_number = game.get_max_game_number(player) + 1
     game.put()
     return game
開發者ID:jdelaney44,項目名稱:fsndp4-tic-tac-toe-01,代碼行數:30,代碼來源:game.py

示例2: TestScore

class TestScore(unittest.TestCase):
    def setUp(self):
        self.score = Score()

    def test_initial_score(self):
        self.assertEqual(0, self.score.player1)
        self.assertEqual(0, self.score.player2)

    def test_inc_play2(self):
        ball = Ball()
        ball.position['x'] = -1
        self.score.check_score(ball)
        self.assertEqual(0, self.score.player1)
        self.assertEqual(1, self.score.player2)
        self.checkFinalPosition(ball)

    def checkFinalPosition(self, ball):
        final_position = constants.SCREEN_WIDTH / 2 - ball.dimension['width'] / 2
        self.assertEqual(final_position, ball.position['x'])

    def test_inc_play1(self):
        ball = Ball()
        ball.position['x'] = constants.SCREEN_WIDTH + 1
        self.score.check_score(ball)
        self.assertEqual(1, self.score.player1)
        self.assertEqual(0, self.score.player2)
        self.checkFinalPosition(ball)
開發者ID:rtouze,項目名稱:yapong,代碼行數:27,代碼來源:test_score.py

示例3: testgetTimeScore

 def testgetTimeScore(self):
   'Test if getTimeScore will return the correct time score for 3 instances'
   get1 = Score()
   finish1 = True
   time1 = 1000
   self.assertEqual(get1.getTimeScore(time1,finish1),0)
   get2 = Score()
   time2 = 290
   self.failIf(get2.getTimeScore(time2,finish1) == 0)
開發者ID:EliasJonsson,項目名稱:Golf-Solitaire,代碼行數:9,代碼來源:test_golfkapall.py

示例4: get_score_for_patient

def get_score_for_patient(p):
    total = 0
    count = 0
    for m in Medicine.objects.filter(treatments__patient=p).distinct():
        r = RecurringTreatment.objects.get(patient = p, medicine = m)
        pt = PillTaken.objects.filter(patient = p, medicine = m)
        s = Score()
        total = total + s.translate(r, pt)
        count = count + 1
    total = ceil(total / count)if count > 0 else 0
    return total
開發者ID:lucaskt,項目名稱:blahalahabla,代碼行數:11,代碼來源:views.py

示例5: main

def main():
    WINDOW_WIDTH = 640
    WINDOW_HEIGHT = 480
    bulletArray = []
    enemyArray = []

    pygame.init()
    screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
    pygame.display.set_caption('CARNAPITON')
    pygame.mouse.set_visible(1)
    clock = pygame.time.Clock()
    clock.tick(60)

    grass = pygame.image.load("images/FONDO2.png")

    s = Score()
    p = Player(WINDOW_WIDTH, WINDOW_HEIGHT)
    ec = Controller(s)

    while 1:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                return
            p.manageEvent(event, bulletArray)

        screen.blit(grass, (0, 0))

        s.draw(screen)
        p.update(clock.get_time())

        for bullet in bulletArray:
            if bullet.isDestroyed:
                bulletArray.remove(bullet)
                continue
            bullet.update()

        for bullet in bulletArray:
            bullet.draw(screen)

        for e in enemyArray:
            e.update(p, clock.get_time())

        for e in enemyArray:
            e.draw(screen)

        ec.execute(WINDOW_WIDTH, WINDOW_HEIGHT, enemyArray, bulletArray, clock.get_time())

        p.draw(screen)

        pygame.display.flip()
開發者ID:MatiasIac,項目名稱:millenialGJ,代碼行數:51,代碼來源:main.py

示例6: _setup_score

    def _setup_score(self):
        """
        Sets up the score object

        """
        from score import Score
        self.score = Score(self.background)
開發者ID:pielgrzym,項目名稱:pung,代碼行數:7,代碼來源:views.py

示例7: record_score

    def record_score(self, aggregate_data):
        score = Score.query().filter(Score.user == self.user).get()
        if score:
            score.score += aggregate_data[0]
            score.num_correct += aggregate_data[1]
            score.num_incorrect += aggregate_data[2]
            score.clues_used += aggregate_data[3]
        else:
            score = Score(user=self.user,
                          score=aggregate_data[0],
                          num_correct=aggregate_data[1],
                          num_incorrect=aggregate_data[2],
                          clues_used=aggregate_data[3])

        score.put()
        return score
開發者ID:CurtiePi,項目名稱:triviagame,代碼行數:16,代碼來源:triviagame.py

示例8: finish_game

    def finish_game(self):
        """Finish the game - user successfully finished the game."""
        self.finished = True
        self.put()

        # Update user score
        user = self.user.get()
        user.finished_game(self.score)

        # Add the game to the score 'board'
        score = Score(user=self.user,
                      date=date.today(),
                      attempts_done=self.attempts_done,
                      card_cnt=self.card_cnt,
                      score=self.score)
        score.put()
開發者ID:TomMuehlegger,項目名稱:full_stack_web_developer,代碼行數:16,代碼來源:game.py

示例9: __init__

    def __init__(self):
        super(MenuManager, self).__init__()

        self.contentsDoc = None
        self.assistantProcess = QtCore.QProcess()
        self.helpRootUrl = ''
        self.docDir = QtCore.QDir()
        self.imgDir = QtCore.QDir()

        self.info = {}
        self.window = None
        self.qmlRoot = None
        self.declarativeEngine = None

        self.ticker = None
        self.tickerInAnim = None
        self.upButton = None
        self.downButton = None
        self.helpEngine = None
        self.score = Score()
        self.currentMenu = "[no menu visible]"
        self.currentCategory = "[no category visible]"
        self.currentMenuButtons = "[no menu buttons visible]"
        self.currentInfo = "[no info visible]"
        self.currentMenuCode = -1
        self.readXmlDocument()
        self.initHelpEngine()
開發者ID:CapB1ack,項目名稱:PyQt4,代碼行數:27,代碼來源:menumanager.py

示例10: __init__

 def __init__(self):
     pygame.mixer.pre_init(48000,-16,2, 1024) #Sound Settings
     pygame.init()
     
     #sets the screen resolution for the game and sets a rect for the game screen
     self.screen = pygame.display.set_mode((1024,768))
     self.screen_rect = self.screen.get_rect()
     
     #initializes a clock for the game
     self.clock = pygame.time.Clock()
     
     #initializes a menu object and HUD object and Score object
     self.menu = Menu()
     self.hud = Hud()
     self.score = Score()
     #sets a boolean for whether you are still in the menu or not
     self.inMenu = True
     #sets a camera for the world
     self.camBorder = 32
     self.cam = Camera(pygame.Rect(100, 100, 1024, 768), pygame.Rect(self.camBorder, self.camBorder, 2048 - self.camBorder, 1536 - self.camBorder))
     self.camShakeFactor = 0 #Magnitude of shake
     self.camShakeDecayFactor = 0.08 #Lerp Amount
     
     #Timing
     self.timer = pygame.time.get_ticks()
     self.elapsed = 0
     
     #Sound Controller
     self.soundCon = SoundCon()
     
     #Game Values
     self.backgroundImg = pygame.image.load("Images/Arena/Arena2.png").convert_alpha()
     self.backgroundImgRect = self.backgroundImg.get_rect()
     self.player = Player( self.hud )
     
     #Effects
     self.effectInstances = []
     self.spawnSound = pygame.mixer.Sound("Sounds/ShipRev.wav")
     self.deathSound = pygame.mixer.Sound("Sounds/shipExplo.wav")
     self.enemyExplo = pygame.mixer.Sound("Sounds/enemyExplo.wav")
     self.clashSound = pygame.mixer.Sound("Sounds/clash.wav")
     self.boostSound = pygame.mixer.Sound("Sounds/boostLow.wav")
     
     #Game over fade out
     self.fadeImage = pygame.image.load("Images/HUD/CrackedGlass.png").convert_alpha()
     self.fadeRect = self.fadeImage.get_rect()
     self.fadeSurface = pygame.Surface((1024, 768), pygame.SRCALPHA)
     self.fadeSurfaceAlpha = 0
     self.fadeSurfaceRate = 1
     self.doFade = False
     self.restartGame = False
     
     #Enemies
     self.enemyList = []
     self.baseNumEnemies = 2
     self.spawnTime = 10
     self.currentSpawnTime = 30
開發者ID:BrettMcNeff,項目名稱:TBA,代碼行數:57,代碼來源:game.py

示例11: __init__

 def __init__(self, **kwargs):
     """Game class initializer. Initializes the temporary grid.
     """
     super(Game, self).__init__()
     self.grid = [[None for i in range(GRID_SIZE)] for j in range(GRID_SIZE)]
     self.letter_grid = LetterGrid(GRID_SIZE)
     self.score = Score()
     self.level = Level()
     self.io = MeowDatabase()
開發者ID:enchanter,項目名稱:meow_letters,代碼行數:9,代碼來源:main.py

示例12: delete_duplicates

	def delete_duplicates( self, control, location ):
		scores = Score.all().filter( "control =", control )
		
		if not location in ( config.LOCATION_WORLD, config.LOCATION_WEEK ):
			scores = scores.filter( "location =", location )
		
		elif location == config.LOCATION_WEEK:
			scores = scores.filter( "new_week =", True )
		elif location != config.LOCATION_WORLD:
			logging.error( "CronJob.delete_duplicates: Got an invalid " \
				+ "location \"%s\".", location )
			return
		
		fetched = scores.order( "-points" ).fetch( config.TOP_LIST_LENGTH )
		fetched = sorted( fetched, key=lambda score: score.date )
		
		to_remove = []
		i = 0
		while i < len( fetched ):
			scorei = fetched[i]
			j = i+1
			while j < len( fetched ):
				scorej = fetched[j]
				if not scorei is scorej and scorei.equals( scorej ) \
						and not scorej in to_remove:
					to_remove.append( scorej )
				j += 1
			i += 1
		
		have = [ score.to_dict() for score in fetched ]
		logging.info( "Location: \"%s\" Have %d scores: %s", location,
			len( have ), have )
		
		would = [ score.to_dict() for score in to_remove ]
		logging.info( "Location: \"%s\"Would remove %d scores: %s", location,
			len( would ), would )
		
		count1 = 0
		for score in to_remove:
			if score in fetched:
				count1 += 1
		
		count2 = 0
		for score in fetched:
			if score in to_remove:
				count2 += 1
		
		logging.info( "count1: %d, count2: %d", count1, count2 )
		
		try:
			db.delete( to_remove )
			self.response.out.write(
				"<br />all entities deleted successfully." )
		except Exception, msg:
			self.response.out.write( "<br />Got exception: '%s'." % msg \
				+ "<br />Some or all deletes might have failed." )
開發者ID:baskus,項目名稱:prendo,代碼行數:56,代碼來源:cronjob.py

示例13: ponderateFrequencyMatrix

def ponderateFrequencyMatrix(groups):
    """
    Return the weighted matrix for the groups
    """
    matrix = Score()
    length = len(groups[0][0])
    for i in range(length):
        for iGroup, group in enumerate(groups):
            for seq in group:
                aa1 = seq[i]
                for iOtherGroup, otherGroup in enumerate(groups):
                    if iGroup != iOtherGroup:
                        for otherSeq in otherGroup:
                            aa2 = otherSeq[i]
                            freq = (1 / len(group)) * (1 / len(otherGroup))
                            if aa1 == aa2:
                                freq = freq / 2
                            matrix[aa1, aa2] = matrix.get((aa1, aa2), 0) + freq
    return matrix
開發者ID:etnarek,項目名稱:info-f-208,代碼行數:19,代碼來源:blosum.py

示例14: score_game

    def score_game(self, winner, penalty_winner, penalty_loser):
        """ Set up Score for Game """
        if winner == self.player_one:
            loser = self.player_two
        else:
            loser = self.player_one
        # Add the game to the score 'board'
        score = Score(date=date.today(),
                      game=self.key,
                      winner=winner,
                      loser=loser,
                      penalty_winner=penalty_winner,
                      penalty_loser=penalty_loser)
        score.put()

        # Update the user models
        winner.get().add_win()
        loser.get().add_loss()
        return
開發者ID:jlyden,項目名稱:straight-gin,代碼行數:19,代碼來源:game.py

示例15: create_evaluation

    def create_evaluation(self, reading_system):
        "Create and return a new evaluation, along with an initialized set of result objects."
        from test import Test
        from score import Score
        from result import Result
        from category import Category
        from testsuite import TestSuite

        testsuite = TestSuite.objects.get_most_recent_testsuite()
        print "Creating evaluation for testsuite {0}".format(testsuite.version_date)
        tests = Test.objects.filter(testsuite = testsuite)

        evaluation = self.create(
            testsuite = testsuite,
            last_updated = generate_timestamp(),
            percent_complete = 0.00,
            reading_system = reading_system
        )
        evaluation.save()
        
        total_score = Score(category = None, evaluation = evaluation)
        total_score.save()

        # create results for this evaluation
        for t in tests:
            result = Result(test = t, evaluation = evaluation, result = RESULT_NOT_ANSWERED)
            result.save()

        # update the score once results have been created
        total_score.update(evaluation.get_all_results())

        # create category score entries for this evaluation
        categories = Category.objects.filter(testsuite = evaluation.testsuite)
        for cat in categories:
            score = Score(
                category = cat,
                evaluation = evaluation
            )
            score.update(evaluation.get_category_results(cat))
            score.save()

        return evaluation
開發者ID:j-a-vizcaino,項目名稱:epubtestweb,代碼行數:42,代碼來源:evaluation.py


注:本文中的score.Score類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。