import{S as Fr,i as Dr,s as zr,e as o,k as c,w as y,t as n,M as Vr,c as a,d as t,m as d,a as s,x as v,h as r,b as p,N as Oe,G as l,g as h,y as b,L as Hr,q as M,o as _,B as E,v as qr}from"../../chunks/vendor-hf-doc-builder.js";import{I as se}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as Io}from"../../chunks/CodeBlock-hf-doc-builder.js";function Or(nn){let k,rl,A,C,bt,ne,So,Mt,Ro,il,I,re,Zo,Bo,_t,Wo,Lo,hl,Ke,xo,pl,f,ie,No,he,Co,Xo,$o,m,Qo,pe,Po,Yo,ce,Fo,Do,de,zo,Vo,fe,Ho,qo,Et,Oo,Ko,et,ea,jt,ta,la,ue,oa,Gt,aa,sa,na,me,ra,Tt,ia,ha,cl,w,pa,we,ca,da,ge,fa,ua,ye,ma,wa,dl,ve,ga,Ut,ya,fl,S,X,Jt,be,va,kt,ba,ul,$,Ma,At,_a,Ea,ml,Q,ja,It,Ga,Ta,wl,P,Ua,St,Ja,ka,gl,Me,rn,yl,R,Y,Rt,_e,Aa,Zt,Ia,vl,j,Sa,Ee,Ra,Za,Bt,Ba,Wa,bl,F,La,Wt,xa,Na,Ml,u,Ca,je,Xa,$a,Ge,Qa,Pa,Te,Ya,Fa,Ue,Da,za,_l,D,Va,Lt,Ha,qa,El,tt,Oa,jl,G,xt,Je,Ka,es,Nt,ke,ts,ls,Ct,Ae,os,Gl,Z,z,Xt,Ie,as,$t,ss,Tl,lt,ns,Ul,V,Qt,Se,rs,is,Pt,Re,hs,Jl,T,ps,Yt,cs,ds,Ft,fs,us,kl,ot,ms,Al,B,H,Dt,Ze,ws,zt,gs,Il,at,ys,Sl,st,vs,Rl,Be,hn,Zl,q,bs,We,Ms,_s,Bl,Le,pn,Wl,nt,Es,Ll,xe,cn,xl,W,O,Vt,Ne,js,Ht,Gs,Nl,rt,Ts,Cl,Ce,dn,Xl,U,Us,qt,Js,ks,Ot,As,Is,$l,Xe,fn,Ql,it,Ss,Pl,$e,Yl,ht,Rs,Fl,K,Zs,Kt,Bs,Ws,Dl,Qe,zl,pt,Ls,Vl,Pe,Hl,ct,xs,ql,ee,Ns,el,Cs,Xs,Ol,Ye,Kl,dt,$s,eo,Fe,Qs,tl,Ps,to,ft,Ys,lo,De,un,oo,ut,Fs,ao,L,te,ll,ze,Ds,ol,zs,so,le,Vs,Ve,Hs,qs,no,x,oe,al,He,Os,sl,Ks,ro,qe,en,mt,tn,io;return ne=new se({}),be=new se({}),_e=new se({}),Ie=new se({}),Ze=new se({}),Ne=new se({}),$e=new Io({props:{code:"JTIzLS0lMjBNZXRob2RzJTIwdGhhdCUyMG5lZWQlMjBpbXBsZW1lbnRpbmclMjB1c2luZyUyMHRoZSUyMCUyMmV4dGVuZCUyMHNjcmlwdCUyMiUyMG9wdGlvbiUyMGluJTIwR29kb3QlMjAtLSUyMyUwQWZ1bmMlMjBnZXRfb2JzKCklMjAtJTNFJTIwRGljdGlvbmFyeSUzQSUwQSUwOWFzc2VydChmYWxzZSUyQyUyMCUyMnRoZSUyMGdldF9vYnMlMjBtZXRob2QlMjBpcyUyMG5vdCUyMGltcGxlbWVudGVkJTIwd2hlbiUyMGV4dGVuZGluZyUyMGZyb20lMjBhaV9jb250cm9sbGVyJTIyKSUwQSUwOXJldHVybiUyMCU3QiUyMm9icyUyMiUzQSU1QiU1RCU3RCUwQSUwQWZ1bmMlMjBnZXRfcmV3YXJkKCklMjAtJTNFJTIwZmxvYXQlM0ElMEElMDlhc3NlcnQoZmFsc2UlMkMlMjAlMjJ0aGUlMjBnZXRfcmV3YXJkJTIwbWV0aG9kJTIwaXMlMjBub3QlMjBpbXBsZW1lbnRlZCUyMHdoZW4lMjBleHRlbmRpbmclMjBmcm9tJTIwYWlfY29udHJvbGxlciUyMiklMEElMDlyZXR1cm4lMjAwLjAlMEElMEFmdW5jJTIwZ2V0X2FjdGlvbl9zcGFjZSgpJTIwLSUzRSUyMERpY3Rpb25hcnklM0ElMEElMDlhc3NlcnQoZmFsc2UlMkMlMjAlMjJ0aGUlMjBnZXQlMjBnZXRfYWN0aW9uX3NwYWNlJTIwbWV0aG9kJTIwaXMlMjBub3QlMjBpbXBsZW1lbnRlZCUyMHdoZW4lMjBleHRlbmRpbmclMjBmcm9tJTIwYWlfY29udHJvbGxlciUyMiklMEElMDlyZXR1cm4lMjAlN0IlMEElMDklMDklMjJleGFtcGxlX2FjdGlvbnNfY29udGlub3VzJTIyJTIwJTNBJTIwJTdCJTBBJTA5JTA5JTA5JTIyc2l6ZSUyMiUzQSUyMDIlMkMlMEElMDklMDklMDklMjJhY3Rpb25fdHlwZSUyMiUzQSUyMCUyMmNvbnRpbnVvdXMlMjIlMEElMDklMDklN0QlMkMlMEElMDklMDklMjJleGFtcGxlX2FjdGlvbnNfZGlzY3JldGUlMjIlMjAlM0ElMjAlN0IlMEElMDklMDklMDklMjJzaXplJTIyJTNBJTIwMiUyQyUwQSUwOSUwOSUwOSUyMmFjdGlvbl90eXBlJTIyJTNBJTIwJTIyZGlzY3JldGUlMjIlMEElMDklMDklN0QlMkMlMEElMDklMDklN0QlMEElMEFmdW5jJTIwc2V0X2FjdGlvbihhY3Rpb24pJTIwLSUzRSUyMHZvaWQlM0ElMEElMDlhc3NlcnQoZmFsc2UlMkMlMjAlMjJ0aGUlMjBnZXQlMjBzZXRfYWN0aW9uJTIwbWV0aG9kJTIwaXMlMjBub3QlMjBpbXBsZW1lbnRlZCUyMHdoZW4lMjBleHRlbmRpbmclMjBmcm9tJTIwYWlfY29udHJvbGxlciUyMiklMEElMjMlMjAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSUyMw==",highlighted:`<span class="hljs-comment">#-- Methods that need implementing using the &quot;extend script&quot; option in Godot --#</span>
func get_obs() -&gt; Dictionary:
	<span class="hljs-keyword">assert</span>(false, <span class="hljs-string">&quot;the get_obs method is not implemented when extending from ai_controller&quot;</span>)
	<span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;obs&quot;</span>:[]}

func get_reward() -&gt; <span class="hljs-built_in">float</span>:
	<span class="hljs-keyword">assert</span>(false, <span class="hljs-string">&quot;the get_reward method is not implemented when extending from ai_controller&quot;</span>)
	<span class="hljs-keyword">return</span> <span class="hljs-number">0.0</span>

func get_action_space() -&gt; Dictionary:
	<span class="hljs-keyword">assert</span>(false, <span class="hljs-string">&quot;the get get_action_space method is not implemented when extending from ai_controller&quot;</span>)
	<span class="hljs-keyword">return</span> {
		<span class="hljs-string">&quot;example_actions_continous&quot;</span> : {
			<span class="hljs-string">&quot;size&quot;</span>: <span class="hljs-number">2</span>,
			<span class="hljs-string">&quot;action_type&quot;</span>: <span class="hljs-string">&quot;continuous&quot;</span>
		},
		<span class="hljs-string">&quot;example_actions_discrete&quot;</span> : {
			<span class="hljs-string">&quot;size&quot;</span>: <span class="hljs-number">2</span>,
			<span class="hljs-string">&quot;action_type&quot;</span>: <span class="hljs-string">&quot;discrete&quot;</span>
		},
		}

func set_action(action) -&gt; void:
	<span class="hljs-keyword">assert</span>(false, <span class="hljs-string">&quot;the get set_action method is not implemented when extending from ai_controller&quot;</span>)
<span class="hljs-comment"># -----------------------------------------------------------------------------#</span>`}}),Qe=new Io({props:{code:"ZXh0ZW5kcyUyMEFJQ29udHJvbGxlcjNEJTBBJTBBJTIzJTIwQ2FsbGVkJTIwd2hlbiUyMHRoZSUyMG5vZGUlMjBlbnRlcnMlMjB0aGUlMjBzY2VuZSUyMHRyZWUlMjBmb3IlMjB0aGUlMjBmaXJzdCUyMHRpbWUuJTBBZnVuYyUyMF9yZWFkeSgpJTNBJTBBJTA5cGFzcyUyMCUyMyUyMFJlcGxhY2UlMjB3aXRoJTIwZnVuY3Rpb24lMjBib2R5LiUwQSUwQSUyMyUyMENhbGxlZCUyMGV2ZXJ5JTIwZnJhbWUuJTIwJ2RlbHRhJyUyMGlzJTIwdGhlJTIwZWxhcHNlZCUyMHRpbWUlMjBzaW5jZSUyMHRoZSUyMHByZXZpb3VzJTIwZnJhbWUuJTBBZnVuYyUyMF9wcm9jZXNzKGRlbHRhKSUzQSUwQSUwOXBhc3M=",highlighted:`extends AIController3D

<span class="hljs-comment"># Called when the node enters the scene tree for the first time.</span>
func _ready():
	<span class="hljs-keyword">pass</span> <span class="hljs-comment"># Replace with function body.</span>

<span class="hljs-comment"># Called every frame. &#x27;delta&#x27; is the elapsed time since the previous frame.</span>
func _process(delta):
	<span class="hljs-keyword">pass</span>`}}),Pe=new Io({props:{code:"ZXh0ZW5kcyUyMEFJQ29udHJvbGxlcjNEJTBBJTBBJTIzJTIwU3RvcmVzJTIwdGhlJTIwYWN0aW9uJTIwc2FtcGxlZCUyMGZvciUyMHRoZSUyMGFnZW50J3MlMjBwb2xpY3klMkMlMjBydW5uaW5nJTIwaW4lMjBweXRob24lMEF2YXIlMjBtb3ZlX2FjdGlvbiUyMCUzQSUyMGZsb2F0JTIwJTNEJTIwMC4wJTBBJTBBZnVuYyUyMGdldF9vYnMoKSUyMC0lM0UlMjBEaWN0aW9uYXJ5JTNBJTBBJTA5JTIzJTIwZ2V0JTIwdGhlJTIwYmFsbHMlMjBwb3NpdGlvbiUyMGFuZCUyMHZlbG9jaXR5JTIwaW4lMjB0aGUlMjBwYWRkbGUncyUyMGZyYW1lJTIwb2YlMjByZWZlcmVuY2UlMEElMDl2YXIlMjBiYWxsX3BvcyUyMCUzRCUyMHRvX2xvY2FsKF9wbGF5ZXIuYmFsbC5nbG9iYWxfcG9zaXRpb24pJTBBJTA5dmFyJTIwYmFsbF92ZWwlMjAlM0QlMjB0b19sb2NhbChfcGxheWVyLmJhbGwubGluZWFyX3ZlbG9jaXR5KSUwQSUwOXZhciUyMG9icyUyMCUzRCUyMCU1QmJhbGxfcG9zLnglMkMlMjBiYWxsX3Bvcy56JTJDJTIwYmFsbF92ZWwueCUyRjEwLjAlMkMlMjBiYWxsX3ZlbC56JTJGMTAuMCU1RCUwQSUwQSUwOXJldHVybiUyMCU3QiUyMm9icyUyMiUzQW9icyU3RCUwQSUwQWZ1bmMlMjBnZXRfcmV3YXJkKCklMjAtJTNFJTIwZmxvYXQlM0ElMEElMDlyZXR1cm4lMjByZXdhcmQlMEElMEFmdW5jJTIwZ2V0X2FjdGlvbl9zcGFjZSgpJTIwLSUzRSUyMERpY3Rpb25hcnklM0ElMEElMDlyZXR1cm4lMjAlN0IlMEElMDklMDklMjJtb3ZlX2FjdGlvbiUyMiUyMCUzQSUyMCU3QiUwQSUwOSUwOSUwOSUyMnNpemUlMjIlM0ElMjAxJTJDJTBBJTA5JTA5JTA5JTIyYWN0aW9uX3R5cGUlMjIlM0ElMjAlMjJjb250aW51b3VzJTIyJTBBJTA5JTA5JTdEJTJDJTBBJTA5JTA5JTdEJTBBJTBBZnVuYyUyMHNldF9hY3Rpb24oYWN0aW9uKSUyMC0lM0UlMjB2b2lkJTNBJTBBJTA5bW92ZV9hY3Rpb24lMjAlM0QlMjBjbGFtcChhY3Rpb24lNUIlMjJtb3ZlX2FjdGlvbiUyMiU1RCU1QjAlNUQlMkMlMjAtMS4wJTJDJTIwMS4wKQ==",highlighted:`extends AIController3D

<span class="hljs-comment"># Stores the action sampled for the agent&#x27;s policy, running in python</span>
var move_action : <span class="hljs-built_in">float</span> = <span class="hljs-number">0.0</span>

func get_obs() -&gt; Dictionary:
	<span class="hljs-comment"># get the balls position and velocity in the paddle&#x27;s frame of reference</span>
	var ball_pos = to_local(_player.ball.global_position)
	var ball_vel = to_local(_player.ball.linear_velocity)
	var obs = [ball_pos.x, ball_pos.z, ball_vel.x/<span class="hljs-number">10.0</span>, ball_vel.z/<span class="hljs-number">10.0</span>]

	<span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;obs&quot;</span>:obs}

func get_reward() -&gt; <span class="hljs-built_in">float</span>:
	<span class="hljs-keyword">return</span> reward

func get_action_space() -&gt; Dictionary:
	<span class="hljs-keyword">return</span> {
		<span class="hljs-string">&quot;move_action&quot;</span> : {
			<span class="hljs-string">&quot;size&quot;</span>: <span class="hljs-number">1</span>,
			<span class="hljs-string">&quot;action_type&quot;</span>: <span class="hljs-string">&quot;continuous&quot;</span>
		},
		}

func set_action(action) -&gt; void:
	move_action = clamp(action[<span class="hljs-string">&quot;move_action&quot;</span>][<span class="hljs-number">0</span>], -<span class="hljs-number">1.0</span>, <span class="hljs-number">1.0</span>)`}}),Ye=new Io({props:{code:"ZXh0ZW5kcyUyME5vZGUzRCUwQSUwQSU0MGV4cG9ydCUyMHZhciUyMHJvdGF0aW9uX3NwZWVkJTIwJTNEJTIwMy4wJTBBJTQwb25yZWFkeSUyMHZhciUyMGJhbGwlMjAlM0QlMjBnZXRfbm9kZSglMjIuLiUyRkJhbGwlMjIpJTBBJTQwb25yZWFkeSUyMHZhciUyMGFpX2NvbnRyb2xsZXIlMjAlM0QlMjAlMjRBSUNvbnRyb2xsZXIzRCUwQSUwQWZ1bmMlMjBfcmVhZHkoKSUzQSUwQSUwOWFpX2NvbnRyb2xsZXIuaW5pdChzZWxmKSUwQSUwQWZ1bmMlMjBnYW1lX292ZXIoKSUzQSUwQSUwOWFpX2NvbnRyb2xsZXIuZG9uZSUyMCUzRCUyMHRydWUlMEElMDlhaV9jb250cm9sbGVyLm5lZWRzX3Jlc2V0JTIwJTNEJTIwdHJ1ZSUwQSUwQWZ1bmMlMjBfcGh5c2ljc19wcm9jZXNzKGRlbHRhKSUzQSUwQSUwOWlmJTIwYWlfY29udHJvbGxlci5uZWVkc19yZXNldCUzQSUwQSUwOSUwOWFpX2NvbnRyb2xsZXIucmVzZXQoKSUwQSUwOSUwOWJhbGwucmVzZXQoKSUwQSUwOSUwOXJldHVybiUwQSUwQSUwOXZhciUyMG1vdmVtZW50JTIwJTNBJTIwZmxvYXQlMEElMDlpZiUyMGFpX2NvbnRyb2xsZXIuaGV1cmlzdGljJTIwJTNEJTNEJTIwJTIyaHVtYW4lMjIlM0ElMEElMDklMDltb3ZlbWVudCUyMCUzRCUyMElucHV0LmdldF9heGlzKCUyMnJvdGF0ZV9hbnRpY2xvY2t3aXNlJTIyJTJDJTIwJTIycm90YXRlX2Nsb2Nrd2lzZSUyMiklMEElMDllbHNlJTNBJTBBJTA5JTA5bW92ZW1lbnQlMjAlM0QlMjBhaV9jb250cm9sbGVyLm1vdmVfYWN0aW9uJTBBJTA5cm90YXRlX3kobW92ZW1lbnQqZGVsdGEqcm90YXRpb25fc3BlZWQpJTBBJTBBZnVuYyUyMF9vbl9hcmVhXzNkX2JvZHlfZW50ZXJlZChib2R5KSUzQSUwQSUwOWFpX2NvbnRyb2xsZXIucmV3YXJkJTIwJTJCJTNEJTIwMS4w",highlighted:`extends Node3D

<span class="hljs-meta">@export var rotation_speed = <span class="hljs-number">3.0</span></span>
<span class="hljs-meta">@onready var ball = get_node(<span class="hljs-params"><span class="hljs-string">&quot;../Ball&quot;</span></span>)</span>
<span class="hljs-meta">@onready var ai_controller = $AIController3D</span>

func _ready():
	ai_controller.init(self)

func game_over():
	ai_controller.done = true
	ai_controller.needs_reset = true

func _physics_process(delta):
	<span class="hljs-keyword">if</span> ai_controller.needs_reset:
		ai_controller.reset()
		ball.reset()
		<span class="hljs-keyword">return</span>

	var movement : <span class="hljs-built_in">float</span>
	<span class="hljs-keyword">if</span> ai_controller.heuristic == <span class="hljs-string">&quot;human&quot;</span>:
		movement = Input.get_axis(<span class="hljs-string">&quot;rotate_anticlockwise&quot;</span>, <span class="hljs-string">&quot;rotate_clockwise&quot;</span>)
	<span class="hljs-keyword">else</span>:
		movement = ai_controller.move_action
	rotate_y(movement*delta*rotation_speed)

func _on_area_3d_body_entered(body):
	ai_controller.reward += <span class="hljs-number">1.0</span>`}}),ze=new se({}),He=new se({}),{c(){k=o("meta"),rl=c(),A=o("h1"),C=o("a"),bt=o("span"),y(ne.$$.fragment),So=c(),Mt=o("span"),Ro=n("Godot RL Agents"),il=c(),I=o("p"),re=o("a"),Zo=n("Godot RL Agents"),Bo=n(" is an Open Source package that allows video game creators, AI researchers, and hobbyists the opportunity "),_t=o("strong"),Wo=n("to learn complex behaviors for their Non Player Characters or agents"),Lo=n("."),hl=c(),Ke=o("p"),xo=n("The library provides:"),pl=c(),f=o("ul"),ie=o("li"),No=n("An interface between games created in the\xA0"),he=o("a"),Co=n("Godot Engine"),Xo=n("\xA0and Machine Learning algorithms running in Python"),$o=c(),m=o("li"),Qo=n("Wrappers for four well known rl frameworks: "),pe=o("a"),Po=n("StableBaselines3"),Yo=n(", "),ce=o("a"),Fo=n("CleanRL"),Do=n(", "),de=o("a"),zo=n("Sample Factory"),Vo=n(" and\xA0"),fe=o("a"),Ho=n("Ray RLLib"),qo=c(),Et=o("li"),Oo=n("Support for memory-based agents with LSTM or attention based interfaces"),Ko=c(),et=o("li"),ea=n("Support for "),jt=o("em"),ta=n("2D and 3D games"),la=c(),ue=o("li"),oa=n("A suite of "),Gt=o("em"),aa=n("AI sensors"),sa=n(" to augment your agent\u2019s capacity to observe the game world"),na=c(),me=o("li"),ra=n("Godot and Godot RL Agents are "),Tt=o("strong"),ia=n("completely free and open source under a very permissive MIT license"),ha=n(". No strings attached, no royalties, nothing."),cl=c(),w=o("p"),pa=n("You can find out more about Godot RL agents on their "),we=o("a"),ca=n("GitHub page"),da=n(" or their AAAI-2022 Workshop\xA0"),ge=o("a"),fa=n("paper"),ua=n(". The library\u2019s creator, "),ye=o("a"),ma=n("Ed Beeching"),wa=n(", is a Research Scientist here at Hugging Face."),dl=c(),ve=o("p"),ga=n("Installation of the library is simple: "),Ut=o("code"),ya=n("pip install godot-rl"),fl=c(),S=o("h2"),X=o("a"),Jt=o("span"),y(be.$$.fragment),va=c(),kt=o("span"),ba=n("Create a custom RL environment with Godot RL Agents"),ul=c(),$=o("p"),Ma=n("In this section, you will "),At=o("strong"),_a=n("learn how to create a custom environment in the Godot Game Engine"),Ea=n(" and then implement an AI controller that learns to play with Deep Reinforcement Learning."),ml=c(),Q=o("p"),ja=n("The example game we create today is simple, "),It=o("strong"),Ga=n("but shows off many of the features of the Godot Engine and the Godot RL Agents library"),Ta=n(". You can then dive into the examples for more complex environments and behaviors."),wl=c(),P=o("p"),Ua=n("The environment we will be building today is called Ring Pong, the game of pong but the pitch is a ring and the paddle moves around the ring. The "),St=o("strong"),Ja=n("objective is to keep the ball bouncing inside the ring"),ka=n("."),gl=c(),Me=o("img"),yl=c(),R=o("h3"),Y=o("a"),Rt=o("span"),y(_e.$$.fragment),Aa=c(),Zt=o("span"),Ia=n("Installing the Godot Game Engine"),vl=c(),j=o("p"),Sa=n("The "),Ee=o("a"),Ra=n("Godot game engine"),Za=n(" is an open source tool for the "),Bt=o("strong"),Ba=n("creation of video games, tools and user interfaces"),Wa=n("."),bl=c(),F=o("p"),La=n("Godot Engine is a feature-packed, cross-platform game engine designed to create 2D and 3D games from a unified interface. It provides a comprehensive set of common tools, so users "),Wt=o("strong"),xa=n("can focus on making games without having to reinvent the wheel"),Na=n(". Games can be exported in one click to a number of platforms, including the major desktop platforms (Linux, macOS, Windows) as well as mobile (Android, iOS) and web-based (HTML5) platforms."),Ml=c(),u=o("p"),Ca=n("While we will guide you through the steps to implement your agent, you may wish to learn more about the Godot Game Engine. Their "),je=o("a"),Xa=n("documentation"),$a=n(" is thorough, and there are many tutorials on YouTube we would also recommend "),Ge=o("a"),Qa=n("GDQuest"),Pa=n(", "),Te=o("a"),Ya=n("KidsCanCode"),Fa=n(" and "),Ue=o("a"),Da=n("Bramwell"),za=n(" as sources of information."),_l=c(),D=o("p"),Va=n("In order to create games in Godot, "),Lt=o("strong"),Ha=n("you must first download the editor"),qa=n(". Godot RL Agents supports the latest version of Godot, Godot 4.0."),El=c(),tt=o("p"),Oa=n("Which can be downloaded at the following links:"),jl=c(),G=o("ul"),xt=o("li"),Je=o("a"),Ka=n("Windows"),es=c(),Nt=o("li"),ke=o("a"),ts=n("Mac"),ls=c(),Ct=o("li"),Ae=o("a"),os=n("Linux"),Gl=c(),Z=o("h3"),z=o("a"),Xt=o("span"),y(Ie.$$.fragment),as=c(),$t=o("span"),ss=n("Loading the starter project"),Tl=c(),lt=o("p"),ns=n("We provide two versions of the codebase:"),Ul=c(),V=o("ul"),Qt=o("li"),Se=o("a"),rs=n("A starter project, to download and follow along for this tutorial"),is=c(),Pt=o("li"),Re=o("a"),hs=n("A final version of the project, for comparison and debugging."),Jl=c(),T=o("p"),ps=n("To load the project, in the Godot Project Manager click "),Yt=o("strong"),cs=n("Import"),ds=n(", navigate to where the files are located and load the "),Ft=o("strong"),fs=n("project.godot"),us=n(" file."),kl=c(),ot=o("p"),ms=n("If you press F5 or play in the editor, you should be able to play the game in human mode. There are several instances of the game running, this is because we want to speed up training our AI agent with many parallel environments."),Al=c(),B=o("h3"),H=o("a"),Dt=o("span"),y(Ze.$$.fragment),ws=c(),zt=o("span"),gs=n("Installing the Godot RL Agents plugin"),Il=c(),at=o("p"),ys=n("The Godot RL Agents plugin can be installed from the Github repo or with the Godot Asset Lib in the editor."),Sl=c(),st=o("p"),vs=n("First click on the AssetLib and search for \u201Crl\u201D"),Rl=c(),Be=o("img"),Zl=c(),q=o("p"),bs=n("Then click on Godot RL Agents, click Download and unselect the LICIENSE and "),We=o("a"),Ms=n("README.md"),_s=n(" files. Then click install."),Bl=c(),Le=o("img"),Wl=c(),nt=o("p"),Es=n("The Godot RL Agents plugin is now downloaded to your machine your machine. Now click on Project \u2192 Project settings and enable the addon:"),Ll=c(),xe=o("img"),xl=c(),W=o("h3"),O=o("a"),Vt=o("span"),y(Ne.$$.fragment),js=c(),Ht=o("span"),Gs=n("Adding the AI controller"),Nl=c(),rt=o("p"),Ts=n("We now want to add an AI controller to our game. Open the player.tscn scene, on the left you should see a hierarchy of nodes that looks like this:"),Cl=c(),Ce=o("img"),Xl=c(),U=o("p"),Us=n("Right click the "),qt=o("strong"),Js=n("Player"),ks=n(" node and click "),Ot=o("strong"),As=n("Add Child Node."),Is=n(" There are many nodes listed here, search for AIController3D and create it."),$l=c(),Xe=o("img"),Ql=c(),it=o("p"),Ss=n("The AI Controller Node should have been added to the scene tree, next to it is a scroll. Click on it to open the script that is attached to the AIController. The Godot game engine uses a scripting language called GDScript, which is syntactically similar to python. The script contains methods that need to be implemented in order to get our AI controller working."),Pl=c(),y($e.$$.fragment),Yl=c(),ht=o("p"),Rs=n("In order to implement these methods, we will need to create a class that inherits from AIController3D. This is easy to do in Godot, and is called \u201Cextending\u201D a class."),Fl=c(),K=o("p"),Zs=n("Right click the AIController3D Node and click \u201CExtend Script\u201D and call the new script "),Kt=o("code"),Bs=n("controller.gd"),Ws=n(". You should now have an almost empty script file that looks like this:"),Dl=c(),y(Qe.$$.fragment),zl=c(),pt=o("p"),Ls=n("We will now implement the 4 missing methods, delete this code, and replace it with the following:"),Vl=c(),y(Pe.$$.fragment),Hl=c(),ct=o("p"),xs=n("We have now defined the agent\u2019s observation, which is the position and velocity of the ball in its local cooridinate space. We have also defined the action space of the agent, which is a single contuninous value ranging from -1 to +1."),ql=c(),ee=o("p"),Ns=n("The next step is to update the Player\u2019s script to use the actions from the AIController, edit the Player\u2019s script by clicking on the scroll next to the player node, update the code in "),el=o("code"),Cs=n("Player.gd"),Xs=n(" to the following the following:"),Ol=c(),y(Ye.$$.fragment),Kl=c(),dt=o("p"),$s=n("We now need to synchronize between the game running in Godot and the neural network being trained in Python. Godot RL agents provides a node that does just that. Open the train.tscn scene, right click on the root node, and click \u201CAdd child node\u201D. Then, search for \u201Csync\u201D and add a Godot RL Agents Sync node. This node handles the communication between Python and Godot over TCP."),eo=c(),Fe=o("p"),Qs=n("You can run training live in the the editor, by first launching the python training with "),tl=o("code"),Ps=n("gdrl"),to=c(),ft=o("p"),Ys=n("In this simple example, a reasonable policy is learned in several minutes. You may wish to speed up training, click on the Sync node in the train scene and you will see there is a \u201CSpeed Up\u201D property exposed in the editor:"),lo=c(),De=o("img"),oo=c(),ut=o("p"),Fs=n("Try setting this property up to 8 to speed up training. This can be a great benefit on more complex environments, like the multi-player FPS we will learn about in the next chapter."),ao=c(),L=o("h3"),te=o("a"),ll=o("span"),y(ze.$$.fragment),Ds=c(),ol=o("span"),zs=n("There\u2019s more!"),so=c(),le=o("p"),Vs=n("We have only scratched the surface of what can be achieved with Godot RL Agents, the library includes custom sensors and cameras to enrich the information available to the agent. Take a look at the "),Ve=o("a"),Hs=n("examples"),qs=n(" to find out more!"),no=c(),x=o("h2"),oe=o("a"),al=o("span"),y(He.$$.fragment),Os=c(),sl=o("span"),Ks=n("Author"),ro=c(),qe=o("p"),en=n("This section was written by "),mt=o("a"),tn=n("Edward Beeching"),this.h()},l(e){const i=Vr('[data-svelte="svelte-1phssyn"]',document.head);k=a(i,"META",{name:!0,content:!0}),i.forEach(t),rl=d(e),A=a(e,"H1",{class:!0});var ho=s(A);C=a(ho,"A",{id:!0,class:!0,href:!0});var mn=s(C);bt=a(mn,"SPAN",{});var wn=s(bt);v(ne.$$.fragment,wn),wn.forEach(t),mn.forEach(t),So=d(ho),Mt=a(ho,"SPAN",{});var gn=s(Mt);Ro=r(gn,"Godot RL Agents"),gn.forEach(t),ho.forEach(t),il=d(e),I=a(e,"P",{});var nl=s(I);re=a(nl,"A",{href:!0,rel:!0});var yn=s(re);Zo=r(yn,"Godot RL Agents"),yn.forEach(t),Bo=r(nl," is an Open Source package that allows video game creators, AI researchers, and hobbyists the opportunity "),_t=a(nl,"STRONG",{});var vn=s(_t);Wo=r(vn,"to learn complex behaviors for their Non Player Characters or agents"),vn.forEach(t),Lo=r(nl,"."),nl.forEach(t),hl=d(e),Ke=a(e,"P",{});var bn=s(Ke);xo=r(bn,"The library provides:"),bn.forEach(t),pl=d(e),f=a(e,"UL",{});var g=s(f);ie=a(g,"LI",{});var po=s(ie);No=r(po,"An interface between games created in the\xA0"),he=a(po,"A",{href:!0,rel:!0});var Mn=s(he);Co=r(Mn,"Godot Engine"),Mn.forEach(t),Xo=r(po,"\xA0and Machine Learning algorithms running in Python"),po.forEach(t),$o=d(g),m=a(g,"LI",{});var N=s(m);Qo=r(N,"Wrappers for four well known rl frameworks: "),pe=a(N,"A",{href:!0,rel:!0});var _n=s(pe);Po=r(_n,"StableBaselines3"),_n.forEach(t),Yo=r(N,", "),ce=a(N,"A",{href:!0,rel:!0});var En=s(ce);Fo=r(En,"CleanRL"),En.forEach(t),Do=r(N,", "),de=a(N,"A",{href:!0,rel:!0});var jn=s(de);zo=r(jn,"Sample Factory"),jn.forEach(t),Vo=r(N," and\xA0"),fe=a(N,"A",{href:!0,rel:!0});var Gn=s(fe);Ho=r(Gn,"Ray RLLib"),Gn.forEach(t),N.forEach(t),qo=d(g),Et=a(g,"LI",{});var Tn=s(Et);Oo=r(Tn,"Support for memory-based agents with LSTM or attention based interfaces"),Tn.forEach(t),Ko=d(g),et=a(g,"LI",{});var ln=s(et);ea=r(ln,"Support for "),jt=a(ln,"EM",{});var Un=s(jt);ta=r(Un,"2D and 3D games"),Un.forEach(t),ln.forEach(t),la=d(g),ue=a(g,"LI",{});var co=s(ue);oa=r(co,"A suite of "),Gt=a(co,"EM",{});var Jn=s(Gt);aa=r(Jn,"AI sensors"),Jn.forEach(t),sa=r(co," to augment your agent\u2019s capacity to observe the game world"),co.forEach(t),na=d(g),me=a(g,"LI",{});var fo=s(me);ra=r(fo,"Godot and Godot RL Agents are "),Tt=a(fo,"STRONG",{});var kn=s(Tt);ia=r(kn,"completely free and open source under a very permissive MIT license"),kn.forEach(t),ha=r(fo,". No strings attached, no royalties, nothing."),fo.forEach(t),g.forEach(t),cl=d(e),w=a(e,"P",{});var ae=s(w);pa=r(ae,"You can find out more about Godot RL agents on their "),we=a(ae,"A",{href:!0,rel:!0});var An=s(we);ca=r(An,"GitHub page"),An.forEach(t),da=r(ae," or their AAAI-2022 Workshop\xA0"),ge=a(ae,"A",{href:!0,rel:!0});var In=s(ge);fa=r(In,"paper"),In.forEach(t),ua=r(ae,". The library\u2019s creator, "),ye=a(ae,"A",{href:!0,rel:!0});var Sn=s(ye);ma=r(Sn,"Ed Beeching"),Sn.forEach(t),wa=r(ae,", is a Research Scientist here at Hugging Face."),ae.forEach(t),dl=d(e),ve=a(e,"P",{});var on=s(ve);ga=r(on,"Installation of the library is simple: "),Ut=a(on,"CODE",{});var Rn=s(Ut);ya=r(Rn,"pip install godot-rl"),Rn.forEach(t),on.forEach(t),fl=d(e),S=a(e,"H2",{class:!0});var uo=s(S);X=a(uo,"A",{id:!0,class:!0,href:!0});var Zn=s(X);Jt=a(Zn,"SPAN",{});var Bn=s(Jt);v(be.$$.fragment,Bn),Bn.forEach(t),Zn.forEach(t),va=d(uo),kt=a(uo,"SPAN",{});var Wn=s(kt);ba=r(Wn,"Create a custom RL environment with Godot RL Agents"),Wn.forEach(t),uo.forEach(t),ul=d(e),$=a(e,"P",{});var mo=s($);Ma=r(mo,"In this section, you will "),At=a(mo,"STRONG",{});var Ln=s(At);_a=r(Ln,"learn how to create a custom environment in the Godot Game Engine"),Ln.forEach(t),Ea=r(mo," and then implement an AI controller that learns to play with Deep Reinforcement Learning."),mo.forEach(t),ml=d(e),Q=a(e,"P",{});var wo=s(Q);ja=r(wo,"The example game we create today is simple, "),It=a(wo,"STRONG",{});var xn=s(It);Ga=r(xn,"but shows off many of the features of the Godot Engine and the Godot RL Agents library"),xn.forEach(t),Ta=r(wo,". You can then dive into the examples for more complex environments and behaviors."),wo.forEach(t),wl=d(e),P=a(e,"P",{});var go=s(P);Ua=r(go,"The environment we will be building today is called Ring Pong, the game of pong but the pitch is a ring and the paddle moves around the ring. The "),St=a(go,"STRONG",{});var Nn=s(St);Ja=r(Nn,"objective is to keep the ball bouncing inside the ring"),Nn.forEach(t),ka=r(go,"."),go.forEach(t),gl=d(e),Me=a(e,"IMG",{src:!0,alt:!0}),yl=d(e),R=a(e,"H3",{class:!0});var yo=s(R);Y=a(yo,"A",{id:!0,class:!0,href:!0});var Cn=s(Y);Rt=a(Cn,"SPAN",{});var Xn=s(Rt);v(_e.$$.fragment,Xn),Xn.forEach(t),Cn.forEach(t),Aa=d(yo),Zt=a(yo,"SPAN",{});var $n=s(Zt);Ia=r($n,"Installing the Godot Game Engine"),$n.forEach(t),yo.forEach(t),vl=d(e),j=a(e,"P",{});var wt=s(j);Sa=r(wt,"The "),Ee=a(wt,"A",{href:!0,rel:!0});var Qn=s(Ee);Ra=r(Qn,"Godot game engine"),Qn.forEach(t),Za=r(wt," is an open source tool for the "),Bt=a(wt,"STRONG",{});var Pn=s(Bt);Ba=r(Pn,"creation of video games, tools and user interfaces"),Pn.forEach(t),Wa=r(wt,"."),wt.forEach(t),bl=d(e),F=a(e,"P",{});var vo=s(F);La=r(vo,"Godot Engine is a feature-packed, cross-platform game engine designed to create 2D and 3D games from a unified interface. It provides a comprehensive set of common tools, so users "),Wt=a(vo,"STRONG",{});var Yn=s(Wt);xa=r(Yn,"can focus on making games without having to reinvent the wheel"),Yn.forEach(t),Na=r(vo,". Games can be exported in one click to a number of platforms, including the major desktop platforms (Linux, macOS, Windows) as well as mobile (Android, iOS) and web-based (HTML5) platforms."),vo.forEach(t),Ml=d(e),u=a(e,"P",{});var J=s(u);Ca=r(J,"While we will guide you through the steps to implement your agent, you may wish to learn more about the Godot Game Engine. Their "),je=a(J,"A",{href:!0,rel:!0});var Fn=s(je);Xa=r(Fn,"documentation"),Fn.forEach(t),$a=r(J," is thorough, and there are many tutorials on YouTube we would also recommend "),Ge=a(J,"A",{href:!0,rel:!0});var Dn=s(Ge);Qa=r(Dn,"GDQuest"),Dn.forEach(t),Pa=r(J,", "),Te=a(J,"A",{href:!0,rel:!0});var zn=s(Te);Ya=r(zn,"KidsCanCode"),zn.forEach(t),Fa=r(J," and "),Ue=a(J,"A",{href:!0,rel:!0});var Vn=s(Ue);Da=r(Vn,"Bramwell"),Vn.forEach(t),za=r(J," as sources of information."),J.forEach(t),_l=d(e),D=a(e,"P",{});var bo=s(D);Va=r(bo,"In order to create games in Godot, "),Lt=a(bo,"STRONG",{});var Hn=s(Lt);Ha=r(Hn,"you must first download the editor"),Hn.forEach(t),qa=r(bo,". Godot RL Agents supports the latest version of Godot, Godot 4.0."),bo.forEach(t),El=d(e),tt=a(e,"P",{});var qn=s(tt);Oa=r(qn,"Which can be downloaded at the following links:"),qn.forEach(t),jl=d(e),G=a(e,"UL",{});var gt=s(G);xt=a(gt,"LI",{});var On=s(xt);Je=a(On,"A",{href:!0,rel:!0});var Kn=s(Je);Ka=r(Kn,"Windows"),Kn.forEach(t),On.forEach(t),es=d(gt),Nt=a(gt,"LI",{});var er=s(Nt);ke=a(er,"A",{href:!0,rel:!0});var tr=s(ke);ts=r(tr,"Mac"),tr.forEach(t),er.forEach(t),ls=d(gt),Ct=a(gt,"LI",{});var lr=s(Ct);Ae=a(lr,"A",{href:!0,rel:!0});var or=s(Ae);os=r(or,"Linux"),or.forEach(t),lr.forEach(t),gt.forEach(t),Gl=d(e),Z=a(e,"H3",{class:!0});var Mo=s(Z);z=a(Mo,"A",{id:!0,class:!0,href:!0});var ar=s(z);Xt=a(ar,"SPAN",{});var sr=s(Xt);v(Ie.$$.fragment,sr),sr.forEach(t),ar.forEach(t),as=d(Mo),$t=a(Mo,"SPAN",{});var nr=s($t);ss=r(nr,"Loading the starter project"),nr.forEach(t),Mo.forEach(t),Tl=d(e),lt=a(e,"P",{});var rr=s(lt);ns=r(rr,"We provide two versions of the codebase:"),rr.forEach(t),Ul=d(e),V=a(e,"UL",{});var _o=s(V);Qt=a(_o,"LI",{});var ir=s(Qt);Se=a(ir,"A",{href:!0,rel:!0});var hr=s(Se);rs=r(hr,"A starter project, to download and follow along for this tutorial"),hr.forEach(t),ir.forEach(t),is=d(_o),Pt=a(_o,"LI",{});var pr=s(Pt);Re=a(pr,"A",{href:!0,rel:!0});var cr=s(Re);hs=r(cr,"A final version of the project, for comparison and debugging."),cr.forEach(t),pr.forEach(t),_o.forEach(t),Jl=d(e),T=a(e,"P",{});var yt=s(T);ps=r(yt,"To load the project, in the Godot Project Manager click "),Yt=a(yt,"STRONG",{});var dr=s(Yt);cs=r(dr,"Import"),dr.forEach(t),ds=r(yt,", navigate to where the files are located and load the "),Ft=a(yt,"STRONG",{});var fr=s(Ft);fs=r(fr,"project.godot"),fr.forEach(t),us=r(yt," file."),yt.forEach(t),kl=d(e),ot=a(e,"P",{});var ur=s(ot);ms=r(ur,"If you press F5 or play in the editor, you should be able to play the game in human mode. There are several instances of the game running, this is because we want to speed up training our AI agent with many parallel environments."),ur.forEach(t),Al=d(e),B=a(e,"H3",{class:!0});var Eo=s(B);H=a(Eo,"A",{id:!0,class:!0,href:!0});var mr=s(H);Dt=a(mr,"SPAN",{});var wr=s(Dt);v(Ze.$$.fragment,wr),wr.forEach(t),mr.forEach(t),ws=d(Eo),zt=a(Eo,"SPAN",{});var gr=s(zt);gs=r(gr,"Installing the Godot RL Agents plugin"),gr.forEach(t),Eo.forEach(t),Il=d(e),at=a(e,"P",{});var yr=s(at);ys=r(yr,"The Godot RL Agents plugin can be installed from the Github repo or with the Godot Asset Lib in the editor."),yr.forEach(t),Sl=d(e),st=a(e,"P",{});var vr=s(st);vs=r(vr,"First click on the AssetLib and search for \u201Crl\u201D"),vr.forEach(t),Rl=d(e),Be=a(e,"IMG",{src:!0,alt:!0}),Zl=d(e),q=a(e,"P",{});var jo=s(q);bs=r(jo,"Then click on Godot RL Agents, click Download and unselect the LICIENSE and "),We=a(jo,"A",{href:!0,rel:!0});var br=s(We);Ms=r(br,"README.md"),br.forEach(t),_s=r(jo," files. Then click install."),jo.forEach(t),Bl=d(e),Le=a(e,"IMG",{src:!0,alt:!0}),Wl=d(e),nt=a(e,"P",{});var Mr=s(nt);Es=r(Mr,"The Godot RL Agents plugin is now downloaded to your machine your machine. Now click on Project \u2192 Project settings and enable the addon:"),Mr.forEach(t),Ll=d(e),xe=a(e,"IMG",{src:!0,alt:!0}),xl=d(e),W=a(e,"H3",{class:!0});var Go=s(W);O=a(Go,"A",{id:!0,class:!0,href:!0});var _r=s(O);Vt=a(_r,"SPAN",{});var Er=s(Vt);v(Ne.$$.fragment,Er),Er.forEach(t),_r.forEach(t),js=d(Go),Ht=a(Go,"SPAN",{});var jr=s(Ht);Gs=r(jr,"Adding the AI controller"),jr.forEach(t),Go.forEach(t),Nl=d(e),rt=a(e,"P",{});var Gr=s(rt);Ts=r(Gr,"We now want to add an AI controller to our game. Open the player.tscn scene, on the left you should see a hierarchy of nodes that looks like this:"),Gr.forEach(t),Cl=d(e),Ce=a(e,"IMG",{src:!0,alt:!0}),Xl=d(e),U=a(e,"P",{});var vt=s(U);Us=r(vt,"Right click the "),qt=a(vt,"STRONG",{});var Tr=s(qt);Js=r(Tr,"Player"),Tr.forEach(t),ks=r(vt," node and click "),Ot=a(vt,"STRONG",{});var Ur=s(Ot);As=r(Ur,"Add Child Node."),Ur.forEach(t),Is=r(vt," There are many nodes listed here, search for AIController3D and create it."),vt.forEach(t),$l=d(e),Xe=a(e,"IMG",{src:!0,alt:!0}),Ql=d(e),it=a(e,"P",{});var Jr=s(it);Ss=r(Jr,"The AI Controller Node should have been added to the scene tree, next to it is a scroll. Click on it to open the script that is attached to the AIController. The Godot game engine uses a scripting language called GDScript, which is syntactically similar to python. The script contains methods that need to be implemented in order to get our AI controller working."),Jr.forEach(t),Pl=d(e),v($e.$$.fragment,e),Yl=d(e),ht=a(e,"P",{});var kr=s(ht);Rs=r(kr,"In order to implement these methods, we will need to create a class that inherits from AIController3D. This is easy to do in Godot, and is called \u201Cextending\u201D a class."),kr.forEach(t),Fl=d(e),K=a(e,"P",{});var To=s(K);Zs=r(To,"Right click the AIController3D Node and click \u201CExtend Script\u201D and call the new script "),Kt=a(To,"CODE",{});var Ar=s(Kt);Bs=r(Ar,"controller.gd"),Ar.forEach(t),Ws=r(To,". You should now have an almost empty script file that looks like this:"),To.forEach(t),Dl=d(e),v(Qe.$$.fragment,e),zl=d(e),pt=a(e,"P",{});var Ir=s(pt);Ls=r(Ir,"We will now implement the 4 missing methods, delete this code, and replace it with the following:"),Ir.forEach(t),Vl=d(e),v(Pe.$$.fragment,e),Hl=d(e),ct=a(e,"P",{});var Sr=s(ct);xs=r(Sr,"We have now defined the agent\u2019s observation, which is the position and velocity of the ball in its local cooridinate space. We have also defined the action space of the agent, which is a single contuninous value ranging from -1 to +1."),Sr.forEach(t),ql=d(e),ee=a(e,"P",{});var Uo=s(ee);Ns=r(Uo,"The next step is to update the Player\u2019s script to use the actions from the AIController, edit the Player\u2019s script by clicking on the scroll next to the player node, update the code in "),el=a(Uo,"CODE",{});var Rr=s(el);Cs=r(Rr,"Player.gd"),Rr.forEach(t),Xs=r(Uo," to the following the following:"),Uo.forEach(t),Ol=d(e),v(Ye.$$.fragment,e),Kl=d(e),dt=a(e,"P",{});var Zr=s(dt);$s=r(Zr,"We now need to synchronize between the game running in Godot and the neural network being trained in Python. Godot RL agents provides a node that does just that. Open the train.tscn scene, right click on the root node, and click \u201CAdd child node\u201D. Then, search for \u201Csync\u201D and add a Godot RL Agents Sync node. This node handles the communication between Python and Godot over TCP."),Zr.forEach(t),eo=d(e),Fe=a(e,"P",{});var an=s(Fe);Qs=r(an,"You can run training live in the the editor, by first launching the python training with "),tl=a(an,"CODE",{});var Br=s(tl);Ps=r(Br,"gdrl"),Br.forEach(t),an.forEach(t),to=d(e),ft=a(e,"P",{});var Wr=s(ft);Ys=r(Wr,"In this simple example, a reasonable policy is learned in several minutes. You may wish to speed up training, click on the Sync node in the train scene and you will see there is a \u201CSpeed Up\u201D property exposed in the editor:"),Wr.forEach(t),lo=d(e),De=a(e,"IMG",{src:!0,alt:!0}),oo=d(e),ut=a(e,"P",{});var Lr=s(ut);Fs=r(Lr,"Try setting this property up to 8 to speed up training. This can be a great benefit on more complex environments, like the multi-player FPS we will learn about in the next chapter."),Lr.forEach(t),ao=d(e),L=a(e,"H3",{class:!0});var Jo=s(L);te=a(Jo,"A",{id:!0,class:!0,href:!0});var xr=s(te);ll=a(xr,"SPAN",{});var Nr=s(ll);v(ze.$$.fragment,Nr),Nr.forEach(t),xr.forEach(t),Ds=d(Jo),ol=a(Jo,"SPAN",{});var Cr=s(ol);zs=r(Cr,"There\u2019s more!"),Cr.forEach(t),Jo.forEach(t),so=d(e),le=a(e,"P",{});var ko=s(le);Vs=r(ko,"We have only scratched the surface of what can be achieved with Godot RL Agents, the library includes custom sensors and cameras to enrich the information available to the agent. Take a look at the "),Ve=a(ko,"A",{href:!0,rel:!0});var Xr=s(Ve);Hs=r(Xr,"examples"),Xr.forEach(t),qs=r(ko," to find out more!"),ko.forEach(t),no=d(e),x=a(e,"H2",{class:!0});var Ao=s(x);oe=a(Ao,"A",{id:!0,class:!0,href:!0});var $r=s(oe);al=a($r,"SPAN",{});var Qr=s(al);v(He.$$.fragment,Qr),Qr.forEach(t),$r.forEach(t),Os=d(Ao),sl=a(Ao,"SPAN",{});var Pr=s(sl);Ks=r(Pr,"Author"),Pr.forEach(t),Ao.forEach(t),ro=d(e),qe=a(e,"P",{});var sn=s(qe);en=r(sn,"This section was written by "),mt=a(sn,"A",{href:!0});var Yr=s(mt);tn=r(Yr,"Edward Beeching"),Yr.forEach(t),sn.forEach(t),this.h()},h(){p(k,"name","hf:doc:metadata"),p(k,"content",JSON.stringify(Kr)),p(C,"id","godot-rl-agents"),p(C,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(C,"href","#godot-rl-agents"),p(A,"class","relative group"),p(re,"href","https://github.com/edbeeching/godot_rl_agents"),p(re,"rel","nofollow"),p(he,"href","https://godotengine.org/"),p(he,"rel","nofollow"),p(pe,"href","https://stable-baselines3.readthedocs.io/en/master/"),p(pe,"rel","nofollow"),p(ce,"href","https://docs.cleanrl.dev/"),p(ce,"rel","nofollow"),p(de,"href","https://www.samplefactory.dev/"),p(de,"rel","nofollow"),p(fe,"href","https://docs.ray.io/en/latest/rllib-algorithms.html"),p(fe,"rel","nofollow"),p(we,"href","https://github.com/edbeeching/godot_rl_agents"),p(we,"rel","nofollow"),p(ge,"href","https://arxiv.org/abs/2112.03636"),p(ge,"rel","nofollow"),p(ye,"href","https://edbeeching.github.io/"),p(ye,"rel","nofollow"),p(X,"id","create-a-custom-rl-environment-with-godot-rl-agents"),p(X,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(X,"href","#create-a-custom-rl-environment-with-godot-rl-agents"),p(S,"class","relative group"),Oe(Me.src,rn="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/ringpong.gif")||p(Me,"src",rn),p(Me,"alt","Ring Pong"),p(Y,"id","installing-the-godot-game-engine"),p(Y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(Y,"href","#installing-the-godot-game-engine"),p(R,"class","relative group"),p(Ee,"href","https://godotengine.org/"),p(Ee,"rel","nofollow"),p(je,"href","https://docs.godotengine.org/en/latest/index.html"),p(je,"rel","nofollow"),p(Ge,"href","https://www.gdquest.com/"),p(Ge,"rel","nofollow"),p(Te,"href","https://kidscancode.org/godot_recipes/4.x/"),p(Te,"rel","nofollow"),p(Ue,"href","https://www.youtube.com/channel/UCczi7Aq_dTKrQPF5ZV5J3gg"),p(Ue,"rel","nofollow"),p(Je,"href","https://downloads.tuxfamily.org/godotengine/4.0.1/Godot_v4.0.1-stable_win64.exe.zip"),p(Je,"rel","nofollow"),p(ke,"href","https://downloads.tuxfamily.org/godotengine/4.0.1/Godot_v4.0.1-stable_macos.universal.zip"),p(ke,"rel","nofollow"),p(Ae,"href","https://downloads.tuxfamily.org/godotengine/4.0.1/Godot_v4.0.1-stable_linux.x86_64.zip"),p(Ae,"rel","nofollow"),p(z,"id","loading-the-starter-project"),p(z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(z,"href","#loading-the-starter-project"),p(Z,"class","relative group"),p(Se,"href","https://drive.google.com/file/d/1C7xd3TibJHlxFEJPBgBLpksgxrFZ3D8e/view?usp=share_link"),p(Se,"rel","nofollow"),p(Re,"href","https://drive.google.com/file/d/1k-b2Bu7uIA6poApbouX4c3sq98xqogpZ/view?usp=share_link"),p(Re,"rel","nofollow"),p(H,"id","installing-the-godot-rl-agents-plugin"),p(H,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(H,"href","#installing-the-godot-rl-agents-plugin"),p(B,"class","relative group"),Oe(Be.src,hn="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/godot1.png")||p(Be,"src",hn),p(Be,"alt","Godot"),p(We,"href","http://README.md"),p(We,"rel","nofollow"),Oe(Le.src,pn="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/godot2.png")||p(Le,"src",pn),p(Le,"alt","Godot"),Oe(xe.src,cn="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/godot3.png")||p(xe,"src",cn),p(xe,"alt","Godot"),p(O,"id","adding-the-ai-controller"),p(O,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(O,"href","#adding-the-ai-controller"),p(W,"class","relative group"),Oe(Ce.src,dn="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/godot4.png")||p(Ce,"src",dn),p(Ce,"alt","Godot"),Oe(Xe.src,fn="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/godot5.png")||p(Xe,"src",fn),p(Xe,"alt","Godot"),Oe(De.src,un="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/godot6.png")||p(De,"src",un),p(De,"alt","Godot"),p(te,"id","theres-more"),p(te,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(te,"href","#theres-more"),p(L,"class","relative group"),p(Ve,"href","https://github.com/edbeeching/godot_rl_agents_examples"),p(Ve,"rel","nofollow"),p(oe,"id","author"),p(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(oe,"href","#author"),p(x,"class","relative group"),p(mt,"href","https://twitter.com/edwardbeeching")},m(e,i){l(document.head,k),h(e,rl,i),h(e,A,i),l(A,C),l(C,bt),b(ne,bt,null),l(A,So),l(A,Mt),l(Mt,Ro),h(e,il,i),h(e,I,i),l(I,re),l(re,Zo),l(I,Bo),l(I,_t),l(_t,Wo),l(I,Lo),h(e,hl,i),h(e,Ke,i),l(Ke,xo),h(e,pl,i),h(e,f,i),l(f,ie),l(ie,No),l(ie,he),l(he,Co),l(ie,Xo),l(f,$o),l(f,m),l(m,Qo),l(m,pe),l(pe,Po),l(m,Yo),l(m,ce),l(ce,Fo),l(m,Do),l(m,de),l(de,zo),l(m,Vo),l(m,fe),l(fe,Ho),l(f,qo),l(f,Et),l(Et,Oo),l(f,Ko),l(f,et),l(et,ea),l(et,jt),l(jt,ta),l(f,la),l(f,ue),l(ue,oa),l(ue,Gt),l(Gt,aa),l(ue,sa),l(f,na),l(f,me),l(me,ra),l(me,Tt),l(Tt,ia),l(me,ha),h(e,cl,i),h(e,w,i),l(w,pa),l(w,we),l(we,ca),l(w,da),l(w,ge),l(ge,fa),l(w,ua),l(w,ye),l(ye,ma),l(w,wa),h(e,dl,i),h(e,ve,i),l(ve,ga),l(ve,Ut),l(Ut,ya),h(e,fl,i),h(e,S,i),l(S,X),l(X,Jt),b(be,Jt,null),l(S,va),l(S,kt),l(kt,ba),h(e,ul,i),h(e,$,i),l($,Ma),l($,At),l(At,_a),l($,Ea),h(e,ml,i),h(e,Q,i),l(Q,ja),l(Q,It),l(It,Ga),l(Q,Ta),h(e,wl,i),h(e,P,i),l(P,Ua),l(P,St),l(St,Ja),l(P,ka),h(e,gl,i),h(e,Me,i),h(e,yl,i),h(e,R,i),l(R,Y),l(Y,Rt),b(_e,Rt,null),l(R,Aa),l(R,Zt),l(Zt,Ia),h(e,vl,i),h(e,j,i),l(j,Sa),l(j,Ee),l(Ee,Ra),l(j,Za),l(j,Bt),l(Bt,Ba),l(j,Wa),h(e,bl,i),h(e,F,i),l(F,La),l(F,Wt),l(Wt,xa),l(F,Na),h(e,Ml,i),h(e,u,i),l(u,Ca),l(u,je),l(je,Xa),l(u,$a),l(u,Ge),l(Ge,Qa),l(u,Pa),l(u,Te),l(Te,Ya),l(u,Fa),l(u,Ue),l(Ue,Da),l(u,za),h(e,_l,i),h(e,D,i),l(D,Va),l(D,Lt),l(Lt,Ha),l(D,qa),h(e,El,i),h(e,tt,i),l(tt,Oa),h(e,jl,i),h(e,G,i),l(G,xt),l(xt,Je),l(Je,Ka),l(G,es),l(G,Nt),l(Nt,ke),l(ke,ts),l(G,ls),l(G,Ct),l(Ct,Ae),l(Ae,os),h(e,Gl,i),h(e,Z,i),l(Z,z),l(z,Xt),b(Ie,Xt,null),l(Z,as),l(Z,$t),l($t,ss),h(e,Tl,i),h(e,lt,i),l(lt,ns),h(e,Ul,i),h(e,V,i),l(V,Qt),l(Qt,Se),l(Se,rs),l(V,is),l(V,Pt),l(Pt,Re),l(Re,hs),h(e,Jl,i),h(e,T,i),l(T,ps),l(T,Yt),l(Yt,cs),l(T,ds),l(T,Ft),l(Ft,fs),l(T,us),h(e,kl,i),h(e,ot,i),l(ot,ms),h(e,Al,i),h(e,B,i),l(B,H),l(H,Dt),b(Ze,Dt,null),l(B,ws),l(B,zt),l(zt,gs),h(e,Il,i),h(e,at,i),l(at,ys),h(e,Sl,i),h(e,st,i),l(st,vs),h(e,Rl,i),h(e,Be,i),h(e,Zl,i),h(e,q,i),l(q,bs),l(q,We),l(We,Ms),l(q,_s),h(e,Bl,i),h(e,Le,i),h(e,Wl,i),h(e,nt,i),l(nt,Es),h(e,Ll,i),h(e,xe,i),h(e,xl,i),h(e,W,i),l(W,O),l(O,Vt),b(Ne,Vt,null),l(W,js),l(W,Ht),l(Ht,Gs),h(e,Nl,i),h(e,rt,i),l(rt,Ts),h(e,Cl,i),h(e,Ce,i),h(e,Xl,i),h(e,U,i),l(U,Us),l(U,qt),l(qt,Js),l(U,ks),l(U,Ot),l(Ot,As),l(U,Is),h(e,$l,i),h(e,Xe,i),h(e,Ql,i),h(e,it,i),l(it,Ss),h(e,Pl,i),b($e,e,i),h(e,Yl,i),h(e,ht,i),l(ht,Rs),h(e,Fl,i),h(e,K,i),l(K,Zs),l(K,Kt),l(Kt,Bs),l(K,Ws),h(e,Dl,i),b(Qe,e,i),h(e,zl,i),h(e,pt,i),l(pt,Ls),h(e,Vl,i),b(Pe,e,i),h(e,Hl,i),h(e,ct,i),l(ct,xs),h(e,ql,i),h(e,ee,i),l(ee,Ns),l(ee,el),l(el,Cs),l(ee,Xs),h(e,Ol,i),b(Ye,e,i),h(e,Kl,i),h(e,dt,i),l(dt,$s),h(e,eo,i),h(e,Fe,i),l(Fe,Qs),l(Fe,tl),l(tl,Ps),h(e,to,i),h(e,ft,i),l(ft,Ys),h(e,lo,i),h(e,De,i),h(e,oo,i),h(e,ut,i),l(ut,Fs),h(e,ao,i),h(e,L,i),l(L,te),l(te,ll),b(ze,ll,null),l(L,Ds),l(L,ol),l(ol,zs),h(e,so,i),h(e,le,i),l(le,Vs),l(le,Ve),l(Ve,Hs),l(le,qs),h(e,no,i),h(e,x,i),l(x,oe),l(oe,al),b(He,al,null),l(x,Os),l(x,sl),l(sl,Ks),h(e,ro,i),h(e,qe,i),l(qe,en),l(qe,mt),l(mt,tn),io=!0},p:Hr,i(e){io||(M(ne.$$.fragment,e),M(be.$$.fragment,e),M(_e.$$.fragment,e),M(Ie.$$.fragment,e),M(Ze.$$.fragment,e),M(Ne.$$.fragment,e),M($e.$$.fragment,e),M(Qe.$$.fragment,e),M(Pe.$$.fragment,e),M(Ye.$$.fragment,e),M(ze.$$.fragment,e),M(He.$$.fragment,e),io=!0)},o(e){_(ne.$$.fragment,e),_(be.$$.fragment,e),_(_e.$$.fragment,e),_(Ie.$$.fragment,e),_(Ze.$$.fragment,e),_(Ne.$$.fragment,e),_($e.$$.fragment,e),_(Qe.$$.fragment,e),_(Pe.$$.fragment,e),_(Ye.$$.fragment,e),_(ze.$$.fragment,e),_(He.$$.fragment,e),io=!1},d(e){t(k),e&&t(rl),e&&t(A),E(ne),e&&t(il),e&&t(I),e&&t(hl),e&&t(Ke),e&&t(pl),e&&t(f),e&&t(cl),e&&t(w),e&&t(dl),e&&t(ve),e&&t(fl),e&&t(S),E(be),e&&t(ul),e&&t($),e&&t(ml),e&&t(Q),e&&t(wl),e&&t(P),e&&t(gl),e&&t(Me),e&&t(yl),e&&t(R),E(_e),e&&t(vl),e&&t(j),e&&t(bl),e&&t(F),e&&t(Ml),e&&t(u),e&&t(_l),e&&t(D),e&&t(El),e&&t(tt),e&&t(jl),e&&t(G),e&&t(Gl),e&&t(Z),E(Ie),e&&t(Tl),e&&t(lt),e&&t(Ul),e&&t(V),e&&t(Jl),e&&t(T),e&&t(kl),e&&t(ot),e&&t(Al),e&&t(B),E(Ze),e&&t(Il),e&&t(at),e&&t(Sl),e&&t(st),e&&t(Rl),e&&t(Be),e&&t(Zl),e&&t(q),e&&t(Bl),e&&t(Le),e&&t(Wl),e&&t(nt),e&&t(Ll),e&&t(xe),e&&t(xl),e&&t(W),E(Ne),e&&t(Nl),e&&t(rt),e&&t(Cl),e&&t(Ce),e&&t(Xl),e&&t(U),e&&t($l),e&&t(Xe),e&&t(Ql),e&&t(it),e&&t(Pl),E($e,e),e&&t(Yl),e&&t(ht),e&&t(Fl),e&&t(K),e&&t(Dl),E(Qe,e),e&&t(zl),e&&t(pt),e&&t(Vl),E(Pe,e),e&&t(Hl),e&&t(ct),e&&t(ql),e&&t(ee),e&&t(Ol),E(Ye,e),e&&t(Kl),e&&t(dt),e&&t(eo),e&&t(Fe),e&&t(to),e&&t(ft),e&&t(lo),e&&t(De),e&&t(oo),e&&t(ut),e&&t(ao),e&&t(L),E(ze),e&&t(so),e&&t(le),e&&t(no),e&&t(x),E(He),e&&t(ro),e&&t(qe)}}}const Kr={local:"godot-rl-agents",sections:[{local:"create-a-custom-rl-environment-with-godot-rl-agents",sections:[{local:"installing-the-godot-game-engine",title:"Installing the Godot Game Engine"},{local:"loading-the-starter-project",title:"Loading the starter project"},{local:"installing-the-godot-rl-agents-plugin",title:"Installing the Godot RL Agents plugin"},{local:"adding-the-ai-controller",title:"Adding the AI controller"},{local:"theres-more",title:"There\u2019s more!"}],title:"Create a custom RL environment with Godot RL Agents"},{local:"author",title:"Author"}],title:"Godot RL Agents"};function ei(nn){return qr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ai extends Fr{constructor(k){super();Dr(this,k,ei,Or,zr,{})}}export{ai as default,Kr as metadata};
