|
Post by amongstshadows on Jan 13, 2017 2:36:44 GMT -5
So after some testing, looks like the random number algorithm and modulus operator are both effective ways to generate random numbers. As in one is not better than the other. Unless you're trying to generate a decimal(in which case the algorithm is the way to go) they are both fine. I'll stick with the modulus operator since I'm more used to it. Below is the code I used to test this
#include <iostream> #include <cstdio> #include <random> #include <ctime>
using namespace std;
int main() { default_random_engine gen(time(0)); uniform_int_distribution<int> dis(10, 20); for (int i = 0; i < 6; i++) { int a = dis(gen); cout << a << endl;} cout << endl; srand(time(0)); for (int j=0; j<6; j++) { int b = rand()%11+10; cout << b << endl;} return 0; }
|
|
|
Post by Cory Trese on Jan 13, 2017 15:02:37 GMT -5
I really don't see what we're testing here
|
|
|
Post by amongstshadows on Jan 13, 2017 15:20:48 GMT -5
I really don't see what we're testing here I was testing if the random number engine was better than using modulus operator. Looks like the engine is better for simulating dice rolls, but they both do their job
|
|
sheff
Star Hero
[ Star Traders 2 Supporter ]
Posts: 503
|
Post by sheff on Jan 14, 2017 8:37:41 GMT -5
I don't care about good\bad habit coding ideas because it varies depending on the language. Have to remember BASIC was created in 1964, I started in the late 80's. Lots has change since then. There's no such thing as bad code if your program does what it's suppose to. If... And that many times could be a big if. Trust me, I remember them trying to teach us basic coding in high school. It did not end well for me...
|
|
|
Post by ntsheep on Jan 14, 2017 13:32:45 GMT -5
That's strange sheff, I started teaching myself when I was around 10 and understood it fairly easy. I did have some trouble with graphics code, but was pretty good with every thing else. My Future Prediction and AI programs are fun.
|
|
|
Post by stratego on Jan 14, 2017 13:36:08 GMT -5
That's strange sheff, I started teaching myself when I was around 10 and understood it fairly easy. I did have some trouble with graphics code, but was pretty good with every thing else. My Future Prediction and AI programs are fun. I've never understood the graphics if they are written by hand, but I can do a lot with them if they are accessible🙂
|
|
|
Post by ntsheep on Jan 14, 2017 15:18:40 GMT -5
Really good graphics require a good understanding of some basic algebra. There's a lot you can do with simple commands and I would work with those ok. It's still one of the best ways to learn some beginning programming and there's lots of sites with free software.
|
|
|
Post by stratego on Jan 15, 2017 3:44:22 GMT -5
Really good graphics require a good understanding of some basic algebra. There's a lot you can do with simple commands and I would work with those ok. It's still one of the best ways to learn some beginning programming and there's lots of sites with free software. It's quite nice that there is this resources killer called android studio made
|
|
sheff
Star Hero
[ Star Traders 2 Supporter ]
Posts: 503
|
Post by sheff on Jan 15, 2017 7:36:57 GMT -5
That's strange sheff, I started teaching myself when I was around 10 and understood it fairly easy. I did have some trouble with graphics code, but was pretty good with every thing else. My Future Prediction and AI programs are fun. I guess I just didn't have any innate talent for it. Im of the opinion that a good prpgrammer is more artist than mathematician. It requires a certain abstract way of thinking that just didn't click with me too well. If nothing else, I can always blame the teacher, right?
|
|
|
Post by ntsheep on Jan 15, 2017 12:34:36 GMT -5
Blaming the teacher is a good idea. Several times throughout the years I've tried learning other codes like C++. I've bought books that came with the software, installed it and started working only to get error codes left and right when running the program they teach you. The kicker is almost every book has said the exact same thing, "Don't worry, you won't get any errors and we'll teach you about debugging in later chapters." I even loaded the copies of the programs from the disk just in case I had done something wrong, same problem each time. Too many teaching books expect you to already know things. If you knew what you were doing, you wouldn't need the book. Don't give up.
|
|
sheff
Star Hero
[ Star Traders 2 Supporter ]
Posts: 503
|
Post by sheff on Jan 15, 2017 12:44:36 GMT -5
I'm about ten years too late to not give up. I do physical work instead. As a plus, the benefits and hazard pay make up for it. I'm not bill gates, nor would I want to be, but I've got more than I'll ever need. Downside of contract work is that it kinda restricts being able to follow every whim, but, I won't complain. I still enjoy working with computers as a hobby. Troubleshooting can be both intensely frustrating and rewarding. Building a computer from scratch and then figuring out where you went horribly wrong is a great destresser right?
|
|
|
Post by stratego on Jan 15, 2017 17:21:29 GMT -5
Blaming the teacher is a good idea. Several times throughout the years I've tried learning other codes like C++. I've bought books that came with the software, installed it and started working only to get error codes left and right when running the program they teach you. The kicker is almost every book has said the exact same thing, "Don't worry, you won't get any errors and we'll teach you about debugging in later chapters." I even loaded the copies of the programs from the disk just in case I had done something wrong, same problem each time. Too many teaching books expect you to already know things. If you knew what you were doing, you wouldn't need the book. Don't give up. Just stackoverflow
|
|
|
Post by stratego on Jan 15, 2017 17:24:19 GMT -5
I'm about ten years too late to not give up. I do physical work instead. As a plus, the benefits and hazard pay make up for it. I'm not bill gates, nor would I want to be, but I've got more than I'll ever need. Downside of contract work is that it kinda restricts being able to follow every whim, but, I won't complain. I still enjoy working with computers as a hobby. Troubleshooting can be both intensely frustrating and rewarding. Building a computer from scratch and then figuring out where you went horribly wrong is a great destresser right? Yup, but it sometimes goes very frustrating with a motherboard you have designed your self and when something doesn't work you don't have any actual person to blame😈
|
|
|
Post by amongstshadows on Jan 15, 2017 18:33:29 GMT -5
Really good graphics require a good understanding of some basic algebra. There's a lot you can do with simple commands and I would work with those ok. It's still one of the best ways to learn some beginning programming and there's lots of sites with free software. SDL <in my shoutout voice>
|
|
|
Post by Lord Gansai on Jan 15, 2017 20:40:27 GMT -5
Really good graphics require a good understanding of some basic algebra. There's a lot you can do with simple commands and I would work with those ok. It's still one of the best ways to learn some beginning programming and there's lots of sites with free software. SDL <in my shoutout voice> Big +1 for SDL particularly for a beginner.
|
|