forked from datamllab/rlcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gin_rummy_human.py
51 lines (41 loc) · 1.85 KB
/
gin_rummy_human.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
Project: Gui Gin Rummy
File name: gin_rummy_human.py
Author: William Hale
Date created: 3/14/2020
'''
# You need to install tkinter if it is not already installed.
# Tkinter is Python's defacto standard GUI (Graphical User Interface) package.
# It is a thin object-oriented layer on top of Tcl/Tk.
# Note that the name of the module is ‘tkinter’.
#
# If you are using anaconda:
# -- I have version 8.6.8 to work with version 3.5 of Python.
# -- In the installed window for your environment, search for "tk".
# -- If it is found, make sure you have at least version 8.6.8.
# -- Otherwise, go to the "Not installed" window, search for "tk", select it, and apply it.
#
# If you are using Ubuntu:
# -- You can install it with apt-get install python-tk.
#
# For other cases, you can search on google to see how to install tkinter.
# from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from rlcard.envs.gin_rummy import GinRummyEnv
import rlcard
from rlcard.agents import RandomAgent
from rlcard.models.gin_rummy_rule_models import GinRummyNoviceRuleAgent
from rlcard.agents.gin_rummy_human_agent.gin_rummy_human_agent import HumanAgent
from rlcard.agents.gin_rummy_human_agent.gui_gin_rummy.game_app import GameApp
from rlcard.games.gin_rummy.utils import scorers
def make_gin_rummy_env() -> 'GinRummyEnv':
gin_rummy_env = rlcard.make('gin-rummy')
# north_agent = RandomAgent(action_num=gin_rummy_env.action_num)
north_agent = GinRummyNoviceRuleAgent()
south_agent = HumanAgent(gin_rummy_env.action_num)
gin_rummy_env.set_agents([north_agent, south_agent])
gin_rummy_env.game.judge.scorer = scorers.GinRummyScorer(get_payoff=scorers.get_payoff_gin_rummy_v0)
return gin_rummy_env
# Play game
gin_rummy_app = GameApp(make_gin_rummy_env=make_gin_rummy_env)