Discuss Scratch

ComputerTeacherMON
Teacher
2 posts

Run without Screen Refresh Issue for AI experiment

Hi everyone! My idea is to try to make a neural network powered AI for pong (just for fun and to learn about Neural Nets). I want to be able to run whole games of pong without screen refresh so that training can go quickly. I set up a custom block with the game loop and a broadcast message but when I check “Run without screen refresh” everything gets bogged down and runs even slower than normal! I'm new to Scratch so I'm confused about why that may be. Any ideas?

https://scratch.mit.edu/projects/615454152
CodingBaguette
Scratcher
500+ posts

Run without Screen Refresh Issue for AI experiment

ComputerTeacherMON wrote:

Hi everyone! My idea is to try to make a neural network powered AI for pong (just for fun and to learn about Neural Nets). I want to be able to run whole games of pong without screen refresh so that training can go quickly. I set up a custom block with the game loop and a broadcast message but when I check “Run without screen refresh” everything gets bogged down and runs even slower than normal! I'm new to Scratch so I'm confused about why that may be. Any ideas?

https://scratch.mit.edu/projects/615454152



You're issue is in the play1game block. You are doing that block forever, and in that block you are baisicly adding another forever loop, the repeat until game over is 1. That is the problem. When you start the game and you do that block, maybe instead of forever put the “repeat until game over = 1” block.


I hope that helped

Last edited by CodingBaguette (Dec. 11, 2021 22:01:45)

ComputerTeacherMON
Teacher
2 posts

Run without Screen Refresh Issue for AI experiment

Thanks. My goal is to have entire game simulations happen as fast as possible so that is why I had tried that structure. I experimented with various ways and I think I might have found something that works. I switched the repeat until to a repeat 300 and I got rid of the broadcast and just called the movesteps block from the 300steps block and now it seems to be doing what I want. I might have to put the code for the player in the same sprite as the ball though since I can't seem to get it to run fast with the broadcast tick.

The final message on this thread was helpful: https://scratch.mit.edu/discuss/topic/366961/

Last edited by ComputerTeacherMON (Dec. 11, 2021 23:15:36)

CodingBaguette
Scratcher
500+ posts

Run without Screen Refresh Issue for AI experiment

ComputerTeacherMON wrote:

Thanks. My goal is to have entire game simulations happen as fast as possible so that is why I had tried that structure. I experimented with various ways and I think I might have found something that works. I switched the repeat until to a repeat 300 and I got rid of the broadcast and just called the movesteps block from the 300steps block and now it seems to be doing what I want. I might have to put the code for the player in the same sprite as the ball though since I can't seem to get it to run fast with the broadcast tick.

The final message on this thread was helpful: https://scratch.mit.edu/discuss/topic/366961/
yes, that thread explains it perfectly. So maybe when you activate the block do the
repeat until <(game over) = [1]>
Play1Game
broadcast [ tick]
end

Powered by DjangoBB