FearMe Posted April 19, 2014 Posted April 19, 2014 thx!!! void combat (vector<double>& health, double oaccuracy, double obase_damage) { for (int j = 1; j < health.size (); j++) { for (int k = 1; k < obase_damage; k++) { if (j - k >= 0) health [j - k] += oaccuracy * health [j] / obase_damage; else health [0] += oaccuracy * health [j] / obase_damage; } health [j] *= 1 - oaccuracy; health [j] += oaccuracy * health [j] / obase_damage; } } void statistics (double& p, double& win, double& loss, vector<double> health, vector<double> ohealth) { double temp = 1 - (1 - health [0]) * (1 - ohealth [0]); temp -= p; if (health [0] > 0 || ohealth [0] > 0) { win += temp * (ohealth [0] / (ohealth [0] + health [0])); loss += temp * (health [0] / (ohealth [0] + health [0])); } p += temp; } void create_health (vector<double>& health, double constitution) { for (int i = 0; i < constitution * 10; i++) health.push_back (0); health [health.size () - 1] = 1; } int main() { cout << "Enter both players' stats to calculate chances of winning." << endl << endl; double attack; // Your Attack level double strength; // Your Strength level double defence; // Your Defence level double constitution; // Your Constitution level double oattack; // Opponent's Attack level double ostrength; // Opponent's Strength level double odefence; // Opponent's Defence level double oconstitution; // Opponent's Constitution level cout << "Attack: "; cin >> attack; // Your Attack level cout << "Strength: "; cin >> strength; // Your Strength level cout << "Defence: "; cin >> defence; // Your Defence level cout << "Constitution: "; cin >> constitution; // Your Constitution level cout << endl; cout << "Opponent's Attack: "; cin >> oattack; // Opponent's Attack level cout << "Opponent's Strength: "; cin >> ostrength; // Opponent's Strength level cout << "Opponent's Defence: "; cin >> odefence; // Opponent's Defence level cout << "Opponent's Constitution: "; cin >> oconstitution; // Opponent's Constitution level cout << endl; double effective_attack = 10 * (attack + 8 + 3); // 5/8 from standard formula, 3 from style bonus double effective_strength = strength + 8; // ,, double base_damage = effective_strength + 5; // ,, double effective_defence = 10 * (defence + 8); // ,, double oeffective_attack = 10 * (oattack + 8 + 3); // ,, double oeffective_strength = ostrength + 8; // ,, double obase_damage = oeffective_strength + 5; // ,, double oeffective_defence = 10 * (odefence + 8); // ,, double accuracy; double oaccuracy; if (attack < odefence) accuracy = (effective_attack - 1) / (2 * oeffective_defence); else accuracy = 1 - (oeffective_defence + 1) / (2 * effective_attack); if (oattack < defence) oaccuracy = (oeffective_attack - 1) / (2 * effective_defence); else oaccuracy = 1 - (effective_defence + 1) / (2 * oeffective_attack); cout << "Your accuracy: " << accuracy << endl; cout << "Opponent's accuracy: " << oaccuracy << endl; cout << endl; vector<double> health; vector<double> ohealth; create_health (health, constitution); create_health (ohealth, oconstitution); double p = 0; double win = 0; double loss = 0; for (int hit = 0; win + loss < 0.99 && hit < 1000; hit++) { combat (health, oaccuracy, obase_damage); combat (ohealth, accuracy, base_damage); statistics (p, win, loss, health, ohealth); } cout << "Your win chance: " << win << endl; cout << "Opponent's win chance: " << loss << endl; return 0; }
Alek Posted April 19, 2014 Posted April 19, 2014 I don't see what the problem is with converting it, should take you less than 10 minutes? 1
FearMe Posted April 19, 2014 Author Posted April 19, 2014 (edited) I don't see what the problem is with converting it, should take you less than 10 minutes? I don't know anything about c++ though, stuff like this <<'s just confuse me at this point.. Prove yourself and convert it in less than 10 minutes? Edited April 19, 2014 by FearMe
Swizzbeat Posted April 19, 2014 Posted April 19, 2014 >> and << operators I'm assuming just wait/put out data. Obviously it's just printing out text and then waiting for input to store in a variable.
PolishCivil Posted April 19, 2014 Posted April 19, 2014 LOL... Xavier sent me this too a while ago. What a noob cant translate it?
FearMe Posted April 19, 2014 Author Posted April 19, 2014 >> and << operators I'm assuming just wait/put out data. Obviously it's just printing out text and then waiting for input to store in a variable. Ah nvm, I get it now. I thought endl was a variable(didn't look for it at all, just assumed), it turns out it means end line... I think I can convert it myself now. >_>
FearMe Posted April 19, 2014 Author Posted April 19, 2014 LOL... Xavier sent me this too a while ago. What a noob cant translate it? hey wanna help me i got it converted but it returns 0% win chance no matter what.. :<
Hysteria Posted April 19, 2014 Posted April 19, 2014 >> and << operators I'm assuming just wait/put out data. Obviously it's just printing out text and then waiting for input to store in a variable. ^^this std::cout << "kjhkjhkj" << std::endl; //will output whatever follows the "<<" sign on the console/terminal std::cin >> variable; // will take an input and place it in some variable. btw keep your main function as clean as possible ;)