Esempio n. 1
0
 def __init__(self, name, globalAC, sess, conn):
     self.conn = conn
     self.env = GameEnv(conn=self.conn)
     self.name = name
     self.AC = ACNet(name, sess, globalAC)
     self.sess = sess
Esempio n. 2
0
import krpc
import time
from ksp_env import GameEnv
import math
import numpy as np
from config import ip

conn = krpc.connect(name='Tracker', ip=ip)
env = GameEnv(conn)
vessel = env.vessel

frame = vessel.orbit.body.reference_frame
vert_speed = conn.add_stream(getattr, vessel.flight(frame), 'vertical_speed')


def states():
    message = ('sin',
               round(
                   math.sin((math.radians(env.heading()))) *
                   (90 - env.pitch()) / 90, 2), 'cos',
               round(
                   math.cos((math.radians(env.heading()))) *
                   (90 - env.pitch()) / 90, 2), 'sinr',
               round(
                   math.sin((math.radians(env.heading() + env.roll()))) *
                   (90 - env.pitch()) / 90, 2), 'cosr',
               round(
                   math.cos((math.radians(env.heading() + env.roll()))) *
                   (90 - env.pitch()) / 90,
                   2), "p", round(env.pitch(),
                                  2), "h", round(env.heading(), 2), "r",
Esempio n. 3
0
import numpy as np
import csv
import os
import shutil
import tensorflow as tf
import krpc

from config import OUTPUT_GRAPH, LOG_DIR, result_file, fieldnames, N_WORKERS, MAX_EP_STEP, GLOBAL_NET_SCOPE, \
    UPDATE_GLOBAL_ITER, GAMMA, ENTROPY_BETA, LR_A, LR_C, conns
from ksp_env import GameEnv

print(conns)
connections = [krpc.connect(**conns[i]) for i in range(N_WORKERS)]
# connections = [krpc.connect()]

env = GameEnv(conn=connections[0])
env.reset(connections[0])

NUM_STATES = env.observation_space.shape[0]
NUM_ACTIONS = env.action_space.shape[0]
ACTION_BOUND = [env.action_space.low, env.action_space.high]

# Network for the Actor Critic
class ACNet(object):
    def __init__(self, scope, sess, globalAC=None):
        self.sess = sess
        self.actor_optimizer = tf.train.RMSPropOptimizer(LR_A, name='RMSPropA')
        self.critic_optimizer = tf.train.RMSPropOptimizer(LR_C, name='RMSPropC')

        if scope == GLOBAL_NET_SCOPE:
            with tf.variable_scope(scope):