示例#1
0
    def play_card(self, card_idx):
        card = self.hands[self.curr_player_idx][card_idx]
        self.n_cards[self.curr_player_idx] -= 1
        self.hands[self.curr_player_idx] = np.concatenate(
            (np.delete(self.hands[self.curr_player_idx],
                       card_idx), np.array([-1])))

        if self.card_playable(card):
            self.table[util.number_idx(card), util.color_idx(card)] += 1
            self.score += 1
            if util.number(card) == util.MAX_NUMBER:
                self.gain_clue()
            for player_idx in range(self.n_players):
                rel_player_idx = util.player_idx_glob2rel(
                    self.curr_player_idx, player_idx, self.n_players)
                self.players[player_idx].valid_card_played(
                    rel_player_idx, card_idx, card, self.n_clues)
        else:
            self.n_fuses -= 1
            self.discards[util.number_idx(card), util.color_idx(card)] += 1
            for tell_player_idx in range(self.n_players):
                rel_player_idx = util.player_idx_glob2rel(
                    self.curr_player_idx, tell_player_idx, self.n_players)
                self.players[tell_player_idx].invalid_card_played(
                    rel_player_idx, card_idx, card, self.n_fuses)

        logging.debug(disp.play2str(self.curr_player_idx, card_idx, card))
        self.deal_card(self.curr_player_idx)

        return
示例#2
0
 def printCSV(self):
     
     with open('preds.csv', 'w') as csv_file:
         for sid in self.dict.keys():
             for row in range(len(self.dict[sid])):
                 string = ""
                 for pred in range(len(self.dict[sid][row]['a'])):
                     tag = self.dict[sid][row]['a'][pred]
                     if util.number(tag):
                         string + str(tag) + ","
                     else:
                         string += str(self.tagdict[tag]) + ","
                 string = string[:-1]
                 string += '\n'
                 csv_file.write(string)
示例#3
0
文件: game.py 项目: Bubu/LD24
    def __init__(self):
        pygame.mixer.pre_init(22050, -16, 2, 256)
        pygame.init()
        self.screen = pygame.display.set_mode((800, 600), 0, 32)
        pygame.display.set_caption('Evolution of a Planet')
        if INTRO == True:
            self.intro = number(0)
            self.tutorial = number(-1)
            self.game = number(-1)
        else:
            self.intro = number(-1)
            self.tutorial = number(-1)
            self.game = number(1)
        self.scenes = [self.intro, self.tutorial, self.game]
        self.sceneText = {self.intro: T_intro, self.tutorial: T_tutorial}
        self.currentScene = 0
        self.pickup = None
        self.middleAreas = [MiddleArea(200,300+VERT_OFFSET,120),MiddleArea(800-200, 300+VERT_OFFSET, 120)]
        self.reactants = []
        self.products = []
        TextProvider.init()

        self.clock = pygame.time.Clock()

        self.generateElements()
        self.generateElementBar()
        self.sprites = copy.copy(self.activeElements) # sprites = clickable elements
        
        self.pages = [Page(1, self.activeElements, self),Page(2, [], self)]
        self.activePage = self.pages[0]
        self.sprites  = self.sprites + copy.copy(self.pages)
        self.song = 0
        pygame.mixer.music.load(PATH + MUSIC[self.song])
        pygame.mixer.music.set_endevent(MUSIC_END)
        self.init = True
        self.sounds = {}
        for s in SOUNDS:
            self.sounds[s]= pygame.mixer.Sound(PATH + s)
示例#4
0
def card2string_short(card):
    return '{0}{1}'.format(util.color_short(card), util.number(card))
示例#5
0
def card2string(card):
    return '{0: >6} {1}'.format(util.color(card), util.number(card))
示例#6
0
def card_dealt2str(player_idx, card):
    string = 'A {} {} is dealt to Player {}'.format(util.color(card), util.number(card), player_idx)
    return string
示例#7
0
def invalid_play2str(card):
    string = 'A {} {} is not playable, fuse reduced'.format(util.color(card), util.number(card))
    return string
示例#8
0
def discard2str(player_idx, card_idx, card):
    string = 'Player {} discards card [{}], a {} {}'.format(player_idx, card_idx, util.color(card), util.number(card))
    return string