OverviewFelgo 1 Support › Creating random numbers from selected number

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


    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,


    Felgo Team


    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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support