Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools as it
- import json
- import pathlib
- import more_itertools
- import random
- import csv
- def main():
- recipies = []
- affinities = []
- filepath = pathlib.Path.cwd() / "food combanitions.json"
- with filepath.open("r", encoding ="utf-8") as f:
- try:
- recipies = json.load(f)
- for recipe in recipies:
- sum = 0
- for ingredient in recipe:
- sum = sum + ingredient[1]
- afinityNum = (sum % 138) + 1
- if afinityNum in affinities:
- continue
- affinities.append(afinityNum)
- except json.JSONDecodeError:
- pass
- print(f"Size:{len(affinities)} {affinities}")
- # make breakfast: oven 178, pottery bowl 77,
- # Ogare's shift 92
- # All veggies are chopped and then cooked. Mashed coud be subtituted
- # for chopped but it doesn't make a differnce.
- # roasted is +4, fried is +1
- # material all vegetarian 22
- # all values have 128 added for some ood reason
- # modulo'd all summed values(templateID + material + state + 128) by 138.
- pea = [["roasted pea", 62], ["fried pea", 59]] # 1150
- corn =[["roasted corn", 48], ["fried corn", 45]] # 32
- garlic = [["roasted garlic", 96], ["fried garlic", 93]] # 356
- tomato = [["roasted tomato", 47], ["fried tomato", 44]] # 1135
- peaPods = [["roasted pea pods", 50], ["fried pea pods", 47]] # 1138
- carrot = [["roasted carrot", 45], ["fried carrot", 42]] # 1133
- cucumber = [["roasted cucumber", 21], ["fried cucumber", 18]] #1247
- onion = [["roasted onion", 95], ["fried onion", 92]] # 355
- potato = [["roasted potato", 51], ["fried potato", 48]] #35
- # all meat is diced, minced and then fried. meat id 92
- # material types:
- # bear 72, beef 73, canine 74, feline 75, dragon 76, fowl 77,
- # game 78, horse 79, human 80, humanoid 81, insect 82, lamb 83,
- # pork 84, seafood 85, snake 86, tough 87
- # modulo'd all summed values(templateID + material + state + 128) by 138.
- meat = [["fried meat, bear", 17], ["fried meat, canine", 19],
- ["fried meat, feline", 20], ["fried meat, game", 23],
- ["fried meat, horse", 24], ["fried meat, human", 25],
- ["fried meat, humanoid", 26], ["fried meat, insect", 27]]
- # herbs
- # chopped and ground are +16, material all vegetarian 22
- # modulo'd all summed values(templateID + material + state + 128) by 138.
- lovage = [["chopped lovage", 105], ["lovage", 89]]# 353
- rosemary = [["chopped rosemary", 115], ["rosemary", 99]]# 363
- basil = [["chopped basil", 111], ["basil", 95]] # 359
- belladonna = [["chopped belladonna", 113], ["belladonna", 97]] # 361
- fennelSeed = [["ground fennel seed", 75], ["fennel seed", 59]] # 1151
- mint = [["chopped mintmint", 54], ["mint", 38]] # 1130
- oregano = [["chopped oregano", 109], ["oregano", 93]] # 357
- parsley = [["chopped parsley", 110], ["parsley", 94]] # 358
- sage = [["chopped sage", 106], ["sage", 90]] # 354
- thyme = [["chopped thyme", 112], ["thyme", 96]] # 360
- cumin = [["ground cumin", 64], ["cumin", 48]] # 1140
- paprika = [["ground paprika", 67], ["paprika", 51]] # 1143
- turmeric = [["ground turmeric", 68], ["turmeric", 52]] # 1144
- ginger = [["ground ginger", 65], ["ginger", 49]] # 1141
- herbs = (lovage, rosemary, basil, belladonna, fennelSeed, mint, oregano,
- parsley, sage, thyme, cumin, paprika, turmeric, ginger)
- herbSample = []
- herbGroups = list(it.combinations_with_replacement(
- (0,1,2,3,4,5,6,7,8,9,10,11,12,13), 2))
- for herbIndexs in herbGroups:
- ingredients = [pea, corn, garlic, tomato, peaPods, carrot, cucumber, onion, potato,
- meat]
- for index in herbIndexs:
- ingredients.append(herbs[index])
- simulatedRecipies = list(it.product(*ingredients))
- for recipe in simulatedRecipies:
- sum = 0
- for ingredient in recipe:
- sum = sum + ingredient[1]
- afinityNum = (sum % 138) + 1
- if afinityNum in affinities:
- continue
- recipies.append(recipe)
- affinities.append(afinityNum)
- with filepath.open("w", encoding ="utf-8") as f:
- json.dump(recipies, f)
- print(f"Size:{len(affinities)} {affinities}")
- filepath1 = pathlib.Path.cwd() / "food combanitions1.csv"
- with filepath1.open("w", encoding ="utf-8") as f:
- for r in recipies:
- if len(r) == 11:
- csvStr = [
- f"{r[0][0]}, {r[0][1]}, {r[1][0]}, {r[1][1]}, {r[2][0]}, ",
- f"{r[2][1]}, {r[3][0]}, {r[3][1]}, {r[4][0]}, {r[4][1]}, ",
- f"{r[5][0]}, {r[5][1]}, {r[6][0]}, {r[6][1]}, {r[7][0]}, ",
- f"{r[7][1]}, {r[8][0]}, {r[8][1]}, {r[9][0]}, {r[9][1]}, ",
- f"{r[10][0]}, {r[10][1]}\r"]
- f.write("".join(csvStr))
- if len(r) == 12:
- csvStr = [
- f"{r[0][0]}, {r[0][1]}, {r[1][0]}, {r[1][1]}, {r[2][0]}, ",
- f"{r[2][1]}, {r[3][0]}, {r[3][1]}, {r[4][0]}, {r[4][1]}, ",
- f"{r[5][0]}, {r[5][1]}, {r[6][0]}, {r[6][1]}, {r[7][0]}, ",
- f"{r[7][1]}, {r[8][0]}, {r[8][1]}, {r[9][0]}, {r[9][1]}, ",
- f"{r[10][0]}, {r[10][1]}, {r[11][0]}, {r[11][1]}\r"]
- f.write("".join(csvStr))
- main()
Add Comment
Please, Sign In to add comment