Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
Open_Ai_Gym_Autobahn_Auffahren
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Midras Lappe
Open_Ai_Gym_Autobahn_Auffahren
Commits
d8672b34
Commit
d8672b34
authored
4 years ago
by
Theo Brockmann
Browse files
Options
Downloads
Patches
Plain Diff
Update Gym_new.py
parent
3847f611
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Gym_new.py
+22
-20
22 additions, 20 deletions
Gym_new.py
with
22 additions
and
20 deletions
Gym_new.py
+
22
−
20
View file @
d8672b34
...
@@ -24,48 +24,50 @@ class Gym:
...
@@ -24,48 +24,50 @@ class Gym:
self
.
logger
.
addHandler
(
logging
.
StreamHandler
())
self
.
logger
.
addHandler
(
logging
.
StreamHandler
())
print
(
'
New gym instance IP:
'
,
host
,
'
Port:
'
,
port
,
'
Playername:
'
,
player
)
print
(
'
New gym instance IP:
'
,
host
,
'
Port:
'
,
port
,
'
Playername:
'
,
player
)
# Call reset function of environment and returns observation
# Call reset function of environment and returns observation
, reward, done, info
# Send data to reset enviroment
# Send data to reset enviroment
async
def
reset
(
self
,
delta
):
async
def
reset
(
self
,
delta
):
message
=
json
.
dumps
([[
'
reset
'
],
delta
],
sort_keys
=
True
,
indent
=
4
)
message
=
json
.
dumps
([[
'
reset
'
],
delta
],
sort_keys
=
True
,
indent
=
4
)
data
=
[]
data
=
[]
await
self
.
send_websocket
(
message
,
data
)
await
self
.
send_websocket
(
message
,
data
)
test
=
json
.
loads
(
data
[
0
])
all_information
=
json
.
loads
(
data
[
0
])
reward
=
test
[
3
]
reward
=
all_information
[
3
]
observation
=
test
[
0
:
3
]
observation
=
all_information
[
0
:
3
]
done
=
test
[
4
]
done
=
all_information
[
4
]
info
=
0
info
=
all_information
[
5
]
return
observation
,
reward
,
done
,
info
return
observation
,
reward
,
done
,
info
# send action to env returns observation, reward, done, info
# send action to env returns observation, reward, done, info
# Obeservation is an array with the following information:
# [speed, steering-angle, [length of all sensors (starting straight and then clockwise around the car)]]
# creates JSON object
# creates JSON object
async
def
step
(
self
,
action
,
delta
):
async
def
step
(
self
,
action
,
delta
):
global
maxaction
global
maxaction
test_
message
=
[]
message
=
[]
if
action
.
find
(
"
accelerate
"
)
!=-
1
:
if
action
.
find
(
"
accelerate
"
)
!=-
1
:
test_
message
.
append
(
"
accelerate
"
)
message
.
append
(
"
accelerate
"
)
if
action
.
find
(
"
left
"
)
!=
-
1
:
if
action
.
find
(
"
left
"
)
!=
-
1
:
test_
message
.
append
(
"
steer_left
"
)
message
.
append
(
"
steer_left
"
)
if
action
.
find
(
"
right
"
)
!=
-
1
:
if
action
.
find
(
"
right
"
)
!=
-
1
:
test_
message
.
append
(
"
steer_right
"
)
message
.
append
(
"
steer_right
"
)
if
action
.
find
(
"
brake
"
)
!=
-
1
:
if
action
.
find
(
"
brake
"
)
!=
-
1
:
test_
message
.
append
(
"
brake
"
)
message
.
append
(
"
brake
"
)
if
action
.
find
(
"
reverse
"
)
!=
-
1
:
if
action
.
find
(
"
reverse
"
)
!=
-
1
:
test_
message
.
append
(
"
reverse
"
)
message
.
append
(
"
reverse
"
)
if
action
.
find
(
"
screen_on
"
)
!=
-
1
:
if
action
.
find
(
"
screen_on
"
)
!=
-
1
:
test_
message
.
append
(
"
screen_on
"
)
message
.
append
(
"
screen_on
"
)
if
action
.
find
(
"
screen_off
"
)
!=
-
1
:
if
action
.
find
(
"
screen_off
"
)
!=
-
1
:
test_
message
.
append
(
"
screen_off
"
)
message
.
append
(
"
screen_off
"
)
message
=
json
.
dumps
([
test_
message
,
delta
],
sort_keys
=
True
,
indent
=
4
)
message
=
json
.
dumps
([
message
,
delta
],
sort_keys
=
True
,
indent
=
4
)
data
=
[]
data
=
[]
await
self
.
send_websocket
(
message
,
data
)
await
self
.
send_websocket
(
message
,
data
)
test
=
json
.
loads
(
data
[
0
])
all_information
=
json
.
loads
(
data
[
0
])
reward
=
test
[
3
]
reward
=
all_information
[
3
]
observation
=
test
[
0
:
3
]
observation
=
all_information
[
0
:
3
]
done
=
test
[
4
]
done
=
all_information
[
4
]
info
=
test
[
5
]
info
=
all_information
[
5
]
return
observation
,
reward
,
done
,
info
return
observation
,
reward
,
done
,
info
async
def
connect_websocket
(
self
):
async
def
connect_websocket
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment