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
#21
Hi AB,

This is harder than I thought it would be, mainly due to the latency in communication, which I guess is a real issue for physical control systems.

The server just stores the current state for each user, and only resets everything when it hasn't been updated for over 60 seconds.  Since the browser is continually updating to the server, you would bave to close browser and stop SB sending commands for 1 munute to reset everything.

Or you could just send the command below when you close SB or just run it from another program at any point.

Code:
LDNetwork.SendWebRequest("https://litdev.uk/apps/maze3D/maze3D.php?action=set&move=0&left=0&right=0")

I will probably reduce the timeout to 1 sec anyway.

EDIT

Timeout updated to 1 sec.

I do have a SB code that does solve the maze, but its pretty slow.  I can post the code or leave it just now if you are having fun working on it.
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply
#22
Hi,
WebSocket is more suitable for browser game communications. HTTP has a header load for each request/response.

st
Reply
#23
(02-01-2025, 12:34 PM)stevantosic Wrote: WebSocket is more suitable for browser game communications. HTTP has a header load for each request/response.

Yes I agree, but I don't think this is available on my current ISP without buying a VPS.

PS

The js-php communication with AJAX I am using is not really the bottleneck I don't think (although it may be faster with sockets) - for me the client/server round trip (send and receive) only takes 2 or 3 frames when running at 60fps - some of that is database handling of the data.  My understanding is that sockets are just 'always open' AJAX.  There is also a delay in sending and receiving messages over the web (the round trip for this send and receive is also around 2 or 3 frames).  Finally my understanding is that HTTP is similar performance to TCP, and maybe faster for direct communication to php.  I use 100 ms to ensure good chance of full synchronisity in my SB code - this is typically about 6 frames at 60 fps.

The control would be a lot easier if we can just tell the 'robot' to move to a certain coordinate or look in a specific direction rather than start and end moving with uncertainty exactly how much movement/rotation will take place, but it is a fun excercise to do it.
[-] The following 1 user Likes litdev's post:
  • stevantosic
Reply
#24
(02-01-2025, 09:31 AM)litdev Wrote: Hi AB,

...

I do have a SB code that does solve the maze, but its pretty slow.  I can post the code or leave it just now if you are having fun working on it.

Hello.

I won't look at any other code until I write my code. For me Small Basic is great entertainment.
Publishing the code can never spoil this pleasure for me.  Tongue

I have my own interesting idea. When I implement it, then I will be interested to see all other people's ideas.
I will be happy to follow this interesting project.  Shy
Reply
#25
LitDev, 

So, where in the code did you include the arrow keys? I don't see it.

JR
Reply
#26
JR,

This challenge is write a SB controller for the 'robot', using Artificial Intellegence coded by you.  As such it should have no Human Intelligence input directly from you like for example key stokes to guide the robot.  Therefore none of the code I have shared has any keyboard control.

However, the robot in the browser can be controlled by you directly with arrow keys completely independent of any SB code.  This has nothing to do with any SB AI control program, it is an alternative using Human Intelligence (you) to control the robot.  The purpose of this is to maybe test some ideas or move about the maze a bit to see what challenges the robot AI may face.

My previous code that I shared was my first pass and I could share a 'better' version, but some prefer to work on their own without dilution of ideas from me.

If any of you, AB, JR, ST have any code you want to share that would also be good - this is a tricky challenge and joint effort may help.
Reply
#27
(Yesterday, 08:50 AM)litdev Wrote: ...

If any of you, AB, JR, ST have any code you want to share that would also be good - this is a tricky challenge and joint effort may help.

Hi all.  Shy

If there is a suggestion to work together on the project, I can say that I am currently writing code to move the robot TO THE CENTER of the cell, before the robot starts collecting data about the distance to the walls that are in the direction of 0, 90, 180 and 270 degrees.

I also want to confirm that publishing any participant's code will not in any way prevent me from enjoying Small Basic.
After all, I can simply not study your code as long as I want to maintain the unknown.  Rolleyes

Thus, I invite everyone who enjoys working with such a wonderful tool as our Small Basic to have fun.
[-] The following 2 users Like AbsoluteBeginner's post:
  • litdev, stevantosic
Reply
#28
AB,

Your ideas are very similar to mine about writing utilities to 'LookAbout' and 'MoveToCellCenter'.  

There are some challenges I had with this:

1] One is that 0 and 360 are the same direction which makes it harder to rotate to 0 as we have to rotate differently when approaching from 350 or 10 degrees, whereas rotation direction towards 180 is easily identified if we are at 170 or 190.

2] Another required funcion is to reliably move or rotate a small distance.

3] Another one, once you can LookAbout and MoveToCellCenter is what to keep track of and what possible directions to take so not to backtrack unless you are at a dead end.
Reply
#29
For any that want to see, this is my current version - JTDS122.000
[-] The following 1 user Likes litdev's post:
  • stevantosic
Reply
#30
(Yesterday, 10:07 AM)litdev Wrote: AB,

Your ideas are very similar to mine about writing utilities to 'LookAbout' and 'MoveToCellCenter'.  
...

Thank you for your thoughts, dear LitDev.  Shy
As you know, I write code very slowly.
I can't even run my code for testing yet because it doesn't contain all the necessary commands yet.
I only wrote the code to determine the direction from the robot to the center of the cell. Now I am coding the process of turning the robot towards the center of the cell so that the robot can start moving there.

I like this activity.  Rolleyes
[-] The following 1 user Likes AbsoluteBeginner's post:
  • litdev
Reply


Forum Jump:


Users browsing this thread: 18 Guest(s)