CPFace Posted September 3, 2006 Share Posted September 3, 2006 I'm looking for advice for a routine I want to write. I have an idea how it could work, but I was wondering if anyone had any more efficient ideas. All I'm looking for is a general strategy -- code is appreciated, but not necessary, and if you do decide to code it, assembly is just as good as BASIC. Here's the behavior I'm looking for: The variables a, b, c, d, and e must all be set to random numbers from 0 to 7. Every value must be unique; there can be no duplicates. The variables a and b are already determined when the routine begins. They may change between calls to the routine, but they are not randomly selected. (It can be assumed that a and b are not equal.) The routine has to finish in a predictable amount of time and, of course, operate as quickly as possible. The program can't sit and reselect random numbers until the conditions are met because how long it takes can't be predicted. The routine doesn't have to be statistically perfect -- it's okay if one number or another has a slightly higher chance of being picked as long as the outcome can't be predicted. Here's the basic strategy I've come up with so far: Use temp1-6 to hold the numbers 0-7 that aren't equal to a or b. Maybe shuffle their values around a bit. (Pick two of them at random and switch the values around, repeat a certain number of times.) Select one of them at random, put the value into c. Select one of the remaining values at random, put it into d, repeat for e. Anyone else have any suggestions? Quote Link to comment https://forums.atariage.com/topic/93131-programming-puzzle-advice-wanted/ Share on other sites More sharing options...
CPFace Posted September 4, 2006 Author Share Posted September 4, 2006 And, as it turns out, I've decided to just have a number of pre-generated "scenarios" for the program to choose from to save code, execution time, and RAM. Quote Link to comment https://forums.atariage.com/topic/93131-programming-puzzle-advice-wanted/#findComment-1131968 Share on other sites More sharing options...
+atari2600land Posted September 4, 2006 Share Posted September 4, 2006 I enjoy puzzle games. Could you tell us more about this game you're working on? Quote Link to comment https://forums.atariage.com/topic/93131-programming-puzzle-advice-wanted/#findComment-1132019 Share on other sites More sharing options...
CPFace Posted September 4, 2006 Author Share Posted September 4, 2006 It's not a puzzle game -- the problem of assigning random values to the variables was the puzzle. The game I'm working on may yet be a fairly generic dungeon-crawler. The routine was intended to randomize contents in the maze. Problem is, if I go the route I've chosen, it's going to take half a kilobyte of my ROM space just to store the random scenarios! O_o Depending on how things go, I may just have to resort to non-randomized maze contents. Quote Link to comment https://forums.atariage.com/topic/93131-programming-puzzle-advice-wanted/#findComment-1132130 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.