How to write a sequence generator algorithm

Discussion in 'iOS Programming' started by newlearner, Sep 5, 2010.

  1. newlearner macrumors member

    newlearner

    Joined:
    Jul 30, 2009
    Location:
    india
    #1
    Hello all,
    I am developing a location based app wherein a random generator algorithm is needed. The app loads up with a number of images which the user has to reach. An algorithm has to be written where in the sequence of images has to be drawn upon three factors: total time entered by the user to play the game, total distance and the difficulty factor associated with reaching each place. The app continuously monitors if the user has reached the place displayed in the iPhone. If the user is on the same place as the image, the next in line location's image gets displayed. If the total time is less and the number of images in the sequence are more, the algorithm needs to backtrack and find another set of sequence of images of reaching the last destination in the list.

    The app needs to implement an algorithm which is dynamically drawing out a sequence of images with respect to distance and time.

    Any guidance is appreciated.

    Thanks
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
  3. newlearner thread starter macrumors member

    newlearner

    Joined:
    Jul 30, 2009
    Location:
    india
    #3
    I have got the images downloaded from the server, configured the CLLocationManager to give updates while the iPhone is on the move. I have stored the images and their accompanying data like GPS coordinates in a NSMutableArray. Using arc4random() am able to randomly choose one of the location images,but do not know how to proceed further to list out a sequence.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    Each image represents a place. Each place has a distance between itself and every other place. Some places can only be reached by going through another place (connectivity).

    A distance can be measured without regard to obstacles (as the crow flies), or with regard to obstacles (as the horse walks). Two places could be within 100 meters as the crow flies, but on opposite sides of a deep river gorge as the horse walks. So you have to account for elevation, obstacles, and traversable pathways, not just as-the-crow-flies distance.

    And that brings you to geographical routing, path planning, and a whole lot of mathematics.
    http://en.wikipedia.org/wiki/Routing
    http://en.wikipedia.org/wiki/Geographic_routing
    http://en.wikipedia.org/wiki/Connectivity_(graph_theory)
    http://en.wikipedia.org/wiki/Graph_theory

    But if you don't start with basic distance and connectivity information, you can't get anywhere else.
     

Share This Page