ReubenESTD

Members
  • Content count

    41
  • Joined

  • Last visited

Community Reputation

96 Neutral

About ReubenESTD

  • Rank
    Member
  1. Functions and Variables (C++)

    [quote name='ArthY303' timestamp='1311253197' post='4838421'] Hello, [code] void timestepfoward(){ otherfactors(); cout << "\n\nIt is currently year " << currentyear << " and the population is " << initpop << ".\n"; cout << "How many years would you like to skip? "; cin >> t; population(); currentyear = t+currentyear; cout << "\nIt is now year " << currentyear << " and the population is now " << newpopulation << ".\n"; newpopulation=initpop; // shouldn't this line be: initpop = newpopulation; ? mysociety(); } [/code] [/quote] Actually that did fix it xD
  2. Functions and Variables (C++)

    This is my complete code.[code]#include <iostream> #include <cmath> #include <math.h> #include <stdio.h> using namespace std; //MAIN FUNCTIONS: void intro(); // the introduction story sequence function void namefunc(); // adds HOIC to beginning of name, couts complete name void mysociety(); // sets the initial values for each factor/variable. void otherfactors(); //temporary function to effect births and deaths. void population(); // natural logarithm for population growth. void birthdeathrate(); //yearly birth and death rate void timestepfoward(); //performs all neccasary proceedures to fast foward time void changes();//main changes menu. void aboutyoursociety();//tells user about society. void initsetup(); //FACTOR FUNCTIONS: void politicalsystem();//executes poltical system algorithm. //CHANGE FUNCTIONS: void inputpoliticalsystemchanges();//allows user to implement political changes. //PRESENTING INFO FUNCTIONS: void politicsinfo();//states political info. //MAIN VARIABLES: double births;//births over a year double deaths;//deaths over a year double popgrowth; // population growth over a year (percentage) double t=0; //time in years int currentyear=0; //current year unsigned int initpop=1000; //holds the population at the start of each period. unsigned int newpopulation; char name[21]; // holds user input name int publicapproval; int economicrating; //CHANGE VARIABLES: int democracy=0; int dictatorship=0; int communist=0; int Politicsystemtype; //EXP VARIABLES: int politicalsystemexp; int main() { intro(); mysociety(); return 0; } void intro(){ cout << "The year is 2332...\n" << "The human population of earth has surpassed 15 billion.\n"; cout << "The world is on the brink of revolution and the Eurasian Alliance have decided\n"; cout << "that in order to secure the future of the human race, the Utopia Protocol must be initiated."; cout << "\n\n" << "The Utopia Protocol originated under president Elysia, the 60th president of theUnited States,"; cout << " as a reformation article and safeguard against the threat of \nmutually assured destruction during the 2073 energy crisis. "; cout << "\n\n" << "The protocol has recently been redesigned by the Alliance to make use of modern tecnology and engineering advances."; cout << "\n\n" << "It states that 'in order to ensure Humanity's prosperity and longevity, a \nUtopian society must be created'."; cout << " It continues, 'A large scale Utopian society \nmust be built, not simply initialised in order for it to be stable and \ncomplete'."; cout << " Recent advances in technology have allowed scientists to create \nhumanoids which replicate human behaviour with 99.9% accuracy."; cout << " These humanoids \nare capable of reproduction and decomposition."; cout << "\n\n" << "This is where you come in." << "\n\n" << "You are a H.I.N.C (Hive Intelligence Network Command),"; cout << " a highly advanced AI thatforms the subconcious of all humaniods. This gives you an indirect control over the entire humanoid population."; cout << "\n\n" << "You are based on one of around 200 habitable planets in the Milky Way where a \nH.I.N.C has been established."; cout << " You are tasked with creating a Utopian society in which humanity can eventually migrate to, replacing the humanoid population."; cout << "\n\n" << "Now, what would you like to be called? "; cin >> name; cout << "\nOkay "; namefunc(); cout << ", you have the power to create a paradise or a hell. \nAll the desions you make will have ramifications, be they positive or negative."; cout << " The decisions start here.\n\n\n\n"; initsetup(); } void namefunc(){ char hinc[]= "H.I.N.C: "; cout << hinc << name; } //****USER CHANGES**** //initial setup: void initsetup(){ } //loop options: void mysociety(){ cout << "Here is the current state of your society: \n\n"; //display current statistics cout << "The current population of your society is " << initpop << " humanoids." << endl; //user action cout << "\nEnter '1' if you would like to skip a number of years, '2' if you would like \nfurther information about your society or any other number if you would like to make changes to your society: "; int skiporchange; cin >> skiporchange; if(skiporchange == 1)timestepfoward(); else if(skiporchange == 2)aboutyoursociety(); else changes(); } //****CHANGES MENU**** void changes(){ cout << "\nWhich factor would you like to change?\n\n"; cout << "1. The political system" << endl; cout << "2. Investment in industries/resources" << endl; cout << "3. Religion" << endl; cout << "4. Education" << endl; cout << "\nEnter the number of the factor you would like to change: "; int factornum; cin >> factornum; switch(factornum){ case 1: inputpoliticalsystemchanges(); break; case 2: break; } //switch statement that allows access to changing each factor and ends by reverting to changes() or my } //****CHANGES FUNCTIONS**** void inputpoliticalsystemchanges(){ restart: cout << "\nYou have ten points to distribute amongst three systems: Democracy, Dictatorship and Communism."; cout << "\nHow many would you like to assign to Democracy? "; cin >> democracy; cout << "\nHow many would you like to assign to Dictatorship?" << " You have " << 10-democracy << " points left. "; cin >> dictatorship; cout << "\nHow many would you like to assign to Communism?" << " You have " << (10-democracy)-dictatorship << " points left. "; cin >> communist; if((democracy+dictatorship+communist)!=10) { cout << "\nYou failed to assign all the points correctly. "; goto restart;} else cout << "\n\nEnter '9' to return to the changes section. Or any other number to change these values again."; //change to switch. int back; cin >> back; switch(back){ case 9: changes(); break; default: goto restart; } } //****SOCIETY INFORMATION**** void aboutyoursociety(){ cout << "\nWhich element of your society would you like to know about? \n\n"; cout << "1. Illness" << endl; // etc. } //****SOCIETY INFO FUNCTIONS**** void politicsinfo(){ } //****TIME/EXPONENTIAL POPULATION GROWTH**** void timestepfoward(){ otherfactors(); cout << "\n\nIt is currently year " << currentyear << " and the population is " << initpop << ".\n"; cout << "How many years would you like to skip? "; cin >> t; population(); currentyear = t+currentyear; cout << "\nIt is now year " << currentyear << " and the population is now " << newpopulation << ".\n"; newpopulation=initpop; mysociety(); } void population(){ popgrowth=(births-deaths)/initpop+1; newpopulation = initpop*exp( (births-deaths)/initpop * t ); } void otherfactors(){ births = 24; deaths = 19; // will be more complex when taking other variables into account. } //****AUTOMATIC (changing according to user-inputed variables) FACTOR FUNCTIONS**** void politicalsystem(){ Politicsystemtype=((11*democracy)+dictatorship); //if pol syst > x and < y it is a Z - implement in an if else loop for all sytems. //Exp double politicalsystemexp1; double politicalsystemexp2; if(publicapproval >= 0.5) politicalsystemexp1 = publicapproval*10; if(economicrating >= 50) politicalsystemexp2 = economicrating/10; politicalsystemexp = politicalsystemexp1 + politicalsystemexp2; } //****EVENTS**** [/code] @rip-off I will give that a try later, thanks +1!
  3. Functions and Variables (C++)

    Ok so first of all I assign initpop to 1000 (otherwise the formula wouldn't work (if it were 0)) then after population() has run the newpopulation should be assigned to the initpop (initial population) so that the formula will work every time it is called. [code]unsigned int initpop=1000; //holds the population at the start of each period. unsigned int newpopulation;[/code]
  4. Functions and Variables (C++)

    [code]void mysociety(){ cout << "Here is the current state of your society: \n\n"; //display current statistics cout << "The current population of your society is " << initpop << " humanoids." << endl; //user action cout << "\nEnter '1' if you would like to skip a number of years, '2' if you would like \nfurther information about your society or any other number if you would like to make changes to your society: "; int skiporchange; cin >> skiporchange; if(skiporchange == 1)timestepforward(); else if(skiporchange == 2)aboutyoursociety(); else changes();}[/code] When I press '1' the timestepforward function is called. Its code is as follows: [code]void timestepfoward(){ otherfactors(); cout << "\n\nIt is currently year " << currentyear << " and the population is " << initpop << ".\n"; cout << "How many years would you like to skip? "; cin >> t; population(); currentyear = t+currentyear; cout << "\nIt is now year " << currentyear << " and the population is now " << newpopulation << ".\n"; newpopulation=initpop; mysociety(); } void population(){ popgrowth=(births-deaths)/initpop+1; newpopulation = initpop*exp( (births-deaths)/initpop * t ); }[/code] My problem is that when I call the first function after doing a time step forward, (mysociety()), the global variable for initpop has not updated! Why is this?
  5. Gödelization - help needed.

    [quote name='luca-deltodesco' timestamp='1306759889' post='4817483'] I've not heard of [color="#1C2837"][size="2"]G[font="arial, sans-serif"][size="2"][i]ö[/i][/size][/font]delization, but that just looks to be the prime factorisation of an integer for which it is quite easy to prove that a) it exists, and b) that it is unique.[/size][/color] [color="#1C2837"] [/color] [color="#1C2837"][size="2"]An intuitive proof for existance would be: let N be a number, either N is prime or it is not prime. If it is not prime then there must exist a prime P and a possibly non-prime M (otherwise N would be prime).[/size][/color] [color="#1C2837"][size="2"]In the same way, repeat with M instead, and eventually you either get a prime number, or 1. from which it is easy to construct a formal inductive proof.[/size][/color] [color="#1C2837"] [/color] [color="#1C2837"][size="2"]Proof of uniqueness is a little bit harder, a sketch proof would be: Let N be the smallest integer expressible as the product of two minimal; non-identical sets of primes s1,s2..sn q1,q1...qm[/size][/color] [color="#1C2837"][size="2"]as N is the smallest such number, then s1, and s2...sn, must have unique factorisations as they are smaller than N.[/size][/color] [color="#1C2837"][size="2"]p1 then, must either divide s1, or s2...sn (or both, not important) and as all are prime, si = qj for some i,j. By removing si,qj from the two non-equal factorisations we get two smaller, equal numbers. as they are smaller than N, by assumption they have unique factorisations and so the two factorisations cannot be different.[/size][/color] [/quote] [quote name='quasar3d' timestamp='1306787930' post='4817652'] You probably know (and as luca-deltadesco explained) that any integer can be factored into a unique prime factorization, and G[font="sans-serif"][size="2"]ö[/size][/font]delization is a trick that uses this fact to encode a whole sequence of numbers into a single integer by taking the product of the first prime raised to the power of the first element of your sequence, the second prime raised to the power of the second element, and so on. This gives you a single integer that encodes your whole sequence. for example, the sequence of the first 4 squares (1,4,9,16) can be encoded as 2^1 * 3^4 * 5^9 * 7^16 = 10515106938037816406250 [/quote] Thanks both of you I understand perfectly now, big numbers though! I think I was just a little put off by all that complex-looking formula.
  6. Gödelization - help needed.

    Formula: [code] n x?i x?1 x?2 x?n ? p = p p ... p i=1 i 1 2 n[/code] [size="2"][i]Where: n = the nth number in a sequence x = a number in the sequence p = a prime number[/i][/size] G[font="arial, sans-serif"][size="2"][i]ö[/i][/size][/font]delization (as far as I understand) states that if you pick any natural number (x) then there is exactly one sequence of prime numbers (p) whose product (of (n) prime numbers) = x. If there are (n) numbers in the sequence, let every number be denoted by (x?1 x?2 ... x?n). [b]I am having trouble fully grasping this and I think it would help if someone could give me an example calculation using this formula. [/b][b] [/b]
  7. [url="http://lmgtfy.com/?q=math+formula+and+its+theory+behind+it"]Try this?[/url]
  8. Tiny maths question.

    Okay so user has 10 points that he / she is allowed to distribute between three factors: a, b and c. As such, the user may choose to put 10 in a but none in b or c (or any other combination). I need an efficient sum of some sort, that will differentiate all possible combinations, due to the sum resulting in different values. Thanks in advance
  9. Thesis In Physics

    I am currently researching chaos and evolutionary computation, which i find very interesting. If you do too check out [url="http://www.amazon.co.uk/Computational-Beauty-Nature-Explorations-Adaptation/dp/0262561271/ref=sr_1_13?s=books&ie=UTF8&qid=1305133925&sr=1-13"]this book[/url].
  10. [quote name='owl' timestamp='1304985682' post='4808774'] To keep the calculations simple, say that a traveler had a spaceship that could instantly accelerate to 1/2 of light speed (without killing him) and he started a journey to a point in space 10 light years away to finally instantly decelerate at the moment of arrival. How many time would it pass from the point point of view of the traveler inside the spaceship? Intuitive thinking may make one think it'd be 20 years but I know relativistic speeds don't work that way. What would be the equations to calculate that "t"? [/quote] Correct me if I'm wrong, but I'm pretty sure that for the the guy in the spaceship it would be twenty years. However, see [url="http://www.youtube.com/watch?v=HHRK6ojWdtU&feature=related"]this[/url] video for a simple explanation of time dilation. Skip to about 6:40 to avoid the junk. Hope this helps! Also a book called 'The Elegant Universe' explains this and many other related issues very well.
  11. Need SFML 2 binaries (xxx.a and xxx.dll's)

    [quote name='monchito' timestamp='1304939336' post='4808480'] Hi I'm using Code::Blocks 10.05 & MinGW I need the compiled SMFL 2 library. Can anyone post it somewhere to get it? Really, I tried to Cmake it without success. Followed some tutorials from internet and get a group of folders 'CMakeFiles', an empty 'lib' folder , a 'src" and subfolders 'SFML'( Audio, Graphics,Main,Network,System,Window,CMakeFiles) each with more subfolders and cmake files. How can I get the libxxxxx.a and the XXXXX.dll's Thanks in advance [/quote] Just type it into youtube with the word 'tutorial' thrown in. Or you could try interpreting the steps for SDL stated on [url="http://lazyfoo.net/SDL_tutorials/lesson01/index.php"]this[/url] website.
  12. Idea for game

    The best option for you is to take a course at uni in English literature or business ( depending on which you prefer) and work as a designer/marketeer at a game development company, then work your way into a design position at a company.
  13. Computer Science, The Ivy League and The UK.

    [quote name='Tom Sloper' timestamp='1303741082' post='4802662'] [quote name='Reuben'] 1. Well, Art I still do enjoy and I am fairly good at... I like to write stories and such, ... would skills in these sort of areas be something that would put me at an advantage 2. or would they be completely superfluous[/b], thus should I spend less time focusing on them and more on learning libraries like SDL? ... 3. The American system (particularly with Ivy League colleges) seems to put a huge [b]emphasis on not only academic ability but extra curricular activity[/b]. [b]Would making programs and games using C++ and SDL be sufficient [/b]for this 4. or should I fly to Africa every friday and build shelters/take steroids and become a 6'11 world class basketballer? 5. Also, how much does it cost per college application 6. are the subjects I've chosen at A level appropriate[/b], 7. or should I switch one(or some or all) of them to something different? Or, am I aiming too high and should I instead go to my local college and seek out a part time intern-ship at Starbucks? [/quote] 1. Questions about what "would" put you at an advantage are superfluous! You should pursue stuff you enjoy doing, simply because you enjoy them. 2. Do not give up your passions and take up pastimes you don't enjoy, and don't try to avoid learning anything. 3. Questions about what's "sufficient" are superfluous! Read this forum's FAQs (section on bad questions) and see the FAQ on the bad question "is it enough?" 4. Stop being silly. Ask not what your passions should be, and accept that they are what they are. Your passions are what you are, what you enjoy, what you should do. 5. You'll have to ask that of the schools you apply to. 6. Another bad question (actually, the same one yet again). Pursue your interests and stop worrying. You are unique -- stop asking to get cookie-cuttered. 7. See the FAQ, there's an FAQ on how to make decisions. [/quote] 1. I guess using the word 'advantage' was poor phrasing, I point I was trying to convey was more - would my non-programming skills be useful in a AI programming position at a large studio, or only relevant in, perhaps, a small indie team. 2. I wasn't considering giving up anything and I didn't mention anything I don't enjoy, I was simply saying that if, hypothetically, I enjoyed learning SDL, art and writing in equal amounts, however I have been practising writing and drawing since I was 5 however I have never been formally taught C++ in my life, surely I should prioritise increasing my skills in C++ when considering a Computer science degree. 3. Okay, I guess my phrasing was bad again. I was looking more for insight on the sorts of extra curricular activities the US system seek out. I'd have thought that making a game single handedly (displaying aptitude in multiple disciplines) would be the perfect way to express where my talent lies, or maybe I underestimated the calibre of student these sort of Universities expect (hence question 4.). A one size fits all FAQ doesn't really give me any insight into whether this would be an appropriate approach for an application in a system that I (due to location) have not been versed in, not minimal and solitary as is suggested by the title 'is it enough?'. 5. Yeah, true that was a pretty lazy question. 6. Looking for insight and experiences of people who have experienced something you hope to is not (in my book) a bad question. I was asking if my choices were well-suited for reaching my goal. Although the interest pursuing philosophy is nice, sometimes you have to close one door in order to open another. I'm not asking to be cookie-cuttered, I'm a lump of cookie mixture trying to arrange myself in a way that means that when the giant cookie-cutter of the education system and society comes down on me, I become the best cookie my unique mixture can make. 7. Thank you, It seems like a good way to break down a decision you are struggling with into undeniable logic. Thanks for both of your replies by the way, any sort of feedback is useful.[img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]
  14. Knowing more techniques is far inferior to being able to successfully utilise a few techniques. As for joining a development team, you won't be hired unless you have a degree and/or good examples of work you have done as part of a indie group or on your own.
  15. Natural logarithms, exponential growth and C++

    [quote name='mozie' timestamp='1303745243' post='4802682'] Your form is close. I added the exponential growth formula to your code, its the one that prints 2nd. Notice the difference when you input something like 500 years (and then work each formula with that t value to see why its different) [quote] Enter year increment: 500 12106 12182 [/quote] Your form does something like this (using the provided values in your code) 1.005 to the power of t (number of years) multiplied by the initial population equals the new population. The exponential form does the following. Initial population multiplied by: 'e' to the power of (0.005 * t) equals the new population. I think your form is more intuitive, but since everything else uses newPop=initPop*e^(rate*time), I suggest that you use that. The 0.005 is your 'k' value above. It represents a percent as a decimal, that is 1% is the number 0.01. Your (birth-death)/initpop results in (24-19)/1000 = 0.005 so this is your k value, a population increase of 0.5% per year (t). Google up "Exponential Growth" to see more detail about it. This formula is used often enough that it is pretty handy to have memorized and understood. [code] int main(void) { double initpop=1000; double births=24; double deaths=19; double birthdeathrate=(births-deaths)/initpop+1; unsigned int population; int t; cout << "Enter year increment: "; cin >> t; population = initpop*(pow(birthdeathrate,t)); cout << population << endl; population = initpop*exp( (births-deaths)/initpop * t ); cout << population << endl; return 0; } [/code] Hope this helps! [/quote] Thank you, this was the exact explanation I was hoping to receive. Perfectly explained, helpful and accurate. And thanks for elaborating on the rearranging of the formula, it helped me understand better and should come in handy when completing this program. +rep [img]http://public.gamedev.net/public/style_emoticons/default/biggrin.gif[/img]