Ejemplo n.º 1
0
 def testCase1(self):
     env = SevenKingEnv()
     players = [
         AlwaysFoldPlayer(),
         AlwaysFoldPlayer(),
         AlwaysNotFoldPlayer()
     ]
     env.compete(env, players)
Ejemplo n.º 2
0
    def testRandom(self):
        """

        """
        env = SevenKingEnv()
        env.num_players = 2
        players = [roomai.common.RandomPlayer() for i in range(2)]

        for i in range(100):
            SevenKingEnv.compete(env, players)
Ejemplo n.º 3
0
    def testScores(self):
        """

        """
        env = SevenKingEnv()
        env.num_players = 3

        print "aaa"
        players = [AlwaysFoldPlayer(), AlwaysFoldPlayer(), AlwaysNotFoldPlayer()]
        scores  = env.compete(env, players)
        print scores

        self.assertEqual(scores[0],-1)
        self.assertEqual(scores[1],-1)
        self.assertEqual(scores[2],2)
Ejemplo n.º 4
0
    def testScores(self):
        """

        """
        env = SevenKingEnv()

        print("aaa")
        players = [
            AlwaysFoldPlayer(),
            AlwaysFoldPlayer(),
            AlwaysNotFoldPlayer(),
            roomai.common.RandomPlayerChance()
        ]
        scores = env.compete(env, players)
        print(scores)

        self.assertEqual(scores[0], -1)
        self.assertEqual(scores[1], -1)
        self.assertEqual(scores[2], 2)
Ejemplo n.º 5
0
    def testScores1(self):
        """

        """
        env = SevenKingEnv()
        infos, public_state, person_states, private_state = env.init()

        self.assertTrue(
            "" not in infos[public_state.turn].person_state.available_actions)
        self.assertFalse(
            env.is_action_valid(SevenKingAction.lookup(""), public_state,
                                person_states[public_state.turn]))


if __name__ == "__main__":
    env = SevenKingEnv()
    players = [
        AlwaysMaxPlayer(),
        AlwaysNotFoldPlayer(),
        AlwaysMinPlayer(),
        roomai.common.RandomPlayer()
    ]
    import time
    start = time.time()
    for i in range(10):
        scores = env.compete(env, players)
        print(scores)
    end = time.time()
    print(end - start)
Ejemplo n.º 6
0
        '''
            if k == BATCH_SIZE:
                feed_dict = {
                    model.xs: batch_x,
                    model.ys: batch_y,
                }
            else:
                feed_dict = {
                    model.xs: batch_x,
                    model.ys: batch_y,
                    model.cell_init_state: state
                }

            # print(feed_dict)

            _, cost, state, pred = sess.run(
                [model.train_op, model.cost, model.cell_final_state, model.pred],
                feed_dict=feed_dict)

            if math.isnan(cost):
                pdb.set_trace()

            if i % 100 == 0:
                print('cost: ', round(cost, 4))
        '''

    # player.rnn_model.save_model("./path/")
    player2 = skp.AlwaysFoldPlayer()
    for i in range(10):
        scores = env.compete(env, players=[player, player2])
        print(scores)