how would u await something, if you cant use promises and await 👀
I have a function in a class that cannot be async,
however in that function i need to run another function that will do a playthrough of a game (basically just run a set interval, every 50 ms) and when that returns, then execute the rest of the function
i dont think that can work with a callback
as i specifically need to wait for the function that does the playthrough to complete as it returns values that the outer function needs.
which would be a perfect usecase for async await, but the function isnt async, and cant be made async without modifying the lib
26 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
sure
but
seed()
should only return Entity
not a promise. (also this code doesnt work)Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
because i need the value from the game, in the return value
so currently i have
however
seed
should be returning an entity, not a promise
i need the values to be changed for the seedUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
ye the issue is i need it in the setInterval
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
because I am basicallly having to poll the chrome dino game every 50ms to check if i should jump.
and only way to do that is to have it in a setInterval
the other solution was a while loop, but theres no way to sleep a while loop in JS
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
GitHub
GitHub - Glavin001/genetic-js: Advanced genetic and evolutionary al...
Advanced genetic and evolutionary algorithm library written in Javascript - GitHub - Glavin001/genetic-js: Advanced genetic and evolutionary algorithm library written in Javascript
the thing is i should be able to make it a promise
its an async function
but basically to generate my seeds
each entity should do a playthrough of the game
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
yea
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
👍
should i await in the clone?
or
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ah true
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
well time to fork it and edit i guess haha
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
do u think maybe i need to reconsider my approach too?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
coz i just cant think of a way to generate the seed without a playthrough of the game first
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ye fair enough. haha honestly still new to doing AI shit lmao