chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


I Need Help With This Vector Problem filter_list
Author
Message
I Need Help With This Vector Problem #1
Recently I've been a bit burned out, and I can't seem to figure out this problem I have. It's for a game I had been working on for a side project when I'm bored. The code I'll be showing below is for an infection chance menu. It'll basically just shuffle the integers in the first vector, and then print them to the first if statement. When the integers are first printed it then pushes them into the second vector. It does this so the infection chance isn't selected until a week has passed (In game time). Which means it shouldn't push back new integers to that second vector until the boolean scavengeOpened, is equal to false.

I couldn't post the code in a code box because it destroys the formatting.

[ Redacted my code ]

Sorry if this is a little bit confusing but I couldn't find any help for this specific problem anywhere else.
(This post was last modified: 06-10-2019, 04:13 AM by Drako. Edit Reason: Fixed my problem )
[Image: tumblr_n4fsswcwZa1sbhzgao1_250.gif]

"Crack it open, throw it in a pan and let it cook." ~ Filthy Frank

Reply

RE: I Need Help With This Vector Problem #2
I need to bump this because I can't do anything until this is resolved.
[Image: tumblr_n4fsswcwZa1sbhzgao1_250.gif]

"Crack it open, throw it in a pan and let it cook." ~ Filthy Frank

Reply

RE: I Need Help With This Vector Problem #3
Sorry for the shit thread. I figured out my problem on my own, I just needed some sleep I guess.
[Image: tumblr_n4fsswcwZa1sbhzgao1_250.gif]

"Crack it open, throw it in a pan and let it cook." ~ Filthy Frank

Reply

RE: I Need Help With This Vector Problem #4
I realize I'm a bit late to the party here. Happy that you figured it out, but were you planning on posting your solution and thought process?

Reply

RE: I Need Help With This Vector Problem #5
(07-17-2019, 05:30 PM)phyrrus9 Wrote: I realize I'm a bit late to the party here. Happy that you figured it out, but were you planning on posting your solution and thought process?

I'll upload it again later. I ended up breaking the code again.
(This post was last modified: 07-17-2019, 05:32 PM by Drako.)
[Image: tumblr_n4fsswcwZa1sbhzgao1_250.gif]

"Crack it open, throw it in a pan and let it cook." ~ Filthy Frank

Reply

RE: I Need Help With This Vector Problem #6
(07-17-2019, 05:30 PM)phyrrus9 Wrote: I realize I'm a bit late to the party here. Happy that you figured it out, but were you planning on posting your solution and thought process?

I forgot about this entire thread so I'm sorry for the late response. I'll try and explain what the code is supposed to do, and what the issue is as best as I can.

This code is for a function in my game where a player can scavenge for items in certain locations. And these locations have infection chances. There is also a function that moves the game into a new week (in game week). Once a new week has occurred, I want the infection chances to change. And in my original solution, it doesn't work.

(I modified the code a bit from my original solution so you could understand it better. If you want me to explain my original solution just ask.)

Code:
    std::vector<int> infectChance = {5, 10, 15, 20, 25, 30, 35, 40, 45}; //List of possible infection chances

    std::cout << "  1 > Kin | Location Size: Large | Infection Chance: " << infectChance[0] << "%" << '\n' //Prints everything
                << "  Location Description - Kin is the largest location in the region, you'll" << '\n'
                << "  probably find lots of loot, but just as many bad guys.\n" << '\n'
                << "  2 > Military Outpost | Location Size: Large | Infection Chance: " << infectChance[1] << "%" << '\n'
                << "  Location Description - The government let us down. So does that mean" << '\n'
                << "  you can take their stuff now? Hell yes!\n" << '\n'
                << "  3 > Vernal | Location Size: Medium | Infection Chance: " << infectChance[2] << "%" << '\n'
                << "  Location Description - A pretty under-developed, rundown town." << '\n'
                << "  It's still got stuff though. Maybe.\n" << '\n'
                << "  4 > Mason | Location Size: Medium | Infection Chance: " << infectChance[3] << "%" << '\n'
                << "  Location Description - A better more developed Vernal. Go check it" << '\n'
                << "  out.\n" << '\n'
                << "  5 > Mavren | Location Size: Small | Infection Chance: " << infectChance[4] << "%" << '\n'
                << "  Location Description - OK, lets just make this short and sweet. it's" << '\n'
                << "  trailer park. Don't expect a thing.\n" << '\n'
                << "  6 > Return To Bunker\n" << '\n';
[Image: tumblr_n4fsswcwZa1sbhzgao1_250.gif]

"Crack it open, throw it in a pan and let it cook." ~ Filthy Frank

Reply

RE: I Need Help With This Vector Problem #7
(08-07-2019, 07:59 PM)Drako Wrote:
(07-17-2019, 05:30 PM)phyrrus9 Wrote: I realize I'm a bit late to the party here. Happy that you figured it out, but were you planning on posting your solution and thought process?

I forgot about this entire thread so I'm sorry for the late response. I'll try and explain what the code is supposed to do, and what the issue is as best as I can.

This code is for a function in my game where a player can scavenge for items in certain locations. And these locations have infection chances. There is also a function that moves the game into a new week (in game week). Once a new week has occurred, I want the infection chances to change. And in my original solution, it doesn't work.

(I modified the code a bit from my original solution so you could understand it better. If you want me to explain my original solution just ask.)

Code:
    std::vector<int> infectChance = {5, 10, 15, 20, 25, 30, 35, 40, 45}; //List of possible infection chances

    std::cout << "  1 > Kin | Location Size: Large | Infection Chance: " << infectChance[0] << "%" << '\n' //Prints everything
                << "  Location Description - Kin is the largest location in the region, you'll" << '\n'
                << "  probably find lots of loot, but just as many bad guys.\n" << '\n'
                << "  2 > Military Outpost | Location Size: Large | Infection Chance: " << infectChance[1] << "%" << '\n'
                << "  Location Description - The government let us down. So does that mean" << '\n'
                << "  you can take their stuff now? Hell yes!\n" << '\n'
                << "  3 > Vernal | Location Size: Medium | Infection Chance: " << infectChance[2] << "%" << '\n'
                << "  Location Description - A pretty under-developed, rundown town." << '\n'
                << "  It's still got stuff though. Maybe.\n" << '\n'
                << "  4 > Mason | Location Size: Medium | Infection Chance: " << infectChance[3] << "%" << '\n'
                << "  Location Description - A better more developed Vernal. Go check it" << '\n'
                << "  out.\n" << '\n'
                << "  5 > Mavren | Location Size: Small | Infection Chance: " << infectChance[4] << "%" << '\n'
                << "  Location Description - OK, lets just make this short and sweet. it's" << '\n'
                << "  trailer park. Don't expect a thing.\n" << '\n'
                << "  6 > Return To Bunker\n" << '\n';

well that took forever Tongue

out of curiosity, since you're going the inefficient route of using cout, why are you streaming in a newline character instead of just using endl?

[+] 1 user Likes phyrrus9's post
Reply

RE: I Need Help With This Vector Problem #8
(08-07-2019, 08:01 PM)phyrrus9 Wrote:
(08-07-2019, 07:59 PM)Drako Wrote:
(07-17-2019, 05:30 PM)phyrrus9 Wrote: I realize I'm a bit late to the party here. Happy that you figured it out, but were you planning on posting your solution and thought process?

I forgot about this entire thread so I'm sorry for the late response. I'll try and explain what the code is supposed to do, and what the issue is as best as I can.

This code is for a function in my game where a player can scavenge for items in certain locations. And these locations have infection chances. There is also a function that moves the game into a new week (in game week). Once a new week has occurred, I want the infection chances to change. And in my original solution, it doesn't work.

(I modified the code a bit from my original solution so you could understand it better. If you want me to explain my original solution just ask.)

Code:
    std::vector<int> infectChance = {5, 10, 15, 20, 25, 30, 35, 40, 45}; //List of possible infection chances

    std::cout << "  1 > Kin | Location Size: Large | Infection Chance: " << infectChance[0] << "%" << '\n' //Prints everything
                << "  Location Description - Kin is the largest location in the region, you'll" << '\n'
                << "  probably find lots of loot, but just as many bad guys.\n" << '\n'
                << "  2 > Military Outpost | Location Size: Large | Infection Chance: " << infectChance[1] << "%" << '\n'
                << "  Location Description - The government let us down. So does that mean" << '\n'
                << "  you can take their stuff now? Hell yes!\n" << '\n'
                << "  3 > Vernal | Location Size: Medium | Infection Chance: " << infectChance[2] << "%" << '\n'
                << "  Location Description - A pretty under-developed, rundown town." << '\n'
                << "  It's still got stuff though. Maybe.\n" << '\n'
                << "  4 > Mason | Location Size: Medium | Infection Chance: " << infectChance[3] << "%" << '\n'
                << "  Location Description - A better more developed Vernal. Go check it" << '\n'
                << "  out.\n" << '\n'
                << "  5 > Mavren | Location Size: Small | Infection Chance: " << infectChance[4] << "%" << '\n'
                << "  Location Description - OK, lets just make this short and sweet. it's" << '\n'
                << "  trailer park. Don't expect a thing.\n" << '\n'
                << "  6 > Return To Bunker\n" << '\n';

well that took forever Tongue

out of curiosity, since you're going the inefficient route of using cout, why are you streaming in a newline character instead of just using endl?

I started doing that a while back when I read that endl was actually inefficient. What I read, and also heard from a lot of people was that it flushes and creates a newline. Which is unnecessary.
[Image: tumblr_n4fsswcwZa1sbhzgao1_250.gif]

"Crack it open, throw it in a pan and let it cook." ~ Filthy Frank

Reply

RE: I Need Help With This Vector Problem #9
(08-07-2019, 08:02 PM)Drako Wrote:
(08-07-2019, 08:01 PM)phyrrus9 Wrote:
(08-07-2019, 07:59 PM)Drako Wrote: I forgot about this entire thread so I'm sorry for the late response. I'll try and explain what the code is supposed to do, and what the issue is as best as I can.

This code is for a function in my game where a player can scavenge for items in certain locations. And these locations have infection chances. There is also a function that moves the game into a new week (in game week). Once a new week has occurred, I want the infection chances to change. And in my original solution, it doesn't work.

(I modified the code a bit from my original solution so you could understand it better. If you want me to explain my original solution just ask.)

Code:
    std::vector<int> infectChance = {5, 10, 15, 20, 25, 30, 35, 40, 45}; //List of possible infection chances

    std::cout << "  1 > Kin | Location Size: Large | Infection Chance: " << infectChance[0] << "%" << '\n' //Prints everything
                << "  Location Description - Kin is the largest location in the region, you'll" << '\n'
                << "  probably find lots of loot, but just as many bad guys.\n" << '\n'
                << "  2 > Military Outpost | Location Size: Large | Infection Chance: " << infectChance[1] << "%" << '\n'
                << "  Location Description - The government let us down. So does that mean" << '\n'
                << "  you can take their stuff now? Hell yes!\n" << '\n'
                << "  3 > Vernal | Location Size: Medium | Infection Chance: " << infectChance[2] << "%" << '\n'
                << "  Location Description - A pretty under-developed, rundown town." << '\n'
                << "  It's still got stuff though. Maybe.\n" << '\n'
                << "  4 > Mason | Location Size: Medium | Infection Chance: " << infectChance[3] << "%" << '\n'
                << "  Location Description - A better more developed Vernal. Go check it" << '\n'
                << "  out.\n" << '\n'
                << "  5 > Mavren | Location Size: Small | Infection Chance: " << infectChance[4] << "%" << '\n'
                << "  Location Description - OK, lets just make this short and sweet. it's" << '\n'
                << "  trailer park. Don't expect a thing.\n" << '\n'
                << "  6 > Return To Bunker\n" << '\n';

well that took forever Tongue

out of curiosity, since you're going the inefficient route of using cout, why are you streaming in a newline character instead of just using endl?

I started doing that a while back when I read that endl was actually inefficient. What I read, and also heard from a lot of people was that it flushes and creates a newline. Which is unnecessary.

You'd be correct on it being inefficient, but the entirety of cout is that way. As for flushing the stream though, that's what std::flush is for.

Reply

RE: I Need Help With This Vector Problem #10
(08-08-2019, 04:02 AM)phyrrus9 Wrote:
(08-07-2019, 08:02 PM)Drako Wrote:
(08-07-2019, 08:01 PM)phyrrus9 Wrote: well that took forever Tongue

out of curiosity, since you're going the inefficient route of using cout, why are you streaming in a newline character instead of just using endl?

I started doing that a while back when I read that endl was actually inefficient. What I read, and also heard from a lot of people was that it flushes and creates a newline. Which is unnecessary.

You'd be correct on it being inefficient, but the entirety of cout is that way. As for flushing the stream though, that's what std::flush is for.

I had already built the entire program with cout so I didn't want to try and use printf. Printf is a lot faster. As for my problem, any solutions?
[Image: tumblr_n4fsswcwZa1sbhzgao1_250.gif]

"Crack it open, throw it in a pan and let it cook." ~ Filthy Frank

Reply






Users browsing this thread: 1 Guest(s)