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:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Small Basic AI Championship
AB,

LDInline doesn't especially speed anything.  What makes SB slow is mainly the Primitive type, especially with arrays.  To really speed up you would need to write in C# or similar.  However, careful use of LDList and other optimisations depending on the code (e.g. there may be things that can be done with large number of moving shapes).

The first thing to do is to simplify the code trying to identify cause of bottleneck (which bits are slow - array manipulations, graphics update, file operations, expensive extension commands ...).  If you then get a small sample program that is running slow I can have a look.
Reply
Well.

Then, let this be my current plan of action.  Shy

Thank you very much.
Reply
(translated by Google translator)

Hi all.  Smile

Finally the main mechanical part of my Retro Football code worked.  Shy
Now I will make the code formatting decent and post it on my cloud for viewing and discussion.

Be healthy everyone.
I wish you all the very best.
Reply
(translated by Google translator)

Hi guys!  Smile
I have uploaded an intermediate version of the game "Retro Football" to my OneDrive.

https://1drv.ms/f/s!AnoSlTzMqlL6jNwEee_Q...g?e=bLsytu

In discussing this version, I am interested in your advice and tips.
Here I first tried to use an asynchronous subroutine call.
I'm interested in advice and comments on the topic of using variables shared between the main and temporary computation threads.
What rules should I follow to avoid program crashes?
How to properly organize the work of threads so that they do not interfere with each other when using shared variables?

Also, I would appreciate your advice on how to improve the gameplay.
Now, left clicking on the "cursor sensor" turns the game Pause on and off.
The human controls the right players, and the Robot controls the left.
The Y coordinate of the cursor corresponds to the midpoint of the rectangles of human-controlled players.
The speed of the ball and the accuracy of the Robot's movement can be changed at the beginning of the program's source code.

I want to add the ability for football players to RE-DIRECT the ball as it moves towards the opponent's goal.
At the moment, football players can only hit the ball when it flies towards their goal.

Well, that's all for now.
I hope you find this game fun to work on.
After all, the most interesting thing is yet to come. This is the creation of a Robot Football Player who will SEE the ball on the field with his "eyes".  Tongue
[-] The following 1 user Likes AbsoluteBeginner's post:
  • z-s
Reply
Hi guys.  Smile
I updated the game "Retro Football" in my cloud (link in the previous post).

Added the ability to redirect the ball that is flying towards the opponent's goal.
Only a forward footballer has this ability.

In addition, the game is paused for 3 seconds if one of the teams scores a goal.

Let's have fun further...  Wink
Reply
New update of the game "Retro Football".  Shy
Counting of goals scored has been implemented.
More precise settings for object movement parameters have been made.

How are things going with you?  Wink
Reply
(translated by Google translator)

Hi all.  Shy
Today I tried playing football with a robot that detects the position of the ball on the field using vision.
On my tablet, the "LDImage.FindImageInImage()" function clearly does not have time to find even one white pixel in the required area of the graphics window.
If the game loop becomes shorter than 100 milliseconds, then the robot loses sight of the ball.

Since, probably, the "LDImage.FindImageInImage()" function searches for an image in an image by checking each pixel, then I hope to achieve my goal using the "LDGraphicsWindow.GetPixel()" function.

The ball has a diameter of 20 pixels.
So I think if I search for a white pixel of the ball on the playing field with a step of 10 pixels horizontally and vertically, the program will have to check 100 times fewer pixels.  Undecided
I hope this will allow us to find the ball quickly enough.

( if anyone is interested, I can post the current version with the big-eyed robot so you can try your ideas or find my mistakes )
Reply
(translated by Google translator)

An incredibly fun process.  Rolleyes

For example, making such a game in C# would not be interesting at all.
But here in Small Basic, you'll need all your ingenuity to make the game work well even on a slow tablet.  Cool

I've used everything I've learned about Small Basic so far.
It seems to me that I have already used all the technical capabilities to achieve a sufficient speed of the game. But, I still lack a little speed.

At first I thought it was already a dead end.
But then a new idea comes to mind again - and the feeling of enthusiasm returns.
I thought that in case of mechanical resources running out, using AI elements could help.
In conditions where the hardware does not have time to calculate everything necessary, the program can try to "look into the future" and predict where the ball WILL BE at the moment when the hardware finishes the calculations (!).

Now I have the current version of the game, in which I think I have used all the possibilities of technique.
If anyone is interested, I can improve the code formatting and post it on my OneDrive.
And now I will begin to add to the program the ability to predict the future...
Reply
(translated by Google translator)

Dear Small Basic fans,
I just put the latest version of the game "Retro Football" into my OneDrive. ( Retro Football v0_0401 with AI.sb )

This version is notable because I used a ball search by image and parallel operation of two computation threads (asynchronous subroutine call).
These were unexplored topics for me.  Shy

In addition, this version of the game gives the opportunity to organize AI Football matches BETWEEN TWO ROBOTS.
Now, the right team of football players is controlled by a person, moving the mouse across the graphic window.
The left team is controlled by a robot that determines the position of the ball on the field using "vision".
(on my slow tablet, the robot takes up to 4 game cycles to make its decision)

But (!)...
Thanks to the LitDev extension, not only a person can move the cursor around the graphic window.
Therefore, every fan of cyber SB sports can write an AUTONOMOUS SB program, which will also "see" the ball on the field, using "vision" and will be able to control the right team of football players, moving the cursor on the screen.
Thus, two "sighted" robots can compete with each other.

(what do you think about our Small Basic now? Wink  )
Reply
Is it ethical for AI programs to compete against human athletes in sports? As AI continues to advance, should we reconsider the definition of competition, or does this undermine the spirit of sportsmanship? What implications does this have for the future of both AI development and athletic integrity?",
"refusal
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)