diff --git a/AlgorithmAuthenticate.cpp b/AlgorithmAuthenticate.cpp new file mode 100644 index 0000000..6af7f5c --- /dev/null +++ b/AlgorithmAuthenticate.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +using namespace std; + +int main() +{ + int T[1001] = {0}; + for(int i = 0;i < 1000000;i ++) + { + // int r = (int)(rand()*100)/RAND_MAX; + int r = rand(); + for(;r >= 30000;)r = rand(); + r %= 100; + T[r] ++; + } + for(int i = 0;i < 101;i ++) + { + cout << T[i] << endl; + } + cout << RAND_MAX << endl; + system("pause"); + +} diff --git a/GachaSimulationRec.h b/GachaSimulationRec.h new file mode 100644 index 0000000..bc0ee22 --- /dev/null +++ b/GachaSimulationRec.h @@ -0,0 +1,29 @@ +#include +#include + +class GachaSimulationRec{//记录及统计 + +public: + void AddData(GachaFallBack FallBack) + { + + } + + void output() + { + + } + +}; + +class GachaTatic{//方案 + + +public: + + PlayerData TaticFallBack(PlayerData privData) + { + + } + +}; diff --git a/GachaSystem.h b/GachaSystem.h new file mode 100644 index 0000000..26e7dfd --- /dev/null +++ b/GachaSystem.h @@ -0,0 +1,409 @@ +//#include +#include +#include +#include +#include +#include +using namespace std; + +class Item{ +public: + Item() + { + ID = 0; + name = ''; + rarity = 0; + itemType = 0; + ifPity = 0; + } + + Item(string nameInput,int IDInput,int rarityTnput,int itemTypeInput,int ifPityInput) + { + ID = IDInput; + name = nameInput; + rarity = rarityTnput; + itemType = itemTypeInput; + ifPity = ifPityInput; + } + + operator!=(Item b) + { + return (ID == b.ID); + } + +public: + int ID; //Produced UUID + string name; //Name + int rarity; //rarity 4/5 + int itemType; //Characters or Arms 1-Characters 2-Arms + int ifPity; //ifUP 1-UP 2-Permanent +}; + +class ItemList{ +private: + vector> ItemListData; + +public: +/* + * Item List + * ID marker + * 4 rarity Character Up :1 + * 4 rarity Arm Up :2 + * 5 rarity Character Up :3 + * 5 rarity Arm Up :4 + * 4 rarity Character Permanent :5 + * 4 rarity arm Permanent :6 + * 5 rarity Character Permanent :7 + * 5 rarity Arm Permanent :7 + */ + + Item itemFilter(int ID) + { + int Classify = ID/100; + switch (Classify) + { + case 411: + return ItemListData[1][ID%100]; + break; + case 421: + return ItemListData[2][ID%100]; + break; + case 511: + return ItemListData[3][ID%100]; + break; + case 521: + return ItemListData[4][ID%100]; + break; + case 412: + return ItemListData[6][ID%100]; + break; + case 422: + return ItemListData[7][ID%100]; + break; + case 512: + return ItemListData[8][ID%100]; + break; + case 522: + return ItemListData[9][ID%100]; + break; + + default: return Item(); + break; + } + } + + Item itemFilter(string name) + { + for (int i = 0; i < ItemListData.size(); i++) + { + for(int j = 0;j < ItemListData[i].size(); j ++) + { + if(ItemListData[i][j].name == name) return ItemListData[i][j]; + } + } + } + + vector itemFilter(int rarity,int itemType,int Permanents) + { + + int Classify = 100*rarity + 10*itemType + Permanents; + switch (Classify) + { + case 411: + return ItemListData[1]; + break; + case 421: + return ItemListData[2]; + break; + case 511: + return ItemListData[3]; + break; + case 521: + return ItemListData[4]; + break; + case 412: + return ItemListData[6]; + break; + case 422: + return ItemListData[7]; + break; + case 512: + return ItemListData[8]; + break; + case 522: + return ItemListData[9]; + break; + + default: return ; + break; + } + } + + void AddItem(string name,int rarity,int itemType,int Permanents) + { + int Classify = 100*rarity + 10*itemType + Permanents; + switch (Classify) + { + case 411: + return ItemListData[1].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + case 421: + return ItemListData[2].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + case 511: + return ItemListData[3].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + case 521: + return ItemListData[4].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + case 412: + return ItemListData[6].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + case 422: + return ItemListData[7].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + case 512: + return ItemListData[8].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + case 522: + return ItemListData[9].push_back(Item(name,Classify*100+ItemListData[1].size(),rarity,itemType,Permanents)); + break; + + default: return ; + break; + } + } + + bool operator==(ItemList b) + { + if(ItemListData.size() == b.ItemListData.size()) + { + for(int i = 0;i < ItemListData.size();i ++) + { + if(ItemListData[i].size() == b.ItemListData[i].size()) + { + for(int j = 0;j < ItemListData[i].size) + { + if(ItemListData[i][j] != b.ItemListData[i][j]) return false; + } + } else return false; + } + } else return false; + return true; + } + + void overWrite(ItemList NewData) + { + ItemListData = NewData.ItemListData; + } + +}; + +class PlayerData{ +public: + int WaterLevel5 = 0; //目前水位5 + int WaterLevel4 = 0; //目前水位4 + int paneleValue = 0; //命定值 + int bannerValue = 0; //当前卡池 11 12 21 22 + + ItemList Package, + Target; + +public: + PlayerData(ItemList TargetInput) + { + + } + + void UpdateData(GachaFallBack FallBack)//根据记录刷新玩家信息 + { + + } + + void UpdateData(PlayerData newData) //手动刷新玩家信息 + { + + } + + bool EndSitiuationJudge() + { + return Package.compare(Target); + } + +}; + +class GachaBannerData{ +public: + ItemList BannerItem; + int ID; //1n 2n: + //Arm :up1 2/5 up2 2/5 other 1/5 + +public: + GachaBannerData(ItemList initialization,int IDit) + { + BannerItem.overWrite(initialization); + ID=IDit; + } + + + int getCharacter5Percent(int waterLevel) + { + double P; + if (waterLevel < 74) P = 0.006; + else if (waterLevel < 90) P = ((waterLevel-73)*0.06 + 0.006); + else P=1 + return (int)(1000*P); + } + + int getArm5Percent(int waterLevel) + { + double P; + if (waterLevel < 64) P = 0.006; + else if (waterLevel < 80) P = ((waterLevel-63)*0.06 + 0.006); + else P = 1; + return (int)(1000*P); + } + + int getCharacter4Percent(int waterLevel) + { + double P; + if (waterLevel < 64) P = 0.006; + else if (waterLevel < 80) P = ((waterLevel-63)*0.06 + 0.006); + else P = 1; + return (int)(1000*P); + } + + int getArm4Percent(int waterLevel) + { + double P; + if (waterLevel < 64) P = 0.006; + else if (waterLevel < 80) P = ((waterLevel-63)*0.06 + 0.006); + else P = 1; + return (int)(1000*P); + } + + int get5Percent(int waterLevel) + { + switch (ID/10) + { + case 1:{ + double P; + if (waterLevel < 74) P = 0.006; + else if (waterLevel < 90) P = ((waterLevel-73)*0.06 + 0.006); + else P=1 + return (int)(1000*P); + } + break; + case 2:{ + double P; + if (waterLevel < 64) P = 0.006; + else if (waterLevel < 80) P = ((waterLevel-63)*0.06 + 0.006); + else P = 1; + return (int)(1000*P); + } + break; + + default: + return -1 + break; + } + } + + int get4Percent(int waterLevel)//▲概率调整未完成// + { + switch (ID/10) + { + case 1:{ + double P; + if (waterLevel < 74) P = 0.006; + else if (waterLevel < 90) P = ((waterLevel-73)*0.06 + 0.006); + else P=1 + return (int)(1000*P); + } + break; + case 2:{ + double P; + if (waterLevel < 64) P = 0.006; + else if (waterLevel < 80) P = ((waterLevel-63)*0.06 + 0.006); + else P = 1; + return (int)(1000*P); + } + break; + + default: + return -1 + break; + } + } + + int getPaneleNeed() + { + return ID%10; + } + + void UpdateBanner(ItemList NewItemList) + { + BannerItem.overWrite(NewItemList); + } + +}; + +class GachaFallBack{ +public: + GachaFallBack(PlayerData thisPlayerData,GachaBannerData thisBannerData,Item thisFallBack) + { + prvPlayerData = thisPlayerData; + BannerData = thisBannerData; + FallBackItem = thisFallBack; + } + + PlayerData prvPlayerData; + GachaBannerData BannerData; + Item FallBackItem; +}; + +class GachaSystem{ +private: + int FullRand(int randMax) + { + srand(time(114514)); + int rTmp = rand(); + int MaxModValue = 32767 - 32767 % randMax; + for(;rTmp >= MaxModValue;) r = rand(); + return rTmp % randMax; + } + + Item ListRand(vector sorce) + { + int randAns = FullRand(sorce.size()); + return sorce[randAns]; + } + + int PersentRand(int P,int MAXp) + { + if(p < FullRand(MAXp)) return true; + else return false; + } + +public: + // GachaSystem(GachaBannerData InitializationData)//初始化抽卡系统 + // { + // bannerData = InitializationData; + // } + + GachaFallBack doGacha(PlayerData thisPlayerData,GachaBannerData BannerData)//抽卡核心 + { + if(PersentRand(BannerData.get5Percent(thisPlayerData.WaterLevel5),1000)) + { + if(thisPlayerData.paneleValue >= BannerData.getPaneleNeed()) + return GachaFallBack(thisPlayerData,BannerData,BannerData.BannerItem.itemFilter(51100+BannerData.ID%10)); + else if(PersentRand(1,2)) + return GachaFallBack(thisPlayerData,BannerData,BannerData.BannerItem.itemFilter(51100+BannerData.ID%10)); + else return ; + }else if(PersentRand(BannerData.get4Percent(thisPlayerData.WaterLevel4),1000)) + { + + } + } + +}; diff --git a/OutputFile/AlgorithmReconstitution.exe b/OutputFile/AlgorithmReconstitution.exe new file mode 100644 index 0000000..e9fda65 Binary files /dev/null and b/OutputFile/AlgorithmReconstitution.exe differ diff --git a/OutputFile/QIYUANroleTest.exe b/OutputFile/QIYUANroleTest.exe new file mode 100644 index 0000000..12ac07e Binary files /dev/null and b/OutputFile/QIYUANroleTest.exe differ diff --git a/QIYUANroleTest.cpp b/QIYUANroleTest.cpp new file mode 100644 index 0000000..c9433c5 --- /dev/null +++ b/QIYUANroleTest.cpp @@ -0,0 +1,154 @@ +#include +#include +#include +#include + +using namespace std; + +double GET_P(int index)//ڻȡĿǰ +{ + if (index < 64) return 0.006; + if (index < 80) return ((index-63)*0.06 + 0.006); + return 1; +} + +int QR_rand(double p)//ij鿨㷨 +{ + int r; + //r = (int)(rand()*1000)/RAND_MAX; + + int tmp;//ʷм + tmp = (int)(1000*p) / 2; + r = rand(); + for(;r >= 30000;)r = rand(); + r %= 1000; //0-999 + + if (r < tmp) return 1; // + if (r < 2 * tmp) return 2; // + return 0; //û + +} + +int main() +{ + int PER_TEST[200], //¼ÿԸģ + TEST_REC[200], //¼ģͳUPɫ + SUM_REC = 0, //¼UPɫ + TEST_T_REC[200],//¼ģͳнɫ + SUM_T_REC = 0, //¼нɫ + TOTL_TIMES = 0, //¼ģ + RAND_TMP = 0; //м + int FEI; //ֵ + double P; //ʵʱ + srand(114514); + + //ʵʱ + cout << "n ʣ%" << endl; + for (int i = 1;i <= 80;i ++) + { + cout << i << " " << (int)(1000*GET_P(i))<< endl; + } + + //ݳʼ + for (int i = 0;i < 240;i ++) + { + PER_TEST[i] = 0; + TEST_REC[i] = 0; + TEST_T_REC[i] = 0; + } + + //ʽģ + cout << "ģ(0С2^31)" << endl; + cin >> TOTL_TIMES; + + system("cls"); + cout << "CACULATING" << endl; + + for (int i = 0;i < TOTL_TIMES;i ++) + { + if(TOTL_TIMES>=1650) if(!(i % (TOTL_TIMES/1650))) UpdatePrc(TOTL_TIMES,i,40); + FEI = false;//С + for (int j = 1 , r = 1; j <= 180;j ++)//һֳ鿨ģ + { + //rʣԱ֤Сø + P = GET_P(r);//ʵʱ + int RES = 0;//жм + RES = QR_rand(P);//ȡж + if (RES == 1) {// + SUM_REC ++; + SUM_T_REC ++; + TEST_REC[j] ++; + TEST_T_REC[r] ++; + break; + } + if ((RES == 2) && (FEI == true)) {//󱣵׻ + SUM_REC ++; + SUM_T_REC ++; + TEST_REC[j] ++; + TEST_T_REC[r] ++; + break; + } + if (RES == 2) {//ˣ + SUM_T_REC ++; + TEST_T_REC[r] ++; + FEI = true;//󱣵 + r = 1; + continue; + } + r ++; + } + } + + double T_EXPT = 0,// + EXPT = 0; //UPɫ + unsigned long long CACU_TMP = 0;//ʽתм + + for (int i = 0;i < 180;i ++) + { + CACU_TMP += TEST_REC[i] * i; + } + + EXPT = (double)CACU_TMP / (double)SUM_REC; + + CACU_TMP = 0; + + for (int i = 0;i < 180;i ++) + { + CACU_TMP += TEST_T_REC[i] * i; + } + + T_EXPT = (double)CACU_TMP / (double)SUM_T_REC; + + system("cls"); + + cout << "UP:" << EXPT << endl; + cout << ":" << T_EXPT << endl; + cout << "UPɫռܳ " << (double)SUM_REC / (double)SUM_T_REC * 100 << " %" << endl; + cout << "---------------------" << endl; + + int dif_Step = 0;//ݶͼÿֵ + dif_Step =(int)( FindMax(&TEST_REC[0],180) / 32); + + + + cout << "ݶͼ" << endl; + cout << "ÿһ" << dif_Step << endl; + + for (int i = 0;i < 90;i ++) + { + cout << i << " - "; + int Wed = 0; + int Tmp_R = TEST_REC[i]; + for (;((Tmp_R / dif_Step)) && (Tmp_R > 0);Wed ++) + { + cout << ""; + Tmp_R -= dif_Step; + } + for (;Wed < 40;Wed++) cout << " "; + cout << TEST_REC[i]; + cout << endl; + } + + system("pause"); + return 0; +} \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..002ff9f --- /dev/null +++ b/main.cpp @@ -0,0 +1,140 @@ +#include +#include +#include +#include +using namespace std; + +/* + for(int i = 0;i < totalSimulationAmount;i ++) + { + for(;;) + { + GachaFallBack fallBackOnce = thisGachaSystem.doGacha(simPlayerData); + // do Gacha and get fallback + simPlayerData.updateData(fallBackOnce); + // refresh player data + for(int j = 0;j < totalTaticAmount;j ++) + { + if(TaticList[j].judgeCondition(simPlayerData)) simPlayerData.updateData(TaticList[j].TaticFallBack()); + //reset player data by the Tatic + } + if(EndSitiuationJudge(simPlayerData)) break; + // if target was completed + } + simRec.AddData(simPlayerData); + // record and do caculate + } + +*/ + +class Command +{ +/* + * command set + * doSimulation [times] + * + * setTarget [TargetAmount] {[itemName] [amount]}…x"amount" times + * + * setBanner [5Up1Name] [5Up2Name] [5Arm1Name] [5Arm2Name] + * + * setTatic [firstBanner] [TaticAmount] {[Tragger] [traggerValue] [Factor] [factorValue] [modifyType] [modifyValue]}…"amount" times + * + */ +// Prmt-parameter +public: + int ID; + struct setTargetPrmt + { + string itemName; + int amount; + }; + + struct setBannerStu + { + string Up1Name, + Up2Name, + Arm1Name, + Arm2Name; + }; + + struct setTatic + { + int TraggerID, + traggerValue, + FactorID, + factorValue, + modifyTypeID, + modifyValue; + } + + Command Command(string cmdInput) //对输入字符串进行处理,存入以上指令数据集 + { + + } +} + +int main() +{ + //initialization simulation data + PlayerData simPlayerData = new PlayerData(); + GachaSystem thisGachaSystem = new GachaSystem(); + GachaSimulationRec simRec = new GachaSimulationRec(); + vector TaticList; + + + //input tatic + int totalSimulationTimes,totalTaticAmount; + + //begin command recall + + for(;;){ //Main + string commandString; + cin >> commandString; //input command + Command thiscommand = new Command(commandString); //initialization class commond and process commond + switch(thiscommand.GetPrvcommandID()){ //apply commond + case 0:{ + for(int i = 0;i < totalSimulationTimes;i ++) + { + for(;;) + { + GachaFallBack fallBackOnce = thisGachaSystem.doGacha(simPlayerData); + // do Gacha and get fallback + simPlayerData.updateData(fallBackOnce); + if(simPlayerData.EndSitiuationJudge()) break; + // refresh player data + for(int j = 0;j < totalTaticAmount;j ++) + { + if(TaticList[j].judgeCondition(simPlayerData)) simPlayerData.updateData(TaticList[j].TaticFallBack()); + //reset player data by the Tatic + } + // if target was completed + } + simRec.AddData(simPlayerData); + // record and do caculate + } + };break; + case 1:{ + + };break; + case 2:{ + + };break; + case 3:{ + + };break; + case 4:{ + + };break; + case 5:{ + + };break; + case 6:{ + + };break; + } + } + + //count record and produce ans + // simRec.output(); + return 0; +} \ No newline at end of file