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
#91
Hi,
I have just realised the power of being Observer user. But I do not see any player moving in the same game (from different browsers which I use).
Reply
#92
Hi, I'm away from home for a few days so can't test but is was working for me.  Must be in the same game name, use mouse and wsad to move.  Also use different browsers like Firefox, chrome, edge etc for different players inclyding Observer on same pc.
Reply
#93
It turned out to be an interesting task to create a mechanism for correcting errors that occur in the server part.  Rolleyes

This is even more interesting than creating an algorithm to explore a maze.  Shy
Reply
#94
Just a comment on the Observer - I tested and it works for me.  The reason to use different browser vendors is that the player name and other settings are stored using localStorage in JS.  

This means that these settings are persistent within any tabs (or windows) for this browser vendor both during and in subsequent sessions.  To have 2 or more players (with different names) on the same PC they musty be using different localStorage and this can only be achieved afaik using different vendor browsers. 

So the options for users (includoing Observer) to join the same game (defined by setting the game setting) are:

a) different names on the same PC using different browser vendors
b) different names on different PCs on the same IP address using any or the same browser vendor
c) different IP addresses regardless of name or browser
[-] The following 2 users Like litdev's post:
  • AbsoluteBeginner, stevantosic
Reply
#95
Hi, 
I have been testing the whole system on my localhost network and found a "suspicious" lines of code in the index.html. In details:

updatePlayer(element) {
      const now = new Date();
      const then = new Date(element.lastActive);

     const inactiveTime = (now - then) / 1000;
     ....
          if (inactiveTime < 60) { player ... }


1.  const now = new Date();
is CET time for me.

2. const then = new Date(element.lastActive);
is London Time which comes from Sqlite DB (also on my PC). 

Hence, the value:
const inactiveTime = (now - then) / 1000; 

is around 3600 (one hour). It means that player ... code is unreachable.

I tried an adhoc solution just for testing purposes which works well:

updatePlayer(element) {
     const nowLocal = new Date();

     const utcTime = nowLocal.getTime() + (nowLocal.getTimezoneOffset() * 60000);
     const londonTime = new Date(utcTime);

     const now = londonTime;
     const then = new Date(element.lastActive);
...


Also, Tag option is chosen in settings.html.
Reply
#96
Good catch, I assumed that the php sqlite CURRENT_TIMESTAMP, php DateTime('now') and JS Date.Now() would all use the same default.

It seems CURRENT_TIMESTAMP is always UTC/GMT.  I changed the other php call and the JS to also work in UTC/GMT.

I tested by changing my time zone and it worked I think.
[-] The following 1 user Likes litdev's post:
  • stevantosic
Reply
#97
Hi all.

Today my robot walked through the entire maze for the first time, collecting data for the map.
   
The robot was able to correct the consequences of all false movements that occurred during the robot's operation.  Cool
Now I can start looking for the reasons for these false movements.
I think that the commands for these movements are generated by my program.
But I don't even have any idea why this is happening.

However, creating a mechanism to compensate for all these harmful effects was a real pleasure.  Tongue
[-] The following 3 users Like AbsoluteBeginner's post:
  • litdev, stevantosic, z-s
Reply
#98
Hi all.  Shy

Yesterday I managed to collect some data about the reason for my robot's false movements.
It turned out that at the moment when the Main Loop of my program begins another data processing, sometimes this data turns out to be still old.
The program generates another movement command, which, in fact, is no longer needed.

Now I will develop a way to control the relevance of the input information that the Loop processes.  Cool
[-] The following 1 user Likes AbsoluteBeginner's post:
  • litdev
Reply
#99
This is great AB,

One useful agorithm would be to be able to plan a path from one cell to any other based on knowledge of the maze already obtained.  Fairly tough, but this may be the end goal for any competetive robot 'game' challenge.  The main difficulty I would see with this is deciding when to take a known route (maybe long) or experimement with unknown paths (that may be better).  I am just thinking ahead, not suggesting this directly.
Reply
At the moment, the duration of the cycle of my program depends on the pause that I set.
If the program has the ability to determine for itself the moment when it can start a new Loop, then the program can work as quickly as possible.
When my program is able to run quickly, then I will start creating intelligence for it.  Rolleyes

You have come up with a very good project.  Tongue
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)