Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:
You awake with a throbbing headache and blurred vision. As you come to, you realize you are not in your room and the sudden adrenaline rush gets you fully alert. The room is such a stark white that it is hard to tell where the edges and corners are. As you get up to go out one of the many open doors in the room, one of the walls turns into a display monitor. On the monitor is a bunch of green blobs glowing with different intensities and lines connecting blobs to each other. You almost forget what is going on as you watch a blip zipping around from blob to blob. As you realize there might be some significance to the one red blob, a voice greets you.
The first thing the voice tells you is that in 24 hours, you will live or die depending on your intellect or your luck. You try to keep a level head as you realize that this must be a recording. The voice is not responding to your questions and your pleas for an explanation are futile. You must pay attention because you do not know if this information will be repeated.
....is how much you have to collect in order to save your life. At the center of each room is a token worth different amounts. In 24 hours from now, if you have not collected enough to pay the ransom, your life is forfeit. If you are able to actually survive *stifled laughter*, any amount above the ransom will be deposited into your bank account. I hope you have been paying attention to the map on the screen. The blip is tracing the path to your salvation. The screen blanks out and returns once again to the stark white wall. Oh, one last thing the voice says, the rules about which doors stay open and close change as you go.
Silence. No, not silence - you can hear the pounding of your heart as you try to think. The map looked like an undirected graph. The red blob must represent the room I am in. The blip. The blip is important - where was it going - grrrrrr I should have paid more attention. Rules, what rules. Ok. Calm down and think. Assuming I wasn't lied to, this can't be the travelling salesman problem nor the hamiltonian path problem because I should be able to collect enough for the ransom and still have money left over. It seems like it is the Longest path problem which is NP complete - damn. Well, maybe not. Obviously a short path could still win provided the tokens collected were sufficient. Also, there is a time limit which implies not all possible paths can be searched - damn again - the voice did say luck could be a factor. Ok, so I need to find a path that allows me to collect - what was the ransom - I can't remember - was I listening - it doesn't matter, just collect as much as I can as fast as I can. Ok, so what is my strategy. I vaguely remember something about not being able to return to a room without dropping the token from the current room and - grrr, I can't remember. I guess it doesn't matter, apparently the rules change anyway. I am wasting time.
As you look up to leave, you notice displays have appeared above each door. Each display reads "Token: $amount Open Doors: $num". You head down the hallways with the door with the largest token amount and when enter, it is just an empty room. So I can't trust the displays. You notice the token in the center of the room and when you pick it up to examine it, the door you came through immediately turns into a wall and doors open up with display. You put the token back and the room returns to its original state. You continue this process (choosing the door with the highest token amount) until you enter the 10th room, and then everything changes.
The number of doors that should have opened didn't. You realize the rules are changing but you can't seem to figure out how. You continue your current strategy until you enter a room where no doors open. Do I have enough? Should I back track? How much time has gone by? Frustrated you backtrack and realize that every 10 tokens you collect, the rules change some how.
Ok, I hope you enjoyed my story introduction to the problem. Here is an explanation of the real problem.
I am working on is a strategy to play a word chain game. Each 4 letter word (approximately 4,000) represents each blob in the story's map. The blobs with connecting paths represent other 4 letter words that have an edit distance of 1. Points are awarded using letter frequency (rare letters are worth more points). These are the token values/blob intensity from the story.
Unlike the story version, figuring out how the rules of the game change is possible. Each level consists of 10 words and the next level replaces the current "rule" with a new rule. On level 1, the rule is "no restrictions". On level 2, the rule is "which ever letter you used to form the first word in level 2 can't be used in any word for the remainder of the level. On level 3, the rule is "You can't use the same position to form new words in back to back words". In other words, if you changed "mark" to "lark", you couldn't change it to "bark" but you could change it to "lurk" because it uses a different position. You can then go back to the first position if you want. I have only played a few times so I haven't figured out level 4 but you get the idea.
Now, I have already created a data structure where every word has a list of neighbors and their point value. This is why in the story version, you know how much each of your neighbors are worth and how many doors they have. Unfortunately, the number of doors is before applying rules and taking into consideration previously visited rooms. Keeping everything up to date is possible but time/resource consuming.
Ok, but how does the time limit come into play? In two ways. First, each time you make a choice of your next word there is a time limit to choose the next word. Fortunately, before you make your first move you are presented with your starting word so you can take as much time as you want to plan your path. I doubt I would let the computer think about it for 24 hours but if you precalculate your path then the time limit to choose the next word should be a moot point.
I hope I have explained everything adequately, but if I have not please feel free to reply or /msg me. If you are interested in playing the game yourself and are on FaceBook it is called "Word Chain Plus". The question I am asking is - given this situation, what strategy would you use to maximize your score. My current strategy (unimplemented):
Update: The ever changing rules get in the way long before "longest path" becomes an issue. See FaceBook's Word Chain Plus
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Not Quite Longest Path Problem
by Bloodnok (Vicar) on Oct 23, 2009 at 17:11 UTC | |
by Limbic~Region (Chancellor) on Oct 23, 2009 at 18:50 UTC | |
|
Re: Not Quite Longest Path Problem
by JavaFan (Canon) on Oct 23, 2009 at 16:14 UTC | |
by Limbic~Region (Chancellor) on Oct 23, 2009 at 18:46 UTC | |
|
Re: Not Quite Longest Path Problem
by jethro (Monsignor) on Oct 23, 2009 at 22:07 UTC | |
by Limbic~Region (Chancellor) on Oct 23, 2009 at 23:34 UTC | |
by jethro (Monsignor) on Oct 24, 2009 at 00:57 UTC | |
by Limbic~Region (Chancellor) on Oct 24, 2009 at 01:11 UTC | |
by jethro (Monsignor) on Oct 24, 2009 at 12:01 UTC | |
by JavaFan (Canon) on Oct 24, 2009 at 14:07 UTC | |
| |
|
Re: Not Quite Longest Path Problem
by SuicideJunkie (Vicar) on Oct 23, 2009 at 20:23 UTC | |
by Limbic~Region (Chancellor) on Oct 23, 2009 at 23:23 UTC | |
|
Re: Not Quite Longest Path Problem
by JavaFan (Canon) on Oct 24, 2009 at 14:56 UTC | |
by Limbic~Region (Chancellor) on Oct 24, 2009 at 16:03 UTC |