How do I create an algorithm?

0 favourites
  • 5 posts
From the Asset Store
Finding the shortest path through the cells based on the A-star algorithm
  • Hello fellow Construct 2 users, I've recently run into a couple of problems with an app I'm trying to make. My app consists of an XY array. On my X axis, I have words. On my Y axis, I have sentences. I need to fill the elements in between with combinations of the X and Y values.

    Here's an example:

    Let's say that my X axis consists of the values "moose" with an index of 0, "goat" with an index of 1, and "monkey" with an index of 2.

    My Y axis consists of the values "We saw a cat" with an index of 0, "You want a cat" with an index of 1, and "I own a cat" with an index of 2.

    You follow?

    Now what I need to do is swap out the word "cat" with all of the other X values and record them into my array.

    For instance. Point (0,0) on my new array would have a value of "We saw a moose", and point (1,2) would have a value of "I own a goat."

    I have to replace one word in the sentence with every element in my X axis and record the new sentences in every combination into the array.

    I've tried many methods but they all involve me entering the data to every XY point by hand. Unfortunately my entire array will need to consist of about 1 million elements, seeing how my X and Y axis both have 1000 elements each. I don't have 4 months straight to sit and type in every possible combination for the values of every XY index.

    Is there anyway to solve this problem?

    ~TylerNormal

  • Should be something like set the array to:

    "We saw a"&arrayat(array.curx,0)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So set all of my X's and Y's, and then use that formula to generate the X (new word) value into the Y value (sentence).

    What if I'd need to replace a word in the middle of the sentence?

  • Something like this:

    "We saw a"&arrayat(array.curx,0)&"in the street"

  • But you could choose not to put all those sentences in the array and just create them from a string, that way you'd only have to have an array with all the different animals..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)