A differentiable Pong game environment for RL experimentation in Julia.
] add https://github.com/kraftpunk97/DiffPong.jl#master
Vector_(x::Float32, y::Float32)
Player(length::Float32, position::Vector_, velocity::Int, score::Int)
Ball(position::Vector_, velocity::Vector_, radius::Float32)
Arena(dims::Vector_, margin::Vector_)
Env(arena::Arena, player_a::Player, player_b::Player, ball:Ball)
wall_collision!
paddle_collision!
rebound
- Updates the direction of the velocity of ball when collision occurs.
draw_rectangle!
- Accepts anArray{UInt8, 2}
and draws a rectangle at positionx, y
of widthw
and heighth
.get_obs
- Converts the current game state into a 2DArray{UInt8, 2}
dot matrix image.get_score
update_paddle_position!
- Based on given input, changes the position of the paddle.render
reset_ball!
- Resets the ball's position at the end of the round.human_action
- Processes human input.ai_action
step!
reset!
As of writing this demo script, the rendering works only when you run the script within the Juno IDE. Other visualization options will/may be added in the future.
julia> using DiffPong
julia> env = Env()
julia> reset!(env)
julia> for _=1:100
state, reward, done, _ = step!(env, rand(1:3));
render(env) |> display;
sleep(0.01)
end