Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Example Analysis of non-landing of small Ball in matlab

Shulou Source: shulou.com Published: 2022-06-01 06:35:07 09月29日 Update

Editor to share with you the matlab small ball does not land on the example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Agent effect after 1000 training times

When using the object-oriented management program in the previous FrozenLake environment training, it was found that the running speed became slower in the later stage of the training, and it was observed by the naked eye, so matlab another program file management method, packages, was adopted.

Name the folder with + and name to form a package, within which you can create a new function or the class you used earlier

Here, use the function file directly. When calling the function, you need to write the name of the package, such as env.step ().

It can be observed that there is no visible change in running speed after 1000 training.

This method is easier to use than the object-oriented model to build a simple game environment.

When passing parameters and calls, structural body variables are used to store the original object parameters, that is, the global variables under the mode of more than a dozen function files in a folder and a main file, such as

Function self = step (self,action)

% one step action

Self.done = 0

Self.reward=0

Temp_w=self.agent (5) + 5* (2-action)

If temp_w25

Temp_w=25

End

Self.reward=0

BallPos = self.observation (1:2)

BallVel = self.observation (3:4)

If ballPos (1) > self.weight

BallPos (1) = self.weight

BallVel (1) =-ballVel (1);% boundary

Elseif ballPos (1)

< 0.1 ballPos(1) = 0.1; ballVel(1) = -ballVel(1); elseif ballPos(2) >

= self.height

BallPos (2) = self.height

BallVel (2) =-ballVel (2);% Top Wall

Self.score=self.score+1

Elseif ballPos (2) < 1

If abs (self.agent (5)-ballPos (1))

Tags: Files functions training environment learning actions variables objects ways patterns programs articles small and medium examples analysis landing content parameters that is folders Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Shulou Technology Huawei MariaDB