![]() |
|
#1
|
|||
|
|||
Question about RandomizingI am attempting to have my randomizer select a value from a vector based on the following:
high enough Integer Level, and Rarity of the value. For example, if the Level we are looking for is "6", I still want lower value items to possible, but less likely. Also, I want it to be able to deal with the fact that there might not be any level 6 items. My current program selects random values between 5-6 in this example, and doesn't work if there are no values for 6. Also there is no percent change for any of the items. (vector[random(5 start, 6 end)] ) If you recommend a different data type to store the values I'm all ears. Vector was chosen just to get a prototype working. |
|||
|
#2
|
|||
|
|||
Re: Question about RandomizingQuote:
What program? What example? In other words: Show Us The Code. Quote:
What language are you using? That isn't C, and it isn't C++. Maybe you should give an exact definition of the function you are using (or that you want to use), and maybe we can take it from there. Maybe you can show us your code that "doesn't work", and give a few details about what you tried that "doesn't work". Regards, Dave Last edited by davekw7x : 29-Dec-2006 at 09:25.
|
|
#3
|
|||
|
|||
Re: Question about RandomizingFirst off C++.
Ok, here we go. I understand you are a valued member of the community based upon the rank under your name. Therefore you must understand that as much as you hate vague posts, I also hate useless responces. I was attempting to keep the post as clear as possible without dragging all my code in here (everything is custom classes, including the randomizer). However because you asked for it, here is the things in question: I should first remark that the program compiles and runs perfectly, but the result does not meet the Boolean requirement(as it is not built in yet). Code:
Now you'll notice why I didn't post code. The only important part in that is the randomizer, which just picks a random value from 0 to the last value of items of m_lvl (m_lvl+1 is the starting point of the next level of items). (EDIT: I changed the floor value to 0 in since my first post) Code:
Now the required fix is this: Each value in the vector will also need several booleans to determine if they will successfully work with the other randomized values. Each one will have around 12-15 booleans. To me it seemed silly to create 12-15 different vectors, when many of the members would over lap, and I felt that regenerating the number until a successful one was found would be not very efficient. However regenerating values is the only way I can see around this problem. To be more clear: If the first random value comes up as a "Child", the next value that goes in will also be random, and may be something like "Broken". "Broken" would have a "false" bool for anything of type "person" as that doesn't make sence. However "Broken" will have a "true" bool for something like "Chair" when it does make sence. (Broken Chair=good, Broken Child=bad) I hope that helps, and I hope you find that more specific without being too long a post for such a simple question. The question again, is what would be the best way to generate the proper random item, which meets the required bool, in the vector. If vector is not the best choice for this, please suggest a better data structure. |
|
#4
|
|||
|
|||
Re: Question about RandomizingQuote:
Pretend for the moment that you are a Program Manager and you are in the middle of a project. The senior software engineer who was in charge of developing the code has been hit by a truck (may he/she Rest In Peace), and you are going to assign the task to another senior software engineer who has never heard of whatever application you are developing. How would you specify the required functionality? What kind of information (and how much information ) would you give the new guy? Maybe your posts would work for someone, but I am kind of clueless. Sorry. To you it might seem to be a "simple" question, but I don't really understand what you are trying to do, so I can't help. The advantage of an open forum like this is that anyone can step in at any time, and I hope someone can come up with a useful response. Regards, Dave Last edited by davekw7x : 30-Dec-2006 at 08:49.
|
|
#5
|
|||
|
|||
Re: Question about RandomizingScrewed if I do screwed if I don't huh? Are you the only one on these forums? Understand the part about booleans is theoretical: no code yet: trying to determine how to do it first.
You see, Dave, I cannot show you the code for something I am still attempting to figure out how to do. Therefore I'll do my best to explain once more, as concise as I can make it. And no I don't do role playing. The current status: 1) Everytime I randomize 1 base value, 2 other values are also randomized with it 2) It randomly picks a value in a vector based on a sorted vector using Integers(least to greatest) 3) This works perfectly What I want: 1) Each secondary value will be randomized with both integer and boolean requirements, rather than just based on integers 2) When randomized, the randomizer will pick "Person" before this is called. When this is called, it cannot have values that are "false" for the boolean correlating to "person". SO: ..............Happy(1).........Broken(1).......... .Metal(5) Person.....TRUE................FALSE.............. ...FALSE Chair.......FALSE...............TRUE.............. ....TRUE In this example, "Happy" should be the only result that comes out, but currently either of the other values are also possible(Metal only possible if LEVEL>=5). What is the best way to do this, without simply doing trial and error randomizations. That is to say, "Oops the bool is false, try a different random value". And one final note: I don't think I can explain this any simpler, this is as close as I can get as, if you recall: There is no code to go along with the boolean data. Because it doesn't exist yet. That's what I'm here for. I plan what I am doing before I code. Responding to this with anything other than some sort of advice on how to solve this problem will simply cause me to try my luck elsewhere. --Kalvorod |
|
#6
|
|||
|
|||
Re: Question about RandomizingIf you care what the program is, maybe this will help a bit
The program I'm doing now is a random item generator, such as those in Diablo. Base item + 2 magic modifiers, all random of course. If the base item is armor, having a damage modifier doesn't make sense. However, I do not want to hard code that. The idea is to make it so that if someone wants an armor that raises damage, then it's easily editable. |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| question on sorting items is not clear...plz help me | gvsivannarayana | C Programming Language | 0 | 28-Mar-2006 00:26 |
| non-member function question | crq | C++ Forum | 1 | 03-Feb-2005 21:59 |
| Simple question on arrays--please help! | brookeville | C++ Forum | 16 | 17-Nov-2004 23:23 |
| Repetition structure problem and question | brookeville | C++ Forum | 17 | 29-Oct-2004 17:48 |
| question of practice | magiccreative | C++ Forum | 1 | 06-Feb-2004 07:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The