Exemple #1
0
    def test_sevenking_dqn(self):
        import logging
        roomai.set_loglevel(logging.DEBUG)
        env = roomai.sevenking.SevenKingEnv()
        model = SevenKingModel_ThreePlayers()
        algo = dqn.DqnAlgorithm()
        algo.train(env=env, model=model, params={"num_normal_players": 3})

        opponents = [roomai.common.RandomPlayer() for i in range(2)]
        scores = algo.eval(model=model, env=env, opponents=opponents)
        print(scores)
Exemple #2
0
 def test_sevenking_dqn(self):
     import logging
     roomai.set_loglevel(logging.DEBUG)
     env = roomai.sevenking.SevenKingEnv()
     player = SevenKingModel_ThreePlayers()
     algo = DqnAlgorithm()
     opponents = [roomai.common.RandomPlayer() for i in range(2)]
     algo.train(env=env,
                players=[player] + opponents +
                [roomai.common.RandomPlayerChance()],
                params={
                    "num_normal_players": 3,
                    "num_iters": 1
                })
     opponents = [roomai.common.RandomPlayer() for i in range(2)]
Exemple #3
0
 def setUp(self):
     import logging
     roomai.set_loglevel(logging.DEBUG)
Exemple #4
0
#!/bin/python
import unittest
import roomai.bridge
import roomai
import roomai.common
from functools import cmp_to_key


def compare_action(a, b):
    return a.key > b.key


if __name__ == "__main__":
    import time
    import logging
    roomai.set_loglevel(logging.DEBUG)
    start = time.time()
    for iter in range(1000):
        env = roomai.bridge.BridgeEnv()
        allcards = list(roomai.bridge.AllBridgePlayingPokerCards.values())
        allcards.sort(key=cmp_to_key(roomai.common.PokerCard.compare))
        infos, public_state, person_states, private_state = env.init(
            {"start_turn": 0})
        env.__deepcopy__()

        #### bidding stage
        action = roomai.bridge.BridgeAction.lookup("bidding_bid_A_Heart")
        infos, public_state, person_states, private_state = env.forward(action)
        action = roomai.bridge.BridgeAction.lookup("bidding_double")
        infos, public_state, person_states, private_state = env.forward(action)
        action = roomai.bridge.BridgeAction.lookup("bidding_pass")