the top most left (corner) is the starting point. then it will travel. the gray areas are the traveled areas.

In this 2 dimensional array how will i measure the diagonality of these traveled paths?

The only way I can think of is to translate the points of the path into points on the coordinate plane. Then you could calculate the line of best fit. Using the slope of the line of best fit you could find the diagonality of the path if you know where the line starts (perfect diagonality would be a slope of -1 in this case).

I have not put much thought into it, this is just the first idea that popped into my head.

That's a pretty bad way to do it.

What is your goal in life? Or more specifically, what is your goal by solving this problem?

You haven't specified your question enough, either. Do you want the algorithm to punish walks that have more grey squares? Which of these are more diagonal?

``````***.. ***..
...*. ..**.
....* ...**
....* ....*
....* ....*``````

That's a pretty bad way to do it.

What is your goal in life? Or more specifically, what is your goal by solving this problem?

You haven't specified your question enough, either. Do you want the algorithm to punish walks that have more grey squares? Which of these are more diagonal?

``````***.. ***..
...*. ..**.
....* ...**
....* ....*
....* ....*``````

this is actually a flood-it puzzle. you can find this game here : http://www.google.com.ph/url?sa=t&rct=j&q=flood+itgame&source=web&cd=1&ved=0CC8QFjAA&url=http%3A%2F%2Ffloodit.appspot.com%2F&ei=1bVFT7iAEoqWiQe_r43-Ag&usg=AFQjCNEpCh1Ie5j7K4tYid-qUJ9u6Czp-w&sig2=lW0lv6wRZEDaRyXy5YviTg.

the grey squares are actually the paths traveled. the goal is to flood the board with one color. but i just want to measure how diagonal are the traveled paths. in this point, im not much interested in obtaining the goal but instead much on the diagonality measure.

the board is supposed to be coloured. but im just showing the path traveled so i did not colour it anymore.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.