當前位置: 首頁>>代碼示例>>Python>>正文


Python EnvironmentLoader.loadEnvironment方法代碼示例

本文整理匯總了Python中rlglue.environment.EnvironmentLoader.loadEnvironment方法的典型用法代碼示例。如果您正苦於以下問題:Python EnvironmentLoader.loadEnvironment方法的具體用法?Python EnvironmentLoader.loadEnvironment怎麽用?Python EnvironmentLoader.loadEnvironment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rlglue.environment.EnvironmentLoader的用法示例。


在下文中一共展示了EnvironmentLoader.loadEnvironment方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: launch_environment

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
def launch_environment(parameters):
    """Start the sumo-rlglue environment

    (This function is executed in a separate process using
    multiprocessing.)
    """
    import rl_glue_sumo_environment
    environment = rl_glue_sumo_environment.SumoEnvironment()
    EnvironmentLoader.loadEnvironment(environment)
開發者ID:TobiasMR,項目名稱:DeepLight,代碼行數:11,代碼來源:launcher.py

示例2: main

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
def main():
    EnvironmentLoader.loadEnvironment(
        InvasiveEnvironment(
            simulationParameterObj = None,
            actionParameterObj = None,
            Bad_Action_Penalty = -10000,
            fixedStartState = False,
            nbrReaches = REACHES,
            habitatSize = HABITATS,
            seed = 1))
開發者ID:Wojje,項目名稱:Reinforcement-Learning-Competition-2014,代碼行數:12,代碼來源:InvasiveEnvironment.py

示例3: env_cleanup

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
		episodeOver=0
		theReward=0

		theObs=Observation()
		theObs.intArray=np.zeros(50816)
		
		returnRO=Reward_observation_terminal()
		returnRO.r=theReward
		returnRO.o=theObs
		returnRO.terminal=episodeOver
		
		return returnRO

	def env_cleanup(self):
		pass

	def env_message(self,inMessage):
		if inMessage=="what is your name?":
			return "my name is dqn_environment, Python edition!";
		else:
			return "I don't know how to respond to your message";


if __name__ == '__main__':
	App = TetrisApp()
	#App.run()
	EnvironmentLoader.loadEnvironment(TetrisApp())
	print('main start')

開發者ID:ProjectRune,項目名稱:DQN_Tetris,代碼行數:30,代碼來源:tetris.py

示例4: env_cleanup

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
			ro.r=1.0

		else:
			self.o.doubleArray=[0.0078125,-0.0078125,0.0,0.0078125e150,-0.0078125e150]
			self.o.charArray=['g','F','?',' ','&']
			self.o.intArray=[173,-173,2147483647,0,-2147483648]

			ro.r=-2.0

		ro.o=self.o
		ro.terminal=terminal
		return ro	

	def env_cleanup(self):
		pass

	def env_message(self,inMessage):
		timesToPrint=self.stepCount%3
		
		outMessage=inMessage+"|"
		for i in range(0, timesToPrint):
			outMessage=outMessage+"%d" % (self.stepCount)
			outMessage=outMessage+"."

		outMessage=outMessage+"|"+inMessage
		
		return outMessage
	
if __name__=="__main__":
	EnvironmentLoader.loadEnvironment(test_1_environment())
開發者ID:junzhez,項目名稱:rl_glue_python3_codec,代碼行數:32,代碼來源:test_1_environment.py

示例5: env_init

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
	def env_init(self):  
		return ""

	def env_start(self):
		return Observation()
	
	def env_step(self,action):
		return Reward_observation_terminal()

	def env_cleanup(self):
		pass
	
	def env_message(self,inMessage):
		if inMessage==None:
			return "null"

		if inMessage=="":
			return "empty"

		if inMessage=="null":
			return None

		if inMessage=="empty":
			return ""
		
		return inMessage;	

if __name__=="__main__":
	EnvironmentLoader.loadEnvironment(test_message_environment())
開發者ID:junzhez,項目名稱:rl_glue_python3_codec,代碼行數:31,代碼來源:test_message_environment.py

示例6: width

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
            if event.type == pygame.QUIT:
                done = True
            if event.type == pygame.KEYUP or event.type == pygame.KEYDOWN:
                user_action = actions.get(event.key, PinballModel.ACC_NONE)

	if environment.take_action(user_action) == environment.END_EPISODE:
	    done = True

        environment_view.blit()

        pygame.display.flip()

    pygame.quit()

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Pinball domain')
    parser.add_argument('configuration', help='the configuration file')
    parser.add_argument('--width', action='store', type=int,
                        default=500, help='screen width (default: 500)')
    parser.add_argument('--height', action='store', type=int,
                        default=500, help='screen height (default: 500)')
    parser.add_argument('-r', '--rlglue', action='store_true', help='expose the environment through RL-Glue')
    args = parser.parse_args()

    if args.rlglue:
	print 'Starting rl-glue'
	EnvironmentLoader.loadEnvironment(PinballRLGlue(args.configuration))
    else:
        run_pinballview(args.width, args.height, args.configuration)

開發者ID:AAHays,項目名稱:python-rl,代碼行數:31,代碼來源:pinball.py

示例7: env_cleanup

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
		return returnRO

	def env_cleanup(self):
		pass

	def env_message(self,inMessage):
		return "I don't know how to respond to your message";

def addTaxiArgs(parser):
	parser.add_argument("--size_x", type=float, default=5, help="Size of the gridworld in the x (horizontal) dimension, where 1.0 is the unit of movement.")
	parser.add_argument("--size_y", type=float, default=5, help="Size of the gridworld in the y (vertical) dimension, where 1.0 is the unit of movement.")
	parser.add_argument("--landmark", action="append", nargs=2, help="Add a landmark, give x y coordinates", type=float)
	parser.add_argument("--wall", type=float, action="append", nargs=2, help="Add a wall, give x coordinate and size in y with sign indicating starting at the bottom (+) or top (-)")
	parser.add_argument("--fuel_loc", type=float, default=[2.0, 1.0], nargs=2, help="x y coordinate of the fuel station")
	parser.add_argument("--fickleness", type=float, default=0, help="Probability of the passenger changing their destination mid-route.")
	parser.add_argument("--noise", type=float, default=0, help="Standard deviation of additive noise to generate")
	parser.add_argument("--fudge", type=float, default=1.4143, help="Distance from goal allowed before episode is counted as finished")


if __name__=="__main__":
	import argparse
	parser = argparse.ArgumentParser(description='Run 2D Noisy Continuous Gridworld environment in network mode.')
	addTaxiArgs(parser)
	args = parser.parse_args()
	fuelloc = None if args.fuel_loc[0] < 0 else args.fuel_loc
	walls = numpy.array(args.wall) if args.wall is not None else None
	landmarks = numpy.array(args.landmark) if args.landmark is not None else None
	EnvironmentLoader.loadEnvironment(Taxi(args.size_x, args.size_y, walls=walls, landmarks=landmarks, fuel_loc=fuelloc, fickleness=args.fickleness, noise=args.noise, fudge=args.fudge))

開發者ID:AAHays,項目名稱:python-rl,代碼行數:30,代碼來源:taxi.py

示例8: env_cleanup

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
		return returnRO

	def env_cleanup(self):
		pass

	def env_message(self,inMessage):
		return "I don't know how to respond to your message";

if __name__=="__main__":
	import argparse
        path_to_problems = os.path.join(os.path.dirname(__file__), 'configs', 'pomdps', '*')
        config_files = glob.glob(path_to_problems)
	parser = argparse.ArgumentParser(description='Run a POMDP problem file as a domain in RL-Glue in network mode.')
        group = parser.add_mutually_exclusive_group(required=True)
	group.add_argument("--file", type=str, default=config_files[0], 
                           help="Run POMDP domain given the path to a POMDP problem file.")
        group.add_argument("--list", action='store_true', default=False, help="List path to included POMDP problem files.")
	args = parser.parse_args()

        if args.list:
            print "Included POMDP problem files:"
            for file in config_files:
                print file
        else:
            EnvironmentLoader.loadEnvironment(POMDPEnvironment(spec_filename=args.file))

	parser = argparse.ArgumentParser(description='Run a specified POMDP in RL-Glue in network mode.')
	parser.add_argument("--pomdp_file", type=str, help="Filename for POMDP spec file to load and use.", required=True)
	args = parser.parse_args()
	EnvironmentLoader.loadEnvironment(POMDPEnvironment(args.pomdp_file))
開發者ID:AAHays,項目名稱:python-rl,代碼行數:32,代碼來源:pomdp.py

示例9: RandomEnvironment

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
"""
Random player environment
"""

import random
from rlglue.environment import EnvironmentLoader
from wrapper_environment import WrapperEnvironment

class RandomEnvironment(WrapperEnvironment):
    
    name = 'random'
    
    def env_play(self):
        """
        Pick the first free spot, and play there.
        """
        open_spots = []
        for i in range(len(self.state)):
            if self.state[i] == 0:
                open_spots.append(i)
        self.state[random.choice(open_spots)] = self.color

if __name__ == "__main__":
    EnvironmentLoader.loadEnvironment(RandomEnvironment())
開發者ID:okkhoy,項目名稱:gabe-and-joh,代碼行數:26,代碼來源:random_environment.py

示例10: int

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
		returnRO.terminal = int(self.counter >= self.T)

		return returnRO

	def env_cleanup(self):
		pass

	def env_message(self,inMessage):
		return "I don't know how to respond to your message";


if __name__=="__main__":
	import argparse
	parser = argparse.ArgumentParser(description='Run 2D Noisy Continuous Gridworld environment in network mode.')
	parser.add_argument("--demand_mean", type=float, default=10., help="Mean demand for the product.")
	parser.add_argument("--demand_std", type=float, default=1., 
			    help="Standard deviation of demand for the product.")
	parser.add_argument("--payoff", type=float, default=5., help="Payment received per unit product sold.")
	parser.add_argument("--cost", type=float, default=2., help="Cost per unit product purchased.")
	parser.add_argument("--discount_factor", type=float, default=0.999, help="Discount factor to learn over.")
	parser.add_argument("--time_period", type=int, default=20, help="Time period for problem. (Number of steps to run)")
	parser.add_argument("--noise", type=float, default=0, help="Standard deviation of additive noise to generate")
	args = parser.parse_args()
	EnvironmentLoader.loadEnvironment(BatchReplenishment(demand_mean=args.demand_mean, 
							     demand_std=args.demand_std, 
							     payoff=args.payoff, 
							     cost=args.cost, 
							     gamma=args.discount_factor,
							     time_period = args.time_period,
							     noise=args.noise))
開發者ID:AAHays,項目名稱:python-rl,代碼行數:32,代碼來源:batch_replenish.py

示例11: env_cleanup

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
            theReward=-1
            episodeOver=1

        if self.currentState >= 20:
            self.currentState=20
            theReward=1
            episodeOver=1

        theObs=Observation()
        theObs.intArray=[self.currentState]

        returnRO=Reward_observation_terminal()
        returnRO.r=theReward
        returnRO.o=theObs
        returnRO.terminal=episodeOver

        return returnRO

    def env_cleanup(self):
        pass

    def env_message(self,inMessage):
        if inMessage=="what is your name?":
            return "my name is skeleton_environment, Python edition!";
        else:
            return "I don't know how to respond to your message";


if __name__=="__main__":
    EnvironmentLoader.loadEnvironment(skeleton_environment())
開發者ID:AAHays,項目名稱:python-rl,代碼行數:32,代碼來源:skeleton_environment.py

示例12: Observation

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
        if self.reward_noise > 0:
            theReward += numpy.random.normal(scale=self.reward_noise)

        theObs = Observation()
        theObs.doubleArray = self.state.tolist()

        returnRO = Reward_observation_terminal()
        returnRO.r = theReward
        returnRO.o = theObs
        returnRO.terminal = episodeOver

        return returnRO

    def env_cleanup(self):
        pass

    def env_message(self,inMessage):
        return "I don't know how to respond to your message";


if __name__=="__main__":
    import argparse
    parser = argparse.ArgumentParser(description='Run Noisy Acrobot environment in network mode.')
    parser.add_argument("--noise", type=float, default=0, help="Standard deviation of additive noise to generate, affects the action effects.")
    parser.add_argument("--random_restarts", type=bool, default=False, help="Restart the state with random values.")

    args = parser.parse_args()
    EnvironmentLoader.loadEnvironment(Acrobot(noise=args.noise, random_start=args.random_restarts))

開發者ID:AAHays,項目名稱:python-rl,代碼行數:30,代碼來源:acrobot.py

示例13: env_cleanup

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
			theReward=-1
			episodeOver=1

		if self.currentState >= 20:
			self.currentState=20
			theReward=1
			episodeOver=1
		
		theObs=Observation()
		theObs.intArray=[self.currentState]
		
		returnRO=Reward_observation_terminal()
		returnRO.r=theReward
		returnRO.o=theObs
		returnRO.terminal=episodeOver
		
		return returnRO

	def env_cleanup(self):
		pass

	def env_message(self,inMessage):
		if inMessage=="what is your name?":
			return "my name is dqn_environment, Python edition!";
		else:
			return "I don't know how to respond to your message";


if __name__=="__main__":
	EnvironmentLoader.loadEnvironment(dqn_environment())
開發者ID:hashima,項目名稱:DQN_Framework,代碼行數:32,代碼來源:dqn_environment.py

示例14: env_cleanup

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
        returnRO.r = theReward
        returnRO.o = theObs
        returnRO.terminal = episodeOver

        return returnRO

    def env_cleanup(self):
        pass

    def env_message(self,inMessage):
        return "I don't know how to respond to your message";

@register_environment
class MountainCar(MountainCarND):
    name = "Mountain Car"

    def __init__(self, **kwargs):
        kwargs['dimension'] = 2
        super(MountainCar, self).__init__(**kwargs)


if __name__=="__main__":
    import argparse
    parser = argparse.ArgumentParser(description='Run Noisy Mountain Car environment in network mode.')
    parser.add_argument("--noise", type=float, default=0, help="Standard deviation of additive noise to generate, affects the action effects.")
    parser.add_argument("--random_restarts", type=bool, default=False, help="Restart the cart with a random location and velocity.")

    args = parser.parse_args()
    EnvironmentLoader.loadEnvironment(MountainCar(noise=args.noise, random_start=args.random_restarts))

開發者ID:AAHays,項目名稱:python-rl,代碼行數:31,代碼來源:mountaincar.py

示例15: SymmetryEnvironment

# 需要導入模塊: from rlglue.environment import EnvironmentLoader [as 別名]
# 或者: from rlglue.environment.EnvironmentLoader import loadEnvironment [as 別名]
"""
MENACE agent environment wrapper
"""

import sys

# Ugly!
sys.path.append('../')

from agents.symmetry_agent import SymmetryAgent
from wrapper_environment import WrapperEnvironment
from rlglue.environment import EnvironmentLoader

class SymmetryEnvironment(WrapperEnvironment, SymmetryAgent):
    
    name = 'symmetry_agent'
    
    player = 2
    def env_play(self): 
        action = self.do_step(self.state)
        self.state = action.intArray
        

if __name__ == "__main__":
    EnvironmentLoader.loadEnvironment(SymmetryEnvironment())
開發者ID:okkhoy,項目名稱:gabe-and-joh,代碼行數:27,代碼來源:symmetry_agent_environment.py


注:本文中的rlglue.environment.EnvironmentLoader.loadEnvironment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。