Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <stdlib.h>
- #include <cstring>
- using namespace std;
- struct move{
- string name;
- int id;
- int effect;
- int defense;
- int wait;
- int special;
- };
- int attempts = 0; //total attempts: 1073741824
- int Phealth = 75;
- int Pwait = 0;
- int Bhealth = 140;
- int Bwait = 0;
- int bestHealth = 140;
- int Bmove = 1;
- string bestStrat = "";
- int battleIndex = 0;
- move strategy[10];
- move movelist[12]; //First 8 are yours, last 4 are boss.
- void initializeMoves();
- void setMove(string a, int b, int c, int d, int e, int f);
- void resetBattle();
- void arrayToString();
- void bossAttack();
- int main(){
- initializeMoves();
- while(attempts < 1073741824 && bestHealth > 0){
- //define strategy array based on attempts
- strategy[0] = movelist[attempts % 8];
- strategy[1] = movelist[(attempts / 8) % 8];
- strategy[2] = movelist[(attempts / 64) % 8];
- strategy[3] = movelist[(attempts / 512) % 8];
- strategy[4] = movelist[(attempts / 4096) % 8];
- strategy[5] = movelist[(attempts / 32768) % 8];
- strategy[6] = movelist[(attempts / 262144) % 8];
- strategy[7] = movelist[(attempts / 2097152) % 8];
- strategy[8] = movelist[(attempts / 16777216) % 8];
- strategy[9] = movelist[(attempts / 134217728) % 8];
- battleIndex = 0;
- resetBattle();
- while(Phealth > 0 && Bhealth > 0 && Bhealth <= 140 && battleIndex < 10){
- //fight loop goes here
- if(Pwait == 0){
- //player attack
- if(strategy[battleIndex].special==0){
- Bhealth -= (strategy[battleIndex].effect - movelist[(Bmove+7)].defense);
- }
- if(strategy[battleIndex].special==1){
- Phealth += strategy[battleIndex].effect;
- }
- if(strategy[battleIndex].special==2){
- Bhealth -= (strategy[battleIndex].effect);
- }
- battleIndex++;
- Pwait = strategy[battleIndex%10].wait;
- }
- if(Bwait == 0){
- bossAttack();
- }
- Pwait--;
- Bwait--;
- }
- if(Bhealth < 140){
- if(Bhealth < bestHealth){
- bestHealth = Bhealth;
- arrayToString();
- cout << "New Best: " << bestStrat << endl;
- cout << bestHealth << endl;
- bestStrat = "";
- }
- }
- // if(attempts % 5000000 == 0){
- // cout << "Attempts: " << attempts << endl;
- // }
- attempts++;
- }
- cout << "Best fight: " << bestStrat << endl;
- cout << bestHealth << endl;
- }
- void initializeMoves(){
- setMove("Longbow", 1, 11, 4, 5, 0);
- setMove("Crossbow", 2, 16, 2, 6, 0);
- setMove("Wing Guard", 3, 0, 18, 6, 0);
- setMove("Wooden Shield", 4, 0, 20, 8, 0);
- setMove("Mythril Sword", 5, 20, 13, 8, 0);
- setMove("Broadsword", 6, 23, 18, 14, 0);
- setMove("Heal", 7, 25, 2, 15, 1);
- setMove("Thunder", 8, 35, 2, 20, 2);
- setMove("Shock+1", 9, 20, 4, 10, 0);
- setMove("Shock+2", 10, 22, 6, 5, 0);
- setMove("Shock+3", 11, 24, 8, 5, 0);
- setMove("Drain", 12, 35, 0, 17, 3);
- }
- //a is the attack name. b is the id of the move. c, d and e are effect, defense and wait.
- //f is any special properties: 0 = none, 1 = Heal, 2 = Piercing, 3 = both.
- //Stun is unimplemented and instead shortcutted by shortening the wait of the next move, given the fixed attack pattern.
- void setMove(string a, int b, int c, int d, int e, int f){
- movelist[b-1].name = a;
- movelist[b-1].id = b;
- movelist[b-1].effect = c;
- movelist[b-1].defense = d;
- movelist[b-1].wait = e;
- movelist[b-1].special = f;
- }
- void resetBattle(){
- Phealth = 75;
- Pwait = strategy[battleIndex].wait;
- Bhealth = 140;
- Bwait = 10;
- Bmove = 1;
- }
- void arrayToString(){
- for(int i=0;i<10;i++){
- bestStrat.append(strategy[i].name);
- bestStrat.append(" | ");
- }
- }
- void bossAttack(){
- if(movelist[(Bmove+7)].special == 0){
- Phealth -= (movelist[(Bmove+7)].effect - strategy[battleIndex].defense);
- }
- if(movelist[(Bmove+7)].special == 3){
- Phealth -= (movelist[(Bmove+7)].effect);
- Bhealth += (movelist[(Bmove+7)].effect);
- }
- Bmove++;
- if(Bmove == 5){
- Bmove = 1;
- }
- Bwait = movelist[(Bmove+7)].wait;
- }
- OUTPUT BELOW
- New Best: Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 120
- New Best: Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 111
- New Best: Thunder | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 107
- New Best: Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 106
- New Best: Thunder | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 102
- New Best: Mythril Sword | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 89
- New Best: Broadsword | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 86
- New Best: Mythril Sword | Broadsword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 84
- New Best: Mythril Sword | Crossbow | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 82
- New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 81
- New Best: Mythril Sword | Broadsword | Crossbow | Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 80
- New Best: Broadsword | Mythril Sword | Mythril Sword | Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 78
- New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow |
- 76
- New Best: Mythril Sword | Broadsword | Thunder | Mythril Sword | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow |
- 69
- New Best: Mythril Sword | Broadsword | Thunder | Mythril Sword | Mythril Sword | Crossbow | Longbow | Longbow | Longbow | Longbow |
- 64
- New Best: Broadsword | Broadsword | Mythril Sword | Crossbow | Longbow | Wing Guard | Longbow | Longbow | Longbow | Longbow |
- 60
- New Best: Mythril Sword | Broadsword | Broadsword | Crossbow | Longbow | Wing Guard | Longbow | Longbow | Longbow | Longbow |
- 58
- New Best: Mythril Sword | Broadsword | Crossbow | Longbow | Broadsword | Wing Guard | Longbow | Longbow | Longbow | Longbow |
- 54
- New Best: Crossbow | Mythril Sword | Mythril Sword | Mythril Sword | Heal | Mythril Sword | Longbow | Longbow | Longbow | Longbow |
- 53
- New Best: Mythril Sword | Broadsword | Crossbow | Crossbow | Longbow | Broadsword | Longbow | Longbow | Longbow | Longbow |
- 38
- New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Mythril Sword | Mythril Sword | Wing Guard | Longbow | Longbow | Longbow |
- 37
- New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Crossbow | Mythril Sword | Mythril Sword | Longbow | Longbow | Longbow |
- 21
- New Best: Crossbow | Mythril Sword | Mythril Sword | Crossbow | Crossbow | Crossbow | Crossbow | Broadsword | Mythril Sword | Longbow |
- 19
- New Best: Crossbow | Mythril Sword | Mythril Sword | Crossbow | Crossbow | Crossbow | Crossbow | Broadsword | Crossbow | Crossbow |
- 18
- Best fight:
- 18
- --------------------------------
- Process exited after 767.5 seconds with return value 0
- Press any key to continue . . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement