Skip to content

Commit 76254c9

Browse files
committed
Example of brute force for a generalized filter
1 parent 448ae24 commit 76254c9

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

src/main.cpp

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,97 @@
44
#include <iostream>
55
#include <vector>
66

7+
//Unfinished code, proof of concept
8+
//Brute force filtering method, checking all items for those in list
9+
10+
std::vector<Item> itemList;
11+
//std::vector<Item> enhancementList //Todo check for enhancements, seals, editions
12+
std::vector<int> amountList;
13+
std::vector<int> anteList; //Until what ante to check for x item in itemList
14+
long filter_all(Instance inst) {
15+
std::vector<int> amountFoundList;
16+
amountFoundList.resize(itemList.size());
17+
std:fill(amountFoundList.begin(), amountFoundList.end(), 0);
18+
19+
for (int i = 0; i < itemList.size(); i++) {
20+
21+
//Check the amount of antes given for that item
22+
for (int ante = 1; ante <= anteList[i]; ante++) {
23+
int max_packs = 4;
24+
if (ante > 1) max_packs = 6;
25+
26+
int max_store_items = 10;
27+
if (ante > 1) max_store_items = 50;
28+
29+
int max_tags = 2;
30+
31+
//Check packs
32+
for (int p = 1; p <= max_packs; p++) {
33+
Pack pack = packInfo(inst.nextPack(ante));
34+
if (pack.type == itemList[i]) {
35+
amountFoundList[i]++;
36+
continue;
37+
}
38+
39+
//Do this for each pack type, possibly roll into a function
40+
if (pack.type == Item::Arcana_Pack){
41+
auto packContents = inst.nextArcanaPack(pack.size, 1);
42+
for (int x = 0; x < pack.size; x++) {
43+
if (packContents[x] == itemList[i])
44+
amountFoundList[i]++;
45+
}
46+
}
47+
48+
}
49+
//Check store
50+
for (int s = 1; s <= max_store_items; s++) {
51+
ShopItem shop_item = inst.nextShopItem(ante);
52+
if (shop_item.item == itemList[i]) {
53+
amountFoundList[i]++;
54+
}
55+
}
56+
57+
//Check vouchers
58+
if (inst.nextVoucher(ante) == itemList[i]) {
59+
amountFoundList[i]++;
60+
}
61+
62+
//Check tags (Possible improvement is checking for double tags)
63+
for (int t = 1; t <= max_tags; t++) {
64+
Item tag = inst.nextTag(ante);
65+
if (tag == itemList[i]) {
66+
amountFoundList[i]++;
67+
continue;
68+
}
69+
70+
//Do this for each pack type, possibly roll into a function
71+
if (tag == Item::Buffoon_Tag) {
72+
auto packContents = inst.nextBuffoonPack(2, 1);
73+
for (int x = 0; x < 2; x++) {
74+
if (packContents[x].joker == itemList[i])
75+
amountFoundList[i]++;
76+
}
77+
}
78+
}
79+
}
80+
//Reset instance (Not sure if I need to do it anywhere else)
81+
inst.reset(inst.seed);
82+
}
83+
84+
//Check if you have found all the items in a list
85+
int correct_amounts = 0;
86+
for (int i = 0; i < amountList.size(); i++) {
87+
if (amountFoundList[i] >= amountList[i]) {
88+
correct_amounts++;
89+
}
90+
}
91+
if (correct_amounts == amountList.size()) {
92+
return 1;
93+
}
94+
return 0;
95+
96+
}
97+
798
long filter(Instance inst) {
899
long legendaries = 0;
9100
inst.nextPack(1);

0 commit comments

Comments
 (0)