code
stringlengths
114
1.05M
path
stringlengths
3
312
quality_prob
float64
0.5
0.99
learning_prob
float64
0.2
1
filename
stringlengths
3
168
kind
stringclasses
1 value
"""An online Q-lambda agent trained to play BSuite's Catch env.""" import collections from absl import app from absl import flags from bsuite.environments import catch import dm_env import haiku as hk from haiku import nets import jax import jax.numpy as jnp import numpy as np import optax import rlax from rlax.exampl...
/rlax-0.1.6-py3-none-any.whl/examples/online_q_lambda.py
0.885291
0.452475
online_q_lambda.py
pypi
"""A simple online Q-learning agent trained to play BSuite's Catch env.""" import collections from absl import app from absl import flags from bsuite.environments import catch import haiku as hk from haiku import nets import jax import jax.numpy as jnp import optax import rlax from rlax.examples import experiment Act...
/rlax-0.1.6-py3-none-any.whl/examples/online_q_learning.py
0.886402
0.53206
online_q_learning.py
pypi
import math import numpy as np import rlbase.misc as misc class BaseAgent: def __init__(self,**kwargs): self.pi = kwargs.get("pi") env = kwargs.get("env") q_init = kwargs.get("q_init",0) self.v = {s:0 for s in env.states} self.nv = {s:0 for s in env.states} self.q = {s:{a:q_init for a in env...
/rlbase-chicotobi-0.6.0.tar.gz/rlbase-chicotobi-0.6.0/src/rlbase/agent.py
0.500977
0.24646
agent.py
pypi
import numpy as np import numpy.random as npr import rlbase.misc as misc def transform_Q_to_BestAction(Q): return {s:misc.all_argmax(Q[s]) for s in Q.keys()} class Policy: def __init__(self,**kwargs): self.valid_actions = kwargs.get("env").valid_actions self.n_valid_actions = {s:len(a) for (s,a) in self....
/rlbase-chicotobi-0.6.0.tar.gz/rlbase-chicotobi-0.6.0/src/rlbase/policy.py
0.449634
0.230974
policy.py
pypi
import typing as t import attrs import numpy as np import numpy.typing as npt from rlbcore import api, uis from rlbcore.external_utils.other import null_object @attrs.define() class EpisodeReturnRecorder: """Records episode returns during training and prints them to console. Args: ui (CliUI): The U...
/external_utils/gym_.py
0.869452
0.804137
gym_.py
pypi
import functools import typing as t from pprint import pformat from omegaconf import MISSING, DictConfig, ListConfig, MissingMandatoryValue, OmegaConf def nested_dict_contains_dot_key( dictionary: dict[str, t.Any] | DictConfig, dot_key: str ) -> bool: """Return True if the dictionary contains dot_key in the ...
/external_utils/builtins_.py
0.792986
0.712507
builtins_.py
pypi
import typing as t from unittest.mock import MagicMock AnyT = t.TypeVar("AnyT") def null_object( cls: type[AnyT], property_returns: dict[str, t.Any] | None = None, method_returns: dict[str, t.Any] | None = None, ) -> AnyT: """Create a null object following the Null object pattern. Args: ...
/external_utils/other.py
0.852506
0.759359
other.py
pypi
<!-- Logo --> <p align="center"> <img src="https://raw.githubusercontent.com/rlberry-py/rlberry/main/assets/logo_wide.svg" width="50%"> </p> <!-- Short description --> <p align="center"> A Reinforcement Learning Library for Research and Education </p> <!-- The badges --> <p align="center"> <a href="https:...
/rlberry-0.5.0.tar.gz/rlberry-0.5.0/README.md
0.418697
0.8308
README.md
pypi
import datetime from typing import TypeVar import six from rlbot_action_server import typing_utils def _deserialize(data, klass): """Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. :return: object. """ if dat...
/rlbot_action_server-1.1.0.tar.gz/rlbot_action_server-1.1.0/rlbot_action_server/util.py
0.797675
0.376222
util.py
pypi
from math import pi from typing import List import eel from rlbot.gateway_util import NetworkingRole from rlbot.matchconfig.loadout_config import LoadoutConfig from rlbot.matchconfig.match_config import PlayerConfig, MatchConfig, MutatorConfig, ScriptConfig from rlbot.parsing.incrementing_integer import IncrementingIn...
/rlbot_gui-0.0.140-py3-none-any.whl/rlbot_gui/match_runner/match_runner.py
0.545044
0.235534
match_runner.py
pypi
from contextlib import contextmanager from datetime import datetime from os import path from typing import List, Optional import glob import shutil import os from rlbot.setup_manager import ( SetupManager, RocketLeagueLauncherPreference, try_get_steam_executable_path, ) from rlbot.gamelaunch.epic_launch ...
/rlbot_gui-0.0.140-py3-none-any.whl/rlbot_gui/match_runner/custom_maps.py
0.54698
0.201145
custom_maps.py
pypi
import platform import random import time from datetime import datetime from multiprocessing import Queue as MPQueue from traceback import print_exc from typing import Tuple from rlbot.matchconfig.match_config import MatchConfig, MutatorConfig from rlbot.parsing.match_settings_config_parser import (game_mode_types, ...
/rlbot_smh-1.0.13.tar.gz/rlbot_smh-1.0.13/src/rlbot_smh/story_mode_util.py
0.521227
0.21713
story_mode_util.py
pypi
from math import pi from rlbot.gateway_util import NetworkingRole from rlbot.matchconfig.loadout_config import LoadoutConfig from rlbot.matchconfig.match_config import (MatchConfig, MutatorConfig, PlayerConfig) from rlbot.parsing.agent_config_parser import ( BOT_CONFIG_L...
/rlbot_smh-1.0.13.tar.gz/rlbot_smh-1.0.13/src/rlbot_smh/showroom_util.py
0.521959
0.282042
showroom_util.py
pypi
import datetime from typing import TypeVar import six from rlbot_action_server import typing_utils def _deserialize(data, klass): """Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. :return: object. """ if dat...
/rlbot_twitch_broker_server-1.0.0.tar.gz/rlbot_twitch_broker_server-1.0.0/rlbot_twitch_broker_server/util.py
0.797675
0.376222
util.py
pypi
# RLCard: A Toolkit for Reinforcement Learning in Card Games <img width="500" src="https://dczha.com/files/rlcard/logo.jpg" alt="Logo" /> [![Testing](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml/badge.svg)](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml) [![PyPI ve...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/README.md
0.530966
0.953449
README.md
pypi
import importlib class ModelSpec(object): ''' A specification for a particular Model. ''' def __init__(self, model_id, entry_point=None): ''' Initilize Args: model_id (string): the name of the model entry_point (string): a string that indicates the location of the m...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/models/registration.py
0.78016
0.273406
registration.py
pypi
import numpy as np import rlcard from rlcard.models.model import Model class UNORuleAgentV1(object): ''' UNO Rule agent version 1 ''' def __init__(self): self.use_raw = True def step(self, state): ''' Predict the action given raw state. A naive rule. Choose the color that...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/models/uno_rule_models.py
0.812123
0.358353
uno_rule_models.py
pypi
from typing import TYPE_CHECKING from collections import OrderedDict if TYPE_CHECKING: from rlcard.core import Card from typing import List import numpy as np import rlcard from rlcard.models.model import Model from rlcard.games.gin_rummy.utils.action_event import * import rlcard.games.gin_rummy.utils.meldin...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/models/gin_rummy_rule_models.py
0.666714
0.346154
gin_rummy_rule_models.py
pypi
import numpy as np import rlcard from rlcard.games.doudizhu.utils import CARD_TYPE, INDEX from rlcard.models.model import Model class DouDizhuRuleAgentV1(object): ''' Dou Dizhu Rule agent version 1 ''' def __init__(self): self.use_raw = True def step(self, state): ''' Predict the act...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/models/doudizhu_rule_models.py
0.44553
0.307189
doudizhu_rule_models.py
pypi
import hashlib import numpy as np import os import struct def colorize(string, color, bold=False, highlight = False): """Return string surrounded by appropriate terminal color codes to print colorized text. Valid colors: gray, red, green, yellow, blue, magenta, cyan, white, crimson """ attr = [] ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/utils/seeding.py
0.643329
0.306203
seeding.py
pypi
import numpy as np from rlcard.games.base import Card def set_seed(seed): if seed is not None: import subprocess import sys reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze']) installed_packages = [r.decode().split('==')[0] for r in reqs.split()] if 'to...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/utils/utils.py
0.578686
0.327507
utils.py
pypi
from collections import defaultdict import numpy as np def wrap_state(state): # check if obs is already wrapped if "obs" in state and "legal_actions" in state and "raw_legal_actions" in state: return state wrapped_state = {} wrapped_state["obs"] = state["observation"] legal_actions = np.f...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/utils/pettingzoo_utils.py
0.593374
0.307267
pettingzoo_utils.py
pypi
import numpy as np from copy import deepcopy from rlcard.games.mahjong import Dealer from rlcard.games.mahjong import Player from rlcard.games.mahjong import Round from rlcard.games.mahjong import Judger class MahjongGame: def __init__(self, allow_step_back=False): '''Initialize the class MajongGame ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/mahjong/game.py
0.612657
0.335024
game.py
pypi
class MahjongRound: def __init__(self, judger, dealer, num_players, np_random): ''' Initialize the round class Args: judger (object): the object of MahjongJudger dealer (object): the object of MahjongDealer num_players (int): the number of players in game ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/mahjong/round.py
0.559892
0.312459
round.py
pypi
from termcolor import colored class UnoCard: info = {'type': ['number', 'action', 'wild'], 'color': ['r', 'g', 'b', 'y'], 'trait': ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'skip', 'reverse', 'draw_2', 'wild', 'wild_draw_4'] } def __init__(s...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/uno/card.py
0.59561
0.285795
card.py
pypi
from copy import deepcopy import numpy as np from rlcard.games.uno import Dealer from rlcard.games.uno import Player from rlcard.games.uno import Round class UnoGame: # def __init__(self, allow_step_back=False, num_players=2): def __init__(self, allow_step_back=False): self.allow_step_back = allow_st...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/uno/game.py
0.753557
0.245797
game.py
pypi
import os import json import numpy as np from collections import OrderedDict import rlcard from rlcard.games.uno.card import UnoCard as Card # Read required docs ROOT_PATH = rlcard.__path__[0] # a map of abstract action to its index and a list of abstract action with open(os.path.join(ROOT_PATH, 'games/uno/jsondata...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/uno/utils.py
0.455441
0.236406
utils.py
pypi
from copy import deepcopy, copy import numpy as np from rlcard.games.limitholdem import Dealer from rlcard.games.limitholdem import Player, PlayerStatus from rlcard.games.limitholdem import Judger from rlcard.games.limitholdem import Round class LimitHoldemGame: def __init__(self, allow_step_back=False, num_play...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/limitholdem/game.py
0.770767
0.287561
game.py
pypi
class LimitHoldemRound: """Round can call other Classes' functions to keep the game running""" def __init__(self, raise_amount, allowed_raise_num, num_players, np_random): """ Initialize the round class Args: raise_amount (int): the raise amount for each raise a...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/limitholdem/round.py
0.910496
0.633609
round.py
pypi
from enum import Enum import numpy as np from copy import deepcopy from rlcard.games.limitholdem import Game from rlcard.games.limitholdem import PlayerStatus from rlcard.games.nolimitholdem import Dealer from rlcard.games.nolimitholdem import Player from rlcard.games.nolimitholdem import Judger from rlcard.games.nol...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/nolimitholdem/game.py
0.624866
0.205615
game.py
pypi
"""Implement no limit texas holdem Round class""" from enum import Enum from rlcard.games.limitholdem import PlayerStatus class Action(Enum): FOLD = 0 CHECK_CALL = 1 #CALL = 2 # RAISE_3BB = 3 RAISE_HALF_POT = 2 RAISE_POT = 3 # RAISE_2POT = 5 ALL_IN = 4 # SMALL_BLIND = 7 # BIG_...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/nolimitholdem/round.py
0.832475
0.35782
round.py
pypi
''' Implement Doudizhu Game class ''' import functools from heapq import merge import numpy as np from rlcard.games.doudizhu.utils import cards2str, doudizhu_sort_card, CARD_RANK_STR from rlcard.games.doudizhu import Player from rlcard.games.doudizhu import Round from rlcard.games.doudizhu import Judger class Doudiz...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/doudizhu/game.py
0.49048
0.171651
game.py
pypi
''' Implement Doudizhu Player class ''' import functools from rlcard.games.doudizhu.utils import get_gt_cards from rlcard.games.doudizhu.utils import cards2str, doudizhu_sort_card class DoudizhuPlayer: ''' Player can store cards in the player's hand and the role, determine the actions can be made according t...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/doudizhu/player.py
0.646237
0.224363
player.py
pypi
import numpy as np from .player import GinRummyPlayer from .round import GinRummyRound from .judge import GinRummyJudge from .utils.settings import Settings, DealerForRound from .utils.action_event import * class GinRummyGame: ''' Game class. This class will interact with outer environment. ''' def __i...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/gin_rummy/game.py
0.534855
0.18717
game.py
pypi
from typing import List from rlcard.games.base import Card from .utils import utils from .utils import melding class GinRummyPlayer: def __init__(self, player_id: int, np_random): ''' Initialize a GinRummy player class Args: player_id (int): id for the player ''' s...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/gin_rummy/player.py
0.691289
0.17515
player.py
pypi
from typing import TYPE_CHECKING if TYPE_CHECKING: from .utils.move import GinRummyMove from typing import List from rlcard.games.gin_rummy.dealer import GinRummyDealer from .utils.action_event import DrawCardAction, PickUpDiscardAction, DeclareDeadHandAction from .utils.action_event import DiscardAction, KnockA...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/gin_rummy/round.py
0.695648
0.17266
round.py
pypi
from typing import TYPE_CHECKING if TYPE_CHECKING: from ..game import GinRummyGame from typing import Callable from .action_event import * from ..player import GinRummyPlayer from .move import ScoreNorthMove, ScoreSouthMove from .gin_rummy_error import GinRummyProgramError from rlcard.games.gin_rummy.utils impor...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/gin_rummy/utils/scorers.py
0.761361
0.251958
scorers.py
pypi
from typing import List, Iterable import numpy as np from rlcard.games.base import Card from .gin_rummy_error import GinRummyProgramError valid_rank = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K'] valid_suit = ['S', 'H', 'D', 'C'] rank_to_deadwood_value = {"A": 1, "2": 2, "3": 3, "4": 4, "5": 5...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/gin_rummy/utils/utils.py
0.799599
0.319267
utils.py
pypi
from typing import List from rlcard.games.base import Card from rlcard.games.gin_rummy.utils import utils from rlcard.games.gin_rummy.utils.gin_rummy_error import GinRummyProgramError # =============================================================== # Terminology: # run_meld - three or more cards of same s...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/gin_rummy/utils/melding.py
0.417509
0.250798
melding.py
pypi
from typing import List import numpy as np from .judger import BridgeJudger from .round import BridgeRound from .utils.action_event import ActionEvent, CallActionEvent, PlayCardAction class BridgeGame: ''' Game class. This class will interact with outer environment. ''' def __init__(self, allow_step_ba...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/bridge/game.py
0.780788
0.177383
game.py
pypi
from typing import List from .dealer import BridgeDealer from .player import BridgePlayer from .utils.action_event import CallActionEvent, PassAction, DblAction, RdblAction, BidAction, PlayCardAction from .utils.move import BridgeMove, DealHandMove, PlayCardMove, MakeBidMove, MakePassMove, MakeDblMove, MakeRdblMove, ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/bridge/round.py
0.787523
0.178204
round.py
pypi
from typing import List from typing import TYPE_CHECKING if TYPE_CHECKING: from .game import BridgeGame from .utils.action_event import PlayCardAction from .utils.action_event import ActionEvent, BidAction, PassAction, DblAction, RdblAction from .utils.move import MakeBidMove, MakeDblMove, MakeRdblMove from .util...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/bridge/judger.py
0.663778
0.160825
judger.py
pypi
class BlackjackJudger: def __init__(self, np_random): ''' Initialize a BlackJack judger class ''' self.np_random = np_random self.rank2score = {"A":11, "2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8, "9":9, "T":10, "J":10, "Q":10, "K":10} def judge_round(self, player): ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/blackjack/judger.py
0.727685
0.46308
judger.py
pypi
import numpy as np from copy import copy from rlcard.games.leducholdem import Dealer from rlcard.games.leducholdem import Player from rlcard.games.leducholdem import Judger from rlcard.games.leducholdem import Round from rlcard.games.limitholdem import Game class LeducholdemGame(Game): def __init__(self, allow_...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/leducholdem/game.py
0.71103
0.314471
game.py
pypi
from rlcard.utils.utils import rank2int class LeducholdemJudger: ''' The Judger class for Leduc Hold'em ''' def __init__(self, np_random): ''' Initialize a judger class ''' self.np_random = np_random @staticmethod def judge_game(players, public_card): ''' Judge the ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/games/leducholdem/judger.py
0.673943
0.356503
judger.py
pypi
import numpy as np import collections import os import pickle from rlcard.utils.utils import * class CFRAgent(): ''' Implement CFR (chance sampling) algorithm ''' def __init__(self, env, model_path='./cfr_model'): ''' Initilize Agent Args: env (Env): Env class ''' ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/cfr_agent.py
0.74382
0.323086
cfr_agent.py
pypi
import random import numpy as np import torch import torch.nn as nn from collections import namedtuple from copy import deepcopy from rlcard.utils.utils import remove_illegal Transition = namedtuple('Transition', ['state', 'action', 'reward', 'next_state', 'legal_actions', 'done']) class DQNAgent(object): ''' ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/dqn_agent.py
0.88981
0.519521
dqn_agent.py
pypi
import random import collections import enum import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from rlcard.agents.dqn_agent import DQNAgent from rlcard.utils.utils import remove_illegal Transition = collections.namedtuple('Transition', 'info_state action_probs') class NFSPAgent(ob...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/nfsp_agent.py
0.850189
0.429669
nfsp_agent.py
pypi
from rlcard.utils.utils import print_card class HumanAgent(object): ''' A human agent for Blackjack. It can be used to play alone for understand how the blackjack code runs ''' def __init__(self, num_actions): ''' Initilize the human agent Args: num_actions (int): the size of...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/human_agents/blackjack_human_agent.py
0.68616
0.522019
blackjack_human_agent.py
pypi
from rlcard.games.uno.card import UnoCard class HumanAgent(object): ''' A human agent for Leduc Holdem. It can be used to play against trained models ''' def __init__(self, num_actions): ''' Initilize the human agent Args: num_actions (int): the size of the ouput action space ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/human_agents/uno_human_agent.py
0.676834
0.391144
uno_human_agent.py
pypi
from rlcard.utils.utils import print_card class HumanAgent(object): ''' A human agent for Limit Holdem. It can be used to play against trained models ''' def __init__(self, num_actions): ''' Initilize the human agent Args: num_actions (int): the size of the ouput action space...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/human_agents/limit_holdem_human_agent.py
0.675551
0.501221
limit_holdem_human_agent.py
pypi
from rlcard.utils.utils import print_card class HumanAgent(object): ''' A human agent for No Limit Holdem. It can be used to play against trained models ''' def __init__(self, num_actions): ''' Initilize the human agent Args: num_actions (int): the size of the ouput action sp...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/human_agents/nolimit_holdem_human_agent.py
0.705684
0.431824
nolimit_holdem_human_agent.py
pypi
from rlcard.utils.utils import print_card class HumanAgent(object): ''' A human agent for Leduc Holdem. It can be used to play against trained models ''' def __init__(self, num_actions): ''' Initilize the human agent Args: num_actions (int): the size of the ouput action space...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/human_agents/leduc_holdem_human_agent.py
0.603815
0.475423
leduc_holdem_human_agent.py
pypi
import time from rlcard.games.gin_rummy.utils.action_event import ActionEvent from rlcard.games.gin_rummy.utils.gin_rummy_error import GinRummyProgramError class HumanAgent(object): ''' A human agent for Gin Rummy. It can be used to play against trained models. ''' def __init__(self, num_actions): ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/human_agents/gin_rummy_human_agent/gin_rummy_human_agent.py
0.670716
0.264067
gin_rummy_human_agent.py
pypi
from typing import TYPE_CHECKING if TYPE_CHECKING: from .game_canvas import GameCanvas from typing import List from rlcard.games.gin_rummy.game import GinRummyGame from rlcard.games.gin_rummy.utils.action_event import DrawCardAction, PickUpDiscardAction, DeclareDeadHandAction from rlcard.games.gin_rummy.utils.ac...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/human_agents/gin_rummy_human_agent/gui_gin_rummy/game_canvas_query.py
0.732209
0.166337
game_canvas_query.py
pypi
import os import threading import time import timeit import pprint from collections import deque import torch from torch import multiprocessing as mp from torch import nn from .file_writer import FileWriter from .model import DMCModel from .pettingzoo_model import DMCModelPettingZoo from .utils import ( get_batc...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/dmc_agent/trainer.py
0.818338
0.303758
trainer.py
pypi
import numpy as np import torch from torch import nn class DMCNet(nn.Module): def __init__( self, state_shape, action_shape, mlp_layers=[512,512,512,512,512] ): super().__init__() input_dim = np.prod(state_shape) + np.prod(action_shape) layer_dims = [in...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/agents/dmc_agent/model.py
0.879903
0.583381
model.py
pypi
import numpy as np from collections import OrderedDict from rlcard.envs import Env from rlcard.games.mahjong import Game from rlcard.games.mahjong import Card from rlcard.games.mahjong.utils import card_encoding_dict, encode_cards, pile2list class MahjongEnv(Env): ''' Mahjong Environment ''' def __init__...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/envs/mahjong.py
0.469763
0.230205
mahjong.py
pypi
import importlib # Default Config DEFAULT_CONFIG = { 'allow_step_back': False, 'seed': None, } class EnvSpec(object): ''' A specification for a particular instance of the environment. ''' def __init__(self, env_id, entry_point=None): ''' Initilize Args: ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/envs/registration.py
0.668664
0.157266
registration.py
pypi
import numpy as np from collections import OrderedDict from rlcard.envs import Env from rlcard.games.blackjack import Game DEFAULT_GAME_CONFIG = { 'game_num_players': 1, 'game_num_decks': 1 } class BlackjackEnv(Env): ''' Blackjack Environment ''' def __init__(self, config): ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/envs/blackjack.py
0.58818
0.264495
blackjack.py
pypi
import json import os import numpy as np from collections import OrderedDict import rlcard from rlcard.envs import Env from rlcard.games.limitholdem import Game DEFAULT_GAME_CONFIG = { 'game_num_players': 2, } class LimitholdemEnv(Env): ''' Limitholdem Environment ''' def __init__(self, ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/envs/limitholdem.py
0.584983
0.22762
limitholdem.py
pypi
from collections import Counter, OrderedDict import numpy as np from rlcard.envs import Env class DoudizhuEnv(Env): ''' Doudizhu Environment ''' def __init__(self, config): from rlcard.games.doudizhu.utils import ACTION_2_ID, ID_2_ACTION from rlcard.games.doudizhu.utils import cards2str,...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/envs/doudizhu.py
0.598547
0.208723
doudizhu.py
pypi
import json import os import numpy as np from collections import OrderedDict import rlcard from rlcard.envs import Env from rlcard.games.leducholdem import Game from rlcard.utils import * DEFAULT_GAME_CONFIG = { 'game_num_players': 2, } class LeducholdemEnv(Env): ''' Leduc Hold'em Environment ...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/envs/leducholdem.py
0.589362
0.210584
leducholdem.py
pypi
from rlcard.utils import * class Env(object): ''' The base Env class. For all the environments in RLCard, we should base on this class and implement as many functions as we can. ''' def __init__(self, config): ''' Initialize the environment Args: config (dict): A co...
/rlcard-uno-2.0.2.tar.gz/rlcard-uno-2.0.2/rlcard/envs/env.py
0.650578
0.336726
env.py
pypi
# RLCard: A Toolkit for Reinforcement Learning in Card Games <img width="500" src="https://dczha.com/files/rlcard/logo.jpg" alt="Logo" /> [![Testing](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml/badge.svg)](https://github.com/datamllab/rlcard/actions/workflows/python-package.yml) [![PyPI ve...
/rlcard-1.2.0.tar.gz/rlcard-1.2.0/README.md
0.530966
0.918261
README.md
pypi
import requests class RLClient: def __init__(self, name, password, hostname="10.216.3.238"): self.TEAM_NAME = name self.TEAM_PASSWORD = password self.SERVER = "http://" + hostname + ":80/rl" @staticmethod def validate_ids(run_id, request_number): if run_id < 0: ...
/rlclientbdr-1.11.tar.gz/rlclientbdr-1.11/rlclient/client.py
0.47926
0.155335
client.py
pypi
import numpy as np import networkx as nx def _rho(D, target_fraction=0.02, mode='gaussian'): """Calculates the RL rho values from a distance matrix""" dcut = np.sort(D)[:,1 + int(len(D) * target_fraction)].mean() if mode == 'classic': r = np.array([len(np.where(d < dcut)[0]) for d in D]) elif ...
/rlcluster-0.0.5.tar.gz/rlcluster-0.0.5/rlcluster.py
0.528533
0.635873
rlcluster.py
pypi
`rlda`: Robust Latent Dirichlet Allocation models ------------------------- This python module provides a set of functions to fit multiple LDA models to a text corpus and then search for the robust topics present in multiple models. In natural language processing LDA models are used to classify text into topics. Ho...
/rlda-0.61.tar.gz/rlda-0.61/README.rst
0.910051
0.759894
README.rst
pypi
# coding=utf-8 """TFDS episode writer.""" from typing import Optional from absl import logging from rlds import rlds_types import tensorflow_datasets as tfds DatasetConfig = tfds.rlds.rlds_base.DatasetConfig class EpisodeWriter(): """Class that writes trajectory data in TFDS format (and RLDS structure).""" d...
/tfds/episode_writer.py
0.874158
0.328314
episode_writer.py
pypi
# coding=utf-8 """Library to generate a TFDS config.""" from typing import Any, Dict, List, Optional, Union import numpy as np from rlds import rlds_types import tensorflow as tf import tensorflow_datasets as tfds _STEP_KEYS = [ rlds_types.OBSERVATION, rlds_types.ACTION, rlds_types.DISCOUNT, rlds_types.REWA...
/tfds/config_generator.py
0.927223
0.495178
config_generator.py
pypi
import time import scipy.optimize import theano from rllab.core import Serializable from rllab.misc import compile_function from rllab.misc import flatten_tensor_variables from rllab.misc import lazydict class LbfgsOptimizer(Serializable): """ Performs unconstrained optimization via L-BFGS. """ def...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/optimizers/lbfgs_optimizer.py
0.847179
0.249802
lbfgs_optimizer.py
pypi
from _ast import Num import itertools # noqa: I100,I201 import numpy as np import theano import theano.tensor as TT from rllab.core import Serializable from rllab.misc import ext from rllab.misc import krylov from rllab.misc import logger from rllab.misc import sliced_fun class PerlmutterHvp(Serializable): def...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/optimizers/conjugate_gradient_optimizer.py
0.765155
0.23557
conjugate_gradient_optimizer.py
pypi
import time from rllab.core import Serializable from rllab.misc import compile_function, from rllab.misc import lazydict from rllab.optimizers import BatchDataset from rllab.optimizers import hf_optimizer class HessianFreeOptimizer(Serializable): """ Performs unconstrained optimization via Hessian-Free Optim...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/optimizers/hessian_free_optimizer.py
0.858006
0.205535
hessian_free_optimizer.py
pypi
from collections import OrderedDict from functools import partial import time import lasagne.updates import pyprind import theano from rllab.core import Serializable from rllab.misc import ext from rllab.misc import logger from rllab.optimizers import BatchDataset class FirstOrderOptimizer(Serializable): """ ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/optimizers/first_order_optimizer.py
0.902014
0.22718
first_order_optimizer.py
pypi
import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano import theano.tensor as TT from rllab.core import ConvNetwork from rllab.core import LasagnePowered from rllab.core import ParamLayer from rllab.core import Serializable from rllab.distributions import Diagon...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/regressors/gaussian_conv_regressor.py
0.841468
0.325601
gaussian_conv_regressor.py
pypi
import numpy as np from rllab.core import Serializable class ProductRegressor(Serializable): """ A class for performing MLE regression by fitting a product distribution to the outputs. A separate regressor will be trained for each individual input distribution. """ def __init__(self, regress...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/regressors/product_regressor.py
0.805403
0.524699
product_regressor.py
pypi
import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano import theano.tensor as TT from rllab.core import LasagnePowered from rllab.core import MLP from rllab.core import Serializable from rllab.distributions import Categorical from rllab.misc import ext from rllab.misc import l...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/regressors/categorical_mlp_regressor.py
0.825941
0.357988
categorical_mlp_regressor.py
pypi
import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano import theano.tensor as TT from rllab.core import LasagnePowered from rllab.core import MLP from rllab.core import ParamLayer from rllab.core import Serializable from rllab.distributions import DiagonalGaussi...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/regressors/gaussian_mlp_regressor.py
0.788217
0.394376
gaussian_mlp_regressor.py
pypi
import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np from rllab.core import ConvNetwork from rllab.core import LasagnePowered from rllab.core import Serializable from rllab.distributions import Categorical from rllab.misc import ext from rllab.misc import logger from rllab.misc import tens...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/policies/categorical_conv_policy.py
0.920057
0.437463
categorical_conv_policy.py
pypi
import lasagne.init import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano.tensor as TT from rllab.core import GRUNetwork from rllab.core import LasagnePowered from rllab.core import ParamLayer from rllab.core import Serializable from rllab.distributions import RecurrentDiagona...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/policies/gaussian_gru_policy.py
0.790247
0.404802
gaussian_gru_policy.py
pypi
from rllab.core import Parameterized class Policy(Parameterized): def __init__(self, env_spec): Parameterized.__init__(self) self._env_spec = env_spec # Should be implemented by all policies def get_action(self, observation): raise NotImplementedError def reset(self): ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/policies/base.py
0.889018
0.398055
base.py
pypi
import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano.tensor as TT from rllab.core import LasagnePowered from rllab.core import MLP from rllab.core import ParamLayer from rllab.core import Serializable from rllab.distributions import DiagonalGaussian from rllab....
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/policies/gaussian_mlp_policy.py
0.85984
0.363336
gaussian_mlp_policy.py
pypi
import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np from rllab.core import LasagnePowered from rllab.core import MLP from rllab.core import Serializable from rllab.distributions import Categorical from rllab.misc import ext from rllab.misc.overrides import overrides from rllab.policies im...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/policies/categorical_mlp_policy.py
0.867457
0.433322
categorical_mlp_policy.py
pypi
import lasagne import lasagne.init as LI import lasagne.layers as L import lasagne.nonlinearities as NL from rllab.core import batch_norm from rllab.core import LasagnePowered from rllab.core import Serializable from rllab.misc import ext from rllab.policies import Policy class DeterministicMLPPolicy(Policy, Lasagne...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/policies/deterministic_mlp_policy.py
0.768907
0.237642
deterministic_mlp_policy.py
pypi
import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano.tensor as TT from rllab.core import GRUNetwork from rllab.core import LasagnePowered from rllab.core import OpLayer from rllab.core import Serializable from rllab.distributions import RecurrentCategorical from rllab.misc im...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/policies/categorical_gru_policy.py
0.759939
0.347565
categorical_gru_policy.py
pypi
from rllab.algos import RLAlgorithm import rllab.misc.logger as logger from rllab.plotter import plotter from rllab.policies import Policy from rllab.sampler import parallel_sampler from rllab.sampler.base import BaseSampler from rllab.sampler.utils import rollout class BatchSampler(BaseSampler): def __init__(sel...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/algos/batch_polopt.py
0.817064
0.309363
batch_polopt.py
pypi
import theano import theano.tensor as TT from rllab.algos import BatchPolopt from rllab.core import Serializable from rllab.misc import ext from rllab.misc import logger from rllab.misc.overrides import overrides from rllab.optimizers import FirstOrderOptimizer class VPG(BatchPolopt, Serializable): """ Vanil...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/algos/vpg.py
0.661267
0.151906
vpg.py
pypi
import numpy as np import theano.tensor as TT from rllab.algos import cma_es_lib from rllab.algos import RLAlgorithm from rllab.core import Serializable from rllab.misc import ext import rllab.misc.logger as logger from rllab.misc.special import discount_cumsum import rllab.plotter as plotter from rllab.sampler import...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/algos/cma_es.py
0.727395
0.401629
cma_es.py
pypi
import theano import theano.tensor as TT from rllab.algos import BatchPolopt from rllab.misc import ext import rllab.misc.logger as logger from rllab.misc.overrides import overrides from rllab.optimizers import PenaltyLbfgsOptimizer class NPO(BatchPolopt): """ Natural Policy Optimization. """ def __...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/algos/npo.py
0.649579
0.185412
npo.py
pypi
import numpy as np import theano.tensor as TT from rllab.distributions import Distribution TINY = 1e-8 class Bernoulli(Distribution): def __init__(self, dim): self._dim = dim @property def dim(self): return self._dim def kl_sym(self, old_dist_info_vars, new_dist_info_vars): ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/distributions/bernoulli.py
0.729038
0.161849
bernoulli.py
pypi
import numpy as np import theano import theano.tensor as TT from rllab.distributions import Categorical from rllab.distributions import Distribution TINY = 1e-8 class RecurrentCategorical(Distribution): def __init__(self, dim): self._cat = Categorical(dim) self._dim = dim @property def ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/distributions/recurrent_categorical.py
0.841858
0.27312
recurrent_categorical.py
pypi
import numpy as np import theano.tensor as TT from rllab.distributions import Distribution class DiagonalGaussian(Distribution): def __init__(self, dim): self._dim = dim @property def dim(self): return self._dim def kl_sym(self, old_dist_info_vars, new_dist_info_vars): old_m...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/distributions/diagonal_gaussian.py
0.822759
0.306864
diagonal_gaussian.py
pypi
import lasagne import lasagne.layers as L import theano import theano.tensor as TT class ParamLayer(L.Layer): def __init__(self, incoming, num_units, param=lasagne.init.Constant(0.), trainable=True, **kwargs): super(Param...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/core/lasagne_layers.py
0.885792
0.525551
lasagne_layers.py
pypi
from contextlib import contextmanager from rllab.core import Serializable from rllab.misc.tensor_utils import flatten_tensors, unflatten_tensors load_params = True @contextmanager def suppress_params_loading(): global load_params load_params = False yield load_params = True class Parameterized(Ser...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/core/parameterized.py
0.813683
0.250517
parameterized.py
pypi
import numpy as np from rllab.misc import special from rllab.misc import tensor_utils import rllab.misc.logger as logger from rllab.sampler import utils class Sampler(object): def start_worker(self): """ Initialize the sampler, e.g. launching parallel workers if necessary. """ rai...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/sampler/base.py
0.756447
0.301137
base.py
pypi
import lasagne import lasagne.init import lasagne.layers as L import lasagne.nonlinearities as NL import theano.tensor as TT from rllab.core import batch_norm from rllab.core import LasagnePowered from rllab.core import Serializable from rllab.misc import ext from rllab.q_functions import QFunction class ContinuousM...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/q_functions/continuous_mlp_q_function.py
0.67971
0.270336
continuous_mlp_q_function.py
pypi
import numpy as np from rllab.misc import ext from rllab.spaces import Space class Product(Space): def __init__(self, *components): if isinstance(components[0], (list, tuple)): assert len(components) == 1 components = components[0] self._components = tuple(components) ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/spaces/product.py
0.62395
0.421611
product.py
pypi
import numpy as np import theano from rllab.core import Serializable from rllab.misc import ext from rllab.spaces import Space class Box(Space): """ A box in R^n. I.e., each coordinate is bounded. """ def __init__(self, low, high, shape=None): """ Two kinds of valid input: ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/spaces/box.py
0.842053
0.585457
box.py
pypi
from cached_property import cached_property import numpy as np from rllab import spaces from rllab.core import Serializable from rllab.envs import Step from rllab.envs.mujoco import MujocoEnv from rllab.envs.proxy_env import ProxyEnv from rllab.misc.overrides import overrides BIG = 1e6 class OcclusionEnv(ProxyEnv, ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/envs/occlusion_env.py
0.855187
0.370168
occlusion_env.py
pypi
import collections from cached_property import cached_property from rllab.envs import EnvSpec class Env(object): def step(self, action): """ Run one timestep of the environment's dynamics. When end of episode is reached, reset() should be called to reset the environment's internal ...
/rlgarage-0.1.0.tar.gz/rlgarage-0.1.0/rllab/envs/base.py
0.909739
0.535524
base.py
pypi