Gen. Rand. numb.s

This is a discussion on Gen. Rand. numb.s within the C++ Programming forums, part of the General Programming Boards category; Yeah, but, the way I see it, my code is perfectly legit. What is causing it to screw up like ...

  1. #31
    Registered User
    Join Date
    Jun 2005
    Posts
    22
    Yeah, but, the way I see it, my code is perfectly legit. What is causing it to screw up like this? My code works fine but still it is screwed up, sometime i should definititly be able to hit my enemy, and vice-versa. Why did it work before I changed the random number generator inside?

    ANYONE who can see my mistake would be increidibly kind to correct me.

    Thanks,
    David
    If at first you don't succeed,
    Skydiving is not for you.

  2. #32
    Registered User
    Join Date
    Dec 2004
    Posts
    32
    Quote Originally Posted by Dkunsberg
    Yeah, but, the way I see it, my code is perfectly legit.
    Yes, but it is probably not your intention?

    Quote Originally Posted by Dkunsberg
    What is causing it to screw up like this? My code works fine but still it is screwed up, sometime i should definititly be able to hit my enemy, and vice-versa. Why did it work before I changed the random number generator inside?
    The previous post has your answer. If not at least something worth pursuing and fixing.

    Quote Originally Posted by Dkunsberg
    ANYONE who can see my mistake would be increidibly kind to correct me.

    Thanks,
    David
    Ok add this to main just before your call to fight,
    Code:
    	cout << "\n\nIn main!!\n" 
    		<< "btd = " << btd 
    		<< "\nestrike = "<< estrike 
    		<< "\nenemytd = " << enemytd
    		<<  "\ntdr = " << tdr
    		<< "\ntdl = " << tdl
    		<< "\ntdh = " << tdh
    		<< "\nenemyhp = " << enemyhp
    		<< "\nhp = " << hp
    		<< "\nattack = " << attack
    		<< "\nac = " << ac
    		<< "\nenemyattack = " << enemyattack
    		<< "\nenemyac = "<< enemyac
    		<< "\nenemydmg = " << enemydmg
    		<<  "\ndmg = " << dmg
    		<< "\nstrike = " << strike << endl;
    	Fight ( btd, estrike, enemytd, tdr,  tdl, tdh, enemyhp, hp, attack, ac, enemyattack, enemyac, enemydmg , dmg, strike);
    Now add this to your function fight,
    Code:
    void Fight (int estrike, int btd, int enemyhp,int hp,int attack,int ac,int enemyattack, int enemyac, int enemydmg, int dmg, int strike, int tdr,  int tdl,  int tdh, int enemytd)
    {
    	cout << "\n\nIn Fight!!\n" 
    		<< "btd = " << btd 
    		<< "\nestrike = "<< estrike 
    		<< "\nenemytd = " << enemytd
    		<<  "\ntdr = " << tdr
    		<< "\ntdl = " << tdl
    		<< "\ntdh = " << tdh
    		<< "\nenemyhp = " << enemyhp
    		<< "\nhp = " << hp
    		<< "\nattack = " << attack
    		<< "\nac = " << ac
    		<< "\nenemyattack = " << enemyattack
    		<< "\nenemyac = "<< enemyac
    		<< "\nenemydmg = " << enemydmg
    		<<  "\ndmg = " << dmg
    		<< "\nstrike = " << strike << endl;
    	cout << "You engage in a fight against the enemy!\n";
    They should have the same output. Do they? If not this might be your problem.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random number gen & looping probelm :?
    By FoxeySoulSLayer in forum C++ Programming
    Replies: 1
    Last Post: 04-10-2009, 06:44 PM
  2. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 10:56 AM
  3. 1337 bible, Gen 11
    By Paz_Rax in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 05-20-2005, 10:40 PM
  4. mission notimpossible (maze gen)
    By datainjector in forum C Programming
    Replies: 6
    Last Post: 11-22-2002, 05:51 PM
  5. What next Gen system you own now?
    By Golden Bunny in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 04-11-2002, 10:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21