0
I made a program that trains a neural network to play old game with the user. I need to rescue the value returned by the method this.academy.step
, which contains the position of the next computer move, but instead of the desired value, my code is returning a promise
.
var result = (async() =>
await this.academy.step([{teacherName: this.teacher, agentsInput: inputs}]))();
pole the
this.academy.step
? also– novic
You cannot wait for the return of a promise in a synchronous function. I see two options: convert the function to
async
or use the callback within thethen
to access the solved promise value in the synchronous function. To learn more, see here and here.– Luiz Felipe
Virgilio Novic this method I took from the Reimprovejs library
– Daniel Reis
There is no await within synchronous functions, read only the first two paragraphs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
– LeAndrade