コード例 #1
0
ファイル: game.py プロジェクト: SophiaP11/CAAP-CS
def game_over(won, difficulty):
    global name
    global moves
    global leaderboard
    time = str(date.now())
    score = Score(name, moves, time)
    #sends the players name, score, and time finished to the score class so the data can be manipulated later by the leaderboard.
    if won == True:
        print("You won!")
    else:
        print ("\nOH NO! You ran out of lives!")
    #Lets the player know if they won or why they lost
    moves = score.get_score()
    #gets the most recent score/moves of the player
    if won == True:
        leaderboard.update(score)
    moves = moves-(difficulty*100)
    #changes the value of moves to reflect the actual amount of moves they made and not their total score(lives included)
    print ("Choices made:", moves)
    #Tells the player how many choices they made and lets them know the game has ended.
    print ("\n\t\tGAME OVER.\n")
    leaderboard.print_board()
    #prints the leaderboard
    leaderboard.saving_leaderboard()
    #saves the current leaderboard outside of the game program so that it can be called back when the game program is restarted 
    name = ""
    moves = 0
    print ("\n*************************************************************\n")
コード例 #2
0
    def gameover(self, timeout=False):
        """Stop the game and display score windows."""

        # -1 to not include failed level
        points = max(len(self.sequence) - 1, 0)

        self.stop_game(0)

        if timeout:
            self.play_error_sound()

        # Remove default blank score if it's there
        for s in self.scores.copy():
            if s.date == 'N/A':
                self.scores.remove(s)

        # Add new score to list of scores
        name = fl_input(f'GAME OVER - SCORE {points}\nEnter your name:',
                        'Anonymous')
        date = datetime.now().strftime('%d/%m/%Y %H:%M:%S')

        if name is not None:
            score = Score(points, name or 'Anonymous', date)
            self.scores.append(score)
            self.scores.sort(key=lambda s: s.value, reverse=True)

            self.view_scores(0, self.scores.index(score) + 2)

        # User pressed cancel or escaped/closed, give them a chance to save score
        else:
            # Don't ask for confirmation if it's a low score
            if points > 2:
                choice = fl_choice(
                    f'Are you sure you want to throw out your score of {points}?',
                    'Yes', 'No', None)

                if not choice or choice is None:  # Clicked yes or closed/escaped
                    # Add back that default score
                    self.scores.append(Score())
                    self.view_scores(0)

                else:  # Clicked no, save score
                    name = fl_input('LAST CHANCE!\nEnter your name:',
                                    'Anonymous')
                    score = Score(points, name or 'Anonymous', date)
                    self.scores.append(score)
                    self.scores.sort(key=lambda s: s.value, reverse=True)

                    self.view_scores(0, self.scores.index(score) + 2)

            else:
                self.view_scores(0)
コード例 #3
0
ファイル: dart-stats.py プロジェクト: jonsimonsen/Dart-stats
    def addObject(self):
        """Class specific helper for the add method that does the actual creation of a new score object."""

        darts = []
        newDart = None

        for i in range(1, 4):
            print('Creating dart ' + str(i))
            #Ask for multiplier
            mul = getPosInt('multiplier', 3)
            if mul == 0:
                newDart = Dart(0, 0)
            elif mul == 2 or mul == 3:
                #Ask for points
                points = getPosInt('points', 20, False)
                newDart = Dart(mul, points)
            elif mul == 1:
                valid = False
                while not valid:
                    points = getPosInt('points', 50)
                    if points <= 20 or points == 25 or points == 50:
                        valid = True
                newDart = Dart(mul, points)

            darts.append(newDart)
            print('Dart created')

        return Score(darts[0], darts[1], darts[2])
コード例 #4
0
ファイル: game.py プロジェクト: ctetrick/CAAP-CS
def game_over(won):
	global name
	global moves
	score = Score(name, moves)
	raise ValueError ('todo')
	print ("\nGame Over.")
	raise ValueError ('todo')
コード例 #5
0
def game_over(won):
    global name
    global moves
    score = Score(name, moves)
    if won:
        leaderboard.update(score)
    print("\nGame Over.")
    leaderboard.print_board()
コード例 #6
0
def game_over(won):
    global name
    global moves
    global leaderboard
    score = Score(name, moves)
    if won == True:
        print("Moves:", moves)
        print("You won")
        score = Score(name, moves)
        if leaderboard.update(score) == True:
            leaderboard.insert(score)

    else:
        print("\nGame Over.")
        moves = 0
        name = ""
    leaderboard.print_board()
コード例 #7
0
def game_over(won):
    global name
    global moves
    score = Score(name, moves)

    if (won):
        leaderboard.update(score)
        print("\nYou won")
        leaderboard.print_board()
コード例 #8
0
 def load_leaderboard(self):
     with open('leaderboard_save.txt','r') as json_file:
         data = json.load(json_file)
         for i in range(len(data)):
             player_data = data[str(i)]
             name = player_data[1]
             moves = player_data[0]
             score = Score(name, moves)
             self.board.append(score)
コード例 #9
0
ファイル: leaderboard.py プロジェクト: SophiaP11/CAAP-CS
 def loading_leaderboard(self):
     #loads a leaderboard from previous game play to use for the current game
     leaderboardfile = open("saved_leaderboard.txt", "r")
     sleaderboard = leaderboardfile.read().splitlines()
     for line in sleaderboard:
         name, moves, date, time = line.split(" ")
         score = Score(name, moves, str(date + " " + time))
         self.board.append(score)
     self.size = len(sleaderboard)
コード例 #10
0
ファイル: game.py プロジェクト: rabisnath/CAAP-CS
def game_over(won):
	global name
	global moves
	score = Score(name, moves)
	leaderboard.update(score)
	if (won):
		print("\nYou Won!")
	else:
		print ("\nGame Over. Better luck next time.")
	leaderboard.print_board()
コード例 #11
0
ファイル: game.py プロジェクト: ctetrick/CAAP-CS
def game_over(won):
    global name
    global moves
    score = Score(name, moves)
    # ***************************************************
    # FIX You should only update if the won (goes inside the if statement)
    # *************************************************
    leaderboard.update(score)
    if (won):
        print("\nYou Won!")
    leaderboard.print_board()
コード例 #12
0
ファイル: game.py プロジェクト: iyoussou/CAAP-CS
def game_over(won):
    global name
    global moves
    score = Score(name, moves)
    if won == True:
        print("You won!")
        leaderboard.update(score)
    print("\nGame Over.")
    leaderboard.print_board()
    moves = 0
    name = ""
コード例 #13
0
ファイル: game.py プロジェクト: navila-luna/CAAP-CS
def game_over(won):
    global name
    global moves
    score = Score(name, moves)
    if won:
        leaderboard.update(score)
        print("CONGRATULATIONS, YOU WON!! WE LOVE YOU")
        print("\nGame Over")
    else:
        print("\nGame Over")

    name = ''
    moves = 0
    leaderboard.print_board()
コード例 #14
0
ファイル: game.py プロジェクト: bwstarr/CAAP-CS
def game_over(won):
    global name
    global moves
    score = Score(name, moves, difficulty)
    if won:
        leaderboard.update(score)  #we could wrap insert in update

    print("\nGame Over.")
    name = ""
    moves = 0
    num = eval(
        input("How Many Top Scores do you wish to see? (100 is the max)")
    )  #***if the game saves the leaderboard after it ends, extra credit.
    leaderboard.print_board(num)  #indention matters, everything is contained
コード例 #15
0
def game_over(won):
    global name
    global moves
    global leaderboard  #score = Score(name, moves)
    print("\n Game over!")

    if won:
        print(moves, "moves")
        print("name", name)
        score = Score(name, moves)
        if leaderboard.update(score):
            leaderboard.insert(score)
    else:
        moves = 0
        name = ""
    leaderboard.print_board()
コード例 #16
0
ファイル: game.py プロジェクト: arlethzuri/CAAP-CS
def game_over(won):
    global name
    global moves
    score = Score(name, moves)
    if won:
        print(
            "\nAt last you made it home! You brush your teeth, shower, then finally lie in bed and fall fast asleep."
        )
        print("\nGame Over. Congrats, " + name + ", you won! It took you",
              moves, "moves.")
        leaderboard.update(score)
    else:
        print("\nGame Over. Sorry, " + name + ", maybe try again yeah?")
    print("\n")
    name = ''
    moves = 0
    leaderboard.print_board()
コード例 #17
0
ファイル: test_scores.py プロジェクト: jonsimonsen/Dart-stats
def test_score(dart1, dart2, dart3, order, file):
    """Function for testing a score. Makes a new score for the given darts.
    Tests if they are sorted in the given order.
    order should be a list containing the three integer 1,2 and 3 and nothing else (1 meaning the dart that should be first in the sorted list).
    file should be a handle to an output file. The score will be written to this file.
    returns True if the order is correct, and False otherwise.
    """
    score = Score(dart1, dart2, dart3)
    print(str(score))
    if score.getDart(order[0]) == dart1 and score.getDart(
            order[1]) == dart2 and score.getDart(order[2]) == dart3:
        score.writeToFile(file)
        return True
    else:
        print('test failed.')
        return False
コード例 #18
0
def game_over(won):
    global name
    global moves
    global leaderboard
    # score = moves
    print(
        "================================\nGame Over\n================================"
    )
    if won == True:
        print("WINNER WINNER CHICKEN DINNER")
        print("Your moves:", moves)
        score = Score(name, moves)
        if leaderboard.update(score) == True:
            leaderboard.insert(score)

    else:
        print("You became Bigfoot's dinner!")
    leaderboard.print_board()
    names = ''
    moves = 0
コード例 #19
0
def game_over(won):
    global name
    global moves
    score = Score(name, moves)
    if won:
        print(
            "*****************************************************************"
        )
        print("Congratulations! You've WON!!!!!!!!!!!")
        leaderboard.update(score)
    else:
        print(
            "*****************************************************************"
        )
        print("GAME OVER")
    print("\nGame Over.")
    name = ""
    moves = 0
    leaderboard.leaderboard_append()
    leaderboard.print_board()
    r_multiplier = 0
コード例 #20
0
ファイル: leaderboard.py プロジェクト: diego2500garza/CAAP-SC
 def __init__(self):
     for i in range(self.size):
         here = Score('Player', 999)
         self.board.append(here)
コード例 #21
0
ファイル: all_exp.py プロジェクト: akachachi/research
        for row_index in range(sheet.nrows):
            row = sheet.row_values(row_index)
            if row[0] == query["qid"]:
                true_urls.extend(row[1:3])
        print('answer urls loaded.')
        print(true_urls)

        ##### Bing 手法 #####
        bing_qr = qr.bing_method()
        print(bing_qr)
        tf_results = []
        for query in bing_qr:
            tf_result = evaluate_results(query, true_urls, bing, stop_domains, stop_titles)
            tf_results.append(tf_result)

        bing_qr_score = Score(tf_results, query_rank, page_rank)
        bing_score["MRR"]       += bing_qr_score.for_MRR()
        bing_score["Contain"]   += bing_qr_score.for_Contain()
        bing_score["Max"]       += bing_qr_score.for_Max()
        bing_score["SDCG"]      += bing_qr_score.for_SDCG()
        query_num, page_num     = bing_qr_score.for_AvgRelNum()
        bing_score["QueryNumForARN"] += query_num
        bing_score["PageNumForARN"]  += page_num
        print('bing method end.')
        

        ##### word2vec 手法 #####
        word2vec_qr = qr.word2vec_method()
        print(word2vec_qr)
        tf_results = []
        for query in word2vec_qr:
コード例 #22
0
 def __init__(self):
     for i in range(self.size):
         name = 'player' + str(i)+': '
         moves = 9999
         score = Score(name, moves)
         self.board.append(score)
コード例 #23
0
#coding=utf-8

import csv
import os


# import nltk

# nltk.download()

from scores import Score

some_score = Score()

'''
1 - To run RECALL BY CORPUS BY COMMONALITY:
corpora = 'ByCorpus'
folder = 'ByCommonality'

2 - To run RECALL BY CORPUS BY LIST:
corpora = 'ByCorpus'
folder = 'ByList'

3 - To run RECALL BY AGE BY COMMONALITY:
corpora = 'ByAge'
folder = 'ByCommonality'

4 - To run RECALL BY AGE BY LIST:
corpora = 'ByAge'
folder = 'ByList'
'''
コード例 #24
0
def __init__(self):
    for i in range(self.size):
        self.board.append(Score("player", i))
コード例 #25
0
 def __init__(self):
     for i in range(self.size):
         name = "Bob" + str(i + 1)
         score = 99
         score = Score(name, score)
         self.board.append(score)
コード例 #26
0
ファイル: leaderboard.py プロジェクト: emilybsimon/CAAP-CS
 def __init__(self):
     for i in range(self.size):
         self.board.append(Score(str("player " + str(i)), 999))
コード例 #27
0
 def __init__(self):
     for i in range(self.size):
         name = "Player" + str(i)
         moves = 1000
         score = Score(name, moves)
         self.board.append(score)
コード例 #28
0
ファイル: game.py プロジェクト: gdelgado1/CAAP-CS
def game_over(won):
	global name
	global moves
	global difficultyl
	score = Score(name, moves)
	print ("\nGame Over...?")
コード例 #29
0
 def __init__(self):
     for i in range(1):
         self.board.append(Score("Dummy Chickens On Strike", 500, 500))
コード例 #30
0
import csv

from posTag import POSTagger
from replacers import RegexpReplacer
from scores import Score

replacer = RegexpReplacer()
tagger = POSTagger()
some_score = Score()

original_words = []
splited_words = []
splited_words_pos = []
canonical_words_pos = []

with open('input/palavras_por_lista_artigos.csv') as csvfile:
    reader = csv.DictReader(csvfile, delimiter=';')
    for row in reader:
        original_words.append((row['list'], row['word'].strip()))


splited_words = replacer.replace_all_list(original_words)
canonical_words_pos = tagger.canonicalTag(splited_words)

classeAberta = ['NN', 'NNS', 'NNP', 'NNPS', 'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ', 'JJ', 'JJR', 'JJS', 'RB', 'RBR', 'RBS']

list = []
words = []
index = canonical_words_pos[0][0]
# print(index)
コード例 #31
0
    def __init__(self, w, h, title='Simon'):
        """Initialize an instance.
        
        Width (w) and height (h) arguments should not be less than 180 and
        210 respectively.

        """

        super().__init__(w, h, title)

        # Load scores or create file if necessary
        try:
            with open('.scores.pickle', 'rb') as f:
                self.scores = pickle.load(f)

        except FileNotFoundError:
            self.scores = [
                Score(),
            ]
            self.save_scores()

        self.color(FL_BLACK)
        self.lastsize = (self.w(), self.h())

        # For keeping track of the sequence, and what the player has entered
        self.sequence = list()
        self.player_seq = list()

        # Initial timing for autoplayed notes in sequence, reset in self.stop()
        self.duration = 0.42
        self.interval = 0.08

        self.begin()

        menuitems = (('Game', 0, 0, 0, FL_SUBMENU), ('New Game', FL_F + 1,
                                                     self.new_game),
                     ('Stop Game', FL_CTRL + ord('x'), self.stop_game, 0,
                      FL_MENU_DIVIDER), ('Scores...', FL_CTRL + ord('s'),
                                         self.view_scores), (None, 0))

        # Position menu slightly off screen to only show bottom edge of box
        self.menubar = Fl_Menu_Bar(-1, -1, w + 2, 31)
        self.menubar.box(FL_BORDER_BOX)
        self.menubar.color(FL_WHITE)
        self.menubar.copy(menuitems)

        # A bit of math to figure out initial positioning of game in window
        # Minimum distance between group and win edges is 40
        dim = min(w, h - 30) - 80
        x = (w // 2) - (dim // 2)
        y = 30 + ((h - 30) // 2) - (dim // 2)

        self.but_group = But_Group(x, y, dim, dim, self)
        self.but_group.begin()

        # Figure out position of start button in center
        center_x = round(40 + (w // 2 - 40) * 0.625)
        center_y = round(70 + ((h - 30) // 2 - 40) * 0.625)
        center_w = round(((w // 2 - 40) * 0.375) * 2)
        self.start_but = StartButton(center_x, center_y, center_w, center_w,
                                     self)

        self.gamebuttons = list()

        # Create main buttons for gameplay
        corners = [(0, 0), (1, 0), (0, 1), (1, 1)]
        for i in range(4):
            corner = corners[i]

            # do this outside of gamebutton args to avoid crazy long line
            b_x = 40 + (w // 2 - 40) * corner[0]
            b_y = 70 + ((h - 30) // 2 - 40) * corner[1]
            b_w = w // 2 - 40
            b_h = (h - 30) // 2 - 40

            # Corner for figuring out position vs corner passed for detecting clicks are opposites
            self.gamebuttons.append(
                GameButton(b_x, b_y, b_w, b_h, corners[::-1][i],
                           (w // 2 - 40) * 0.4, i, self))

        self.but_group.end()

        self.end()
        self.resizable(self.but_group)

        # Buttons are deactivated untill user starts game
        self.deactivate_buts()