Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › Creating random numbers from selected number

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6512

    PanflamCutie

    Dear Felgoteam,

    I want to create an entity with artificial intelligence. It should be possible to move either up, down, left or right (on its own) and it should choose the direction, in which it should head next, dynamically depending on the obstacles, which are surrounding it.

     

    Therefore I planned to spacify a “static” number for each direction – up (1), right (2), down (3), left (4) – these numbers are just examples and can be changed. I wanted to create random numbers in this range and decide which way to go. But I wanted to know if there is a way to use this method efficiently if for example the way “up” and “down” is blocked. In this case I would have to create either the number 2 (right) or 4 (left) randomly to decide which direction to go.

    Is there an efficient way to do this.

     

    Thanks for your help in advance.

    Best regards,
    PanflamCutie

    #6545

    Christian
    Felgo Team

    Hi,

    you can create random numbers with Math.random() and then decide based on this random numbers with further if-checks.

    Cheers, Chris

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded