示例#1
0
文件: main.py 项目: isawzz/vid_old
        side = config.basic.side_length
        stride = config.basic.stride_length

        grid = world.make_quadgrid(rows=side,
                                   cols=side,
                                   table=self.table,
                                   field_obj_type='Tick',
                                   grid_obj_type='Board')

        self.state.board = grid
        self.state.limit = stride

    def _end_game(self):

        val = self.state.winner

        if val is None:
            self.log.writef('Game over! Draw game!')
            return tdict(winner=None)

        for player in self.players:
            if player.val == val:
                self.log.writef('Game Over! {} wins!', player)
                return tdict(winner=player.name)

        raise Exception('No player with val: {}'.format(val))


gsm.register_game(s1, os.path.join(MY_PATH, 'info.yaml'))
示例#2
0
文件: main.py 项目: isawzz/vid_old
		p1, p2 = self.players
		
		p1.symbol = config.basic.characters.p1
		p2.symbol = config.basic.characters.p2
		
		# init state
		
		side = config.basic.side_length
		
		grid = world.make_quadgrid(rows=side, cols=side, table=self.table,
		                           field_obj_type='Tick', grid_obj_type='Board')
		
		self.state.board = grid
		
	def _end_game(self):
		
		val = self.state.winner
		
		if val is None:
			self.log.writef('Game over! Draw game!')
			return tdict(winner=None)
		
		for player in self.players:
			if player.val == val:
				self.log.writef('Game Over! {} wins!', player)
				return tdict(winner=player.name)
			
		raise Exception('No player with val: {}'.format(val))
	
gsm.register_game(TicTacToe, os.path.join(MY_PATH, 'info.yaml'))
示例#3
0
文件: main.py 项目: isawzz/vid_old
        mx = max(vps.values())

        # TODO: break ties with money and hand card values

        winners = tlist()
        for name, V in vps.items():
            if V == mx:
                winners.append(name)

        if len(winners) == 1:
            out.winner = winners[0]
            return out
        out.winners = winners
        return out

    def cheat(self, code=None):

        self.log.writef('Cheat code activated: {}', code)
        self.log.iindent()

        # if code == 'devcard':
        # 	for player in self.players:
        # 		gain_res('wheat', self.state.bank, player, 1, log=self.log)
        # 		gain_res('ore', self.state.bank, player, 1, log=self.log)
        # 		gain_res('sheep', self.state.bank, player, 1, log=self.log)

        self.log.dindent()


gsm.register_game(Aristocracy, os.path.join(MY_PATH, 'info.yaml'))
示例#4
0
    def _select_player(self):
        return next(iter(self.players))

    def _init_game(self, config):
        self.state = config.rules

    def _end_game(self):
        out = tdict()
        winners = tlist()
        for name in self.players.values():
            winners.append(name)
        out.winner = random.choice(winners)
        print('winner is {}'.format(out.winner))
        return out

    def cheat(self, code=None):

        self.log.writef('Cheat code activated: {}', code)
        self.log.iindent()

        # if code == 'devcard':
        # 	for player in self.players:
        # 		gain_res('wheat', self.state.bank, player, 1, log=self.log)
        # 		gain_res('ore', self.state.bank, player, 1, log=self.log)
        # 		gain_res('sheep', self.state.bank, player, 1, log=self.log)

        self.log.dindent()


gsm.register_game(EmptyGame, os.path.join(MY_PATH, 'info.yaml'))