We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3D maze in browser controlled by Small Basic
#41
I made a couple update fixes, mainly to do with some SB sent events getting ignored if the server is busy, so if you have seen this hopefully it is better - may wanr to refine a bit.
Reply
#42
I think this part of Litdev's code (GRWW331.000) should be emphasized:

Code:
urlGet = "https://litdev.uk/apps/maze3D/maze3D.php?action=get"
urlSet = "https://litdev.uk/apps/maze3D/maze3D.php?action=set"

'Random walk
While ("True")
  GetData()
 
  'Possible directions
  numdir = 0
  dirs = ""
  If (data["dir0"] = 1) Then
    numdir = numdir+1
    dirs[numdir] = 0
  EndIf
  If (data["dir90"] = 1) Then
    numdir = numdir+1
    dirs[numdir] = 90
  EndIf
  If (data["dir180"] = 1) Then
    numdir = numdir+1
    dirs[numdir] = 180
  EndIf
  If (data["dir270"] = 1) Then
    numdir = numdir+1
    dirs[numdir] = 270
  EndIf
 
  'Pick one randomly and send the animation
  dir = dirs[Math.GetRandomNumber(numdir)]
  TextWindow.WriteLine("Next direction will be "+dir)
  LDNetwork.SendWebRequest(urlSet+"&animate="+dir) 'Valid values are 0, 90, 180 & 270
 
  'The animations take around 1000ms to fully complete if the screen is running at 60 fps or more (smaller browser window runs faster fps)
  'We can queue up new animations at any time, but they won't start until the previous finished
  'Here we wait an extra second after until the previous animation finishes so we can see them clearly
  Program.Delay(2000)
EndWhile
Reply
#43
Hello everyone.  Smile

Today I had a new interesting idea for our project.

I was conducting tests to determine the dependence of the robot's rotation angle on the duration of the "right = 1" command.
At that moment I thought that if the browser engine is given the "right = 1" command for one second, then due to the different characteristics of the computers on which we will run this project, the robot's rotation angle will be different.
Therefore, it will be cool if at the beginning of the game our robot will make test turns and movements to determine the engine's performance and optimize the robot's settings.

A self-tuning robot is cool.

Am I right?  Cool
[-] The following 1 user Likes AbsoluteBeginner's post:
  • litdev
Reply
#44
AB,

This is a good idea - I also found the approach below good which you could also test with your idea.

1] Decide direction to turn or move
2] Send the rotate or move instruction
3] Almost immediately after send the stop instruction - there is some inbuilt latency on the server and browser so even with no explicit delay some movement will occur, but your idea will test this further
4] Wait a while until there is no further movement - again your method can test this
5] Get the current position and direction while stationary and go to 1

This is what I meant by small steps and keep correcting movement.

The rotation angle dependence on time the message is sent will depend on lots of factors, PC hardware, internet, other processes on PC, browser window size, other users using the server etc and may vary from time to time as well from PC to PC.
Reply
#45
(02-05-2025, 09:27 AM)litdev Wrote: ...

The rotation angle dependence on time the message is sent will depend on lots of factors, PC hardware, internet, other processes on PC, browser window size, other users using the server etc and may vary from time to time as well from PC to PC.

That is, perhaps we should have the robot CONSTANTLY analyze the result of dividing the value of the "angle of rotation" ("distance traveled") by the number of "Timer intervals" in order to more accurately determine the new number of "Timer intervals" for the next action of the robot.  Undecided

( I say this for the version of the SB program, when the developer decided to use DURATION CONTROL of commands, instead of controlling the NUMBER of short commands (step-by-step control). I want to test the "duration control" method now.)
Reply
#46
Internally, the rotation rate is 1.5radians/s (270deg/s) and is designed to be fairly independent of the fps.

Here is a little program inspired by ABs work looking at SB imposed delay vs actual internal rotation time - JKQM901.000

   
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply
#47
May maths is all wrong! 1.5 radians/s is 270/pi degrees/s, the SB file and plot updated and makes more sense - JKQM901.000-0

   
Reply
#48
I admire this method !!!  Rolleyes

Now that we have a real graph from a real study, I feel like I'm part of a real research group, and not just a club of technical hobbyists.  Cool

I even began to respect myself even more.

( I'm serious, LitDev. I really enjoyed this.)
[-] The following 2 users Like AbsoluteBeginner's post:
  • litdev, stevantosic
Reply
#49
Hi all.  Shy

Dear LitDev, I just discovered that on your site, in the help information, on the page "https://litdev.uk/LitDev.html" there is no help for the method "LDGraph.ScaleWidth()".

This is a very useful method. This method is worthy of having kind words said about it on the Internet.  Wink
Reply
#50
Updated website for LDGraph.ScaleWidth() - not sure why it wasn't already there - it is auto generated from extension but not uploaded for some reason - thanks for mentioning it.
Reply


Forum Jump:


Users browsing this thread: 37 Guest(s)