Algorithm Brainstorming.
Mar. 9th, 2012 11:02 pm- A poem is:
- A collection of words all of which are in collision with each other.
- When a word is moved:
- If it belonged to the poem, we must decide if it has left the poem.
- If it does not belong to the poem, we must decide if it has joined the poem.
- When the last two words of a poem are pulled apart
- We must see if where the last word to be moved landed starts a new poem
It probably needs unit testing.
no subject
Date: 2012-03-10 03:59 pm (UTC)no subject
Date: 2012-03-10 04:20 pm (UTC)You use 'the poem' and 'a new poem' - how many poems are there? Are there such things as free-floating words which are not part of a poem, or are those single-word poems?
no subject
Date: 2012-03-10 05:13 pm (UTC)Correct! Good guess.
There is always only one poem. When it's down to two words, if the last word moved is in collision with another word, that starts a new poem.
I have the algorithm almost right. I just need to do a mark-and-sweep now of the poem's bounding box if someone takes a word out of the middle of the poem because that could fragment the poem into two parts, and I need to decide which part is "the" poem at that point.
My first programming guru, Eugene Jarvis, once said that the way for software to appear smart was to not do anything stupid. So far, so good...