def checkTiles(seed, farm): rand = CSRandomLite(seed) for index in range(50): x = rand.Next(5, 60) y = rand.Next(5, 60) coordinate = (x, y) if coordinate not in farm.back: return False if coordinate in farm.buildings: return False if coordinate in farm.notPassable: return False if coordinate in farm.noFurniture: return False if coordinate in farm.water: return False if coordinate in farm.terrainFeatures: return False return True
def GetQuestItem(seed, daysPlayed, recipesKnown=1, mineFloor=0): random = Cs(seed + daysPlayed) random.Sample() # Selecting person season = (daysPlayed - 1) // 28 % 4 if season != 3 and random.Sample() < 0.15: possibleCrops = GetPossibleCrops(season, ((daysPlayed - 1) % 28) + 1 <= 7) return possibleCrops[random.Next(len(possibleCrops))] return SeedUtility.randomItemFromSeason(seed, daysPlayed, 1000, False, True, recipesKnown, mineFloor)
def uniqueKrobusStock(seed, daysPlayed): rand = CSRandomLite(int(seed / 2) + daysPlayed) dayOfWeek = daysPlayed % 7 if dayOfWeek == 3: return rand.Next(698, 709) if dayOfWeek == 6: index = rand.Next(194, 245) if index == 217: index = 216 return index return None
def unusualDarkFloor(seed, daysPlayed, level): if level % 10 == 0: return False if level % 40 > 30: return False rand = CSRandomLite(daysPlayed * level + 4 * level + int(seed / 2)) if rand.Sample() < 0.3 and level > 2: return True if rand.Sample() < 0.15 and level > 5 and not level == 120: return True return False
def dailyLuck(seed, daysPlayed, steps, rand=None): if rand == None: #random is initialised before daysPlayed is incremented rand = CSRandomLite( int(seed / 100) + (daysPlayed - 1) * 10 + 1 + steps) dishOfTheDay(seed, daysPlayed, steps, rand) #rand.Sample(); #Friendship #rand.Sample(); #Friendship mail rand.Sample() #Rarecrow society return min(.10, rand.Next(-100, 101) / 1000)
def monsterFloor(seed, daysPlayed, level): if level % 5 == 0: return False if level % 40 < 5: return False if level % 40 > 30: return False if level % 40 == 19: return False rand = CSRandomLite(int(seed / 2) + daysPlayed + level * 100) return rand.Sample() < 0.044
def getTravelingMerchantStock(item_data, gameID, dayNumber): rand = CSRandom(gameID+dayNumber) stock = {} for i in range(10): index = rand.Next(2, 790) while True: index = (index+1) % 790 item = item_data.get(str(index)) if item is None or not item_validity_check(item): continue break stock[item['name']] = max(rand.Next(1,11)*100, item['price']*rand.Next(3,6)) count = 1 if (rand.Sample() > 0.1) else 5 return stock
def randomItemFromSeason(gameID, day, seedAdd, furnace=False): season = (day-1) // 28 % 4 rand = CSRandomLite(gameID + day + seedAdd) source = [68, 66, 78, 80, 86, 152, 167, 153, 420] source.extend({ 0 : [16,18,20,22,129,131,132,136,137,142,143,145,147,148,152,167], 1 : [128,130,131,132,136,138,142,144,145,146,149,150,155,396,398,400,402], 2 : [404,406,408,410,129,131,132,136,137,139,140,142,143,148,150,154,155], 3 : [412,414,416,418,130,131,132,136,140,141,143,144,146,147,150,151,154] }[season]) if furnace: source.extend([334,335,336,338]) r = rand.Next(len(source)) return source[r]
def setupHand(seed, day=0, timesPlayed=0, report=False): rand = CSRandomLite(seed + day + timesPlayed) card1 = rand.Next(1, 12) card2 = rand.Next(1, 10) dealerTotal = card1 + card2 card3 = rand.Next(1, 12) card4 = rand.Next(1, 10) playerTotal = card3 + card4 if report: print("Dealer cards:") print(card1) print(card2) print("Player cards:") print(card3) print(card4) return rand, playerTotal, dealerTotal
def harvest_quality(gameID, dayNumber, fLevel, xTile, yTile, fertilizer=None): number = 1 quality = 0 num3 = 0 if fertilizer != None: if fertilizer == 'Basic': num3 = 1 elif fertilizer == 'Quality': num3 = 2 rand = CSRandomLite(xTile * 7 + yTile * 11 + gameID + dayNumber) num4 = 0.2 * (fLevel / 10.0) + 0.2 * num3 * (fLevel + 2.0) / 12.0 + 0.01 num5 = min(0.75, num4 * 2.0) if rand.Sample() < num4: quality = 2 elif rand.Sample() < num5: quality = 1 return quality
def checkMinesSpot(seed, ladder=False): objects = [] r = CSRandomLite(seed) r.Sample() if not ladder: r.Sample() if r.Sample() < 0.022: objects.extend([535]) if r.Sample() < 0.005: objects.extend([749]) if r.Sample() < 0.05: r.Sample() r.Sample() if r.Sample() < 0.25: objects.extend([382]) if r.Sample() < 0.1: objects.extend([380]) else: objects.extend([378]) return objects
def isEvent(seed): rand = CSRandomLite(seed) if rand.Sample() < 0.01: return 0 if rand.Sample() < 0.01: return 0 if rand.Sample() < 0.01: return 0 if rand.Sample() < 0.01: return 1 if rand.Sample() < 0.01: return 2 return 0
def totalHarvest(seed, chanceForExtra, level=0, fert=0): num1 = 1 rand = CSRandomLite(seed) num3 = 0.2 * (level / 10.0) + 0.2 * fert * ((level + 2.0) / 12.0) + 0.01 if rand.Sample() >= num3: rand.Sample() #crop quality if False: rand.Sample() #TODO: min/max harvest if chanceForExtra > 0: while rand.Sample() < chanceForExtra: num1 = num1 + 1 if rand.Sample() < 9.99999974737875E-05: num1 = num1 * 2 return num1
def dishOfTheDay(seed, daysPlayed, steps, rand=None): #random is initialised before daysPlayed is incremented localDaysPlayed = daysPlayed - 1 if rand == None: rand = CSRandomLite(int(seed / 100) + localDaysPlayed * 10 + 1 + steps) dayOfMonth = ((localDaysPlayed - 1) % 28) + 1 # for index in range(100): # print( str( min(.10, rand.Next(-100, 101) / 1000) ) ) for index in range(dayOfMonth): rand.Sample() dish = rand.Next(194, 240) while dish in {346, 196, 216, 224, 206, 395, 217}: dish = rand.Next(194, 240) #Dish additional number number = rand.Next(1, 4 + 10 if rand.Sample() < 0.08 else 0) #Dish number rand.Sample() #Object constructor return dish, number
def nightEvent(seed, daysPlayed): #Night events are based on the new day if daysPlayed == 32: return None rand = CSRandomLite(int(seed / 2) + daysPlayed) if rand.Sample() < 0.01: if (daysPlayed - 1) // 28 % 4 != 3: return "Fairy" if rand.Sample() < 0.01: return "Witch" if rand.Sample() < 0.01: return "Meteor" if rand.Sample() < 0.01: if daysPlayed > 28 * 4: return "UFO" if rand.Sample() < 0.01: return "Owl"
def checkTrash(gameID, day, index, x, y, furnace=False, luck=0.0, version="1.4", returnMinLuck=False, minesFloor=0): if version == "1.4": rand = CSRandom(gameID // 2 + day + 777 + index * 77) num2 = rand.Next(0, 100) for index2 in range(num2): rand.Sample() num2 = rand.Next(0, 100) for index2 in range(num2): rand.Sample() #rand.Sample() #rand.Sample() else: rand = CSRandomLite(gameID // 2 + day + 777 + index) result = rand.Sample() if result < luck + 0.2: minLuck = result - 0.2 r = rand.Next(10) if r == 6: ps = randomItemFromSeason(gameID, day, x * 653 + y * 777, furnace, minesFloor) elif r == 8: ps = 309 + rand.Next(3) else: ps = { 0: 168, 1: 167, 2: 170, 3: 171, 4: 172, 5: 216, 7: 403, 9: 153 }[r] if index == 3: result = rand.Sample() if result < luck + 0.2: minLuck = max(minLuck, result - 0.2) ps = 535 if rand.Sample() < 0.05: ps = 749 if index == 4: result = rand.Sample() if result < luck + 0.2: minLuck = max(minLuck, result - 0.2) ps = 378 + rand.Next(3) * 2 if version == "1.4": rand.Next(1, 5) if index == 5: result = rand.Sample() if result < luck + 0.2: minLuck = max(minLuck, result - 0.2) ps = 196 # meals are complicated if returnMinLuck: return 'DishOfTheDay', minLuck return 'DishOfTheDay' if index == 6: result = rand.Sample() if result < luck + 0.2: minLuck = max(minLuck, result - 0.2) ps = 223 if index == 7 and rand.Sample() < 0.2: ps = 167 if returnMinLuck: return ps, minLuck return ps if returnMinLuck: return None, None return None
def getNumTreasureFromGeode(uniqueIDForThisGame, geode_number, geode_type): random = CSRandomLite(geode_number + (uniqueIDForThisGame // 2)) num = None sheet_index = {0:535, 1:536, 2:537, 3: 749}[geode_type] if random.Sample() < 0.5: num = int(random.Next(3)) * 2 + 1 if random.Sample() < 0.1: num = 10 if random.Sample() < 0.01: num = 20 if random.Sample() < 0.5: r = random.Next(4) if r == 0 or r == 1: return ObjectInfo[390], num # stone if r == 2: return ObjectInfo[330], 1 # clay if r == 3: if sheet_index == 535: return ObjectInfo[86], 1 # earth crystal elif sheet_index == 536: return ObjectInfo[84], 1 # frozen tear elif sheet_index ==537: return ObjectInfo[82], 1 # fire quartz return ObjectInfo[82+ random.Next(3)*2], 1 elif sheet_index == 535: num2 = random.Next(3) if num2 == 0: return ObjectInfo[378], num # copper ore if num2 == 1: # assumes that the person is beyond floor 25 in the mines return ObjectInfo[380], num # iron ore if num2 == 2: return ObjectInfo[382], num # coal elif sheet_index == 536: r = random.Next(4) if r == 0: return ObjectInfo[378], num # copper ore elif r == 1: return ObjectInfo[380], num # iron ore elif r == 2: return ObjectInfo[382], num # coal else: return ObjectInfo[384], num # gold ore else: r = random.Next(5) if r == 0: return ObjectInfo[378], num # copper ore elif r == 1: return ObjectInfo[380], num # iron ore elif r == 2: return ObjectInfo[382], num # coal elif r == 3: return ObjectInfo[384], num # gold ore else: return ObjectInfo[386], int(num/2) + 1# iridium ore else: geode_items = [538,542,548,549,552,555,556,557,558,566,568,569,571,574,576,121] frozen_items = [541,544,545,546,550,551,559,560,561,564,567,572,573,577,123] magma_items = [539,540,543,547,553,554,562,563,565,570,575,578,122] omni_items = [538,542,548,549,552,555,556,557,558,566,568,569,571,574,576,541,544,545,546,550,551,559,560,561,564,567,572,573,577,539,540,543,547,553,554,562,563,565,570,575,578,121,122,123] if sheet_index == 535: return ObjectInfo[geode_items[random.Next(len(geode_items))]], 1 if sheet_index == 536: return ObjectInfo[frozen_items[random.Next(len(frozen_items))]], 1 if sheet_index == 537: return ObjectInfo[magma_items[random.Next(len(magma_items))]], 1 if sheet_index == 749: r = random.Next(len(omni_items)) if random.Sample() < 0.008 and geode_number > 15: return ObjectInfo[74], 1 try: return ObjectInfo[omni_items[r]], 1 except IndexError: print(r, len(omni_items)) return ObjectInfo[74], 1 return ObjectInfo[390], 1
def findSeed(): cartDays = [5,7,12,14,19,21,26,28] krobusDays = [10,17,24] bestSeed = 0 bestSeedAmount = 99999 seeds = range(startRange,endRange) for seed in seeds: if seed % 10000 == 0: cleanupCache(seed) if seed % 1000000 == 0: print("Searching: " + str(seed)) f = open(filename,"at") f.write("searching: " + str(seed) + '\n') f.close() #Find bundles for this seed requiredItems,hasFairyItems = RandomBundlesSeeding.getAllSeasonalRequiredItems(seed, "Quality Crops","Quality Fish") #Check if seed is valid if -1 in requiredItems: continue #Requires a fairy morning of Summer 2 hasFairy = SeedUtility.nightEvent(seed,30) == "Fairy" if hasFairyItems and not hasFairy: continue if hasFairy: for fairyItem in fairyItems: while fairyItem in requiredItems: del requiredItems[requiredItems.index(fairyItem)] #Look at travelling cart for Spring #neededItems = {140:1,266:1,272:1,276:1,408:1,416:1,418:1,699:1} #neededItems = {140:1,272:1,276:1,408:1,416:1,418:1,699:1} #idealItems= [254,256,258,260,270,376,421,266] summerCrops = 0 for day in cartDays: if seed+day in travelingCartCache: stock = travelingCartCache[seed+day] else: stock = TravelingCart.getTravelingMerchantStock_1_4(seed+day,"1.5") travelingCartCache[seed+day] = stock for item in stock.items(): if item[0] == 262: summerCrops = summerCrops + item[1][1] if item[0] not in requiredItems: continue del requiredItems[requiredItems.index(item[0])] for day in krobusDays: kroItem = SeedUtility.uniqueKrobusStock(seed,day) if kroItem not in requiredItems: continue del requiredItems[requiredItems.index(kroItem)] if 266 in requiredItems: random = Random(seed*12) if random.Next(2,31) <= 8: del requiredItems[requiredItems.index(266)] needTrash = False if 150 in requiredItems: del requiredItems[requiredItems.index(150)] needTrash = True #Hack for Garden bundle if len(requiredItems) == 1: if 593 in requiredItems: del requiredItems[requiredItems.index(593)] if 595 in requiredItems: del requiredItems[requiredItems.index(595)] if 421 in requiredItems: del requiredItems[requiredItems.index(421)] if requiredItems == []: print(str(seed) + " " + str(summerCrops) + " Need Trash: " + str(needTrash)) f = open(filename,"at") f.write(str(seed) + " " + str(summerCrops) + " Need Trash: " + str(needTrash) + '\n') f.close() if len(requiredItems) < bestSeedAmount: bestSeed = seed bestSeedAmount = len(requiredItems)
def checkTrash(gameID,day,index,x,y,furnace=False, luck=0.2): rand = CSRandomLite(gameID//2 + day + 777 + index) if rand.Sample() < luck: r = rand.Next(10) if r == 6: ps = randomItemFromSeason(gameID, day, x*653+y*777, furnace) elif r == 8: ps = 309 + rand.Next(3) else: ps = { 0 : 168, 1 : 167, 2 : 170, 3 : 171, 4 : 172, 5 : 216, 7 : 403, 9 : 153 }[r] if index == 3 and rand.Sample() < luck: ps = 535 if rand.Sample() < 0.05: ps = 749 if index == 4 and rand.Sample() < luck: ps = 378 + rand.Next(3)*2 if index == 5 and rand.Sample() < luck: ps = 196 # meals are complicated return 'DishOfTheDay' if index == 6 and rand.Sample() < luck: ps = 223 return ObjectInfo[ps].split('/')[0] return None
def giantCropAmount(seed, daysPlayed, x, y): rand = CSRandomLite(seed + daysPlayed + x * 7 + y * 11) return rand.Next(15, 22)
def nextGeodeItem(seed, geodesCracked, geodeType, deepestMineLevel=0, version="1.4"): rand = CSRandomLite(geodesCracked + int(seed / 2)) if version == "1.4" or version == "1.5": num1 = rand.Next(1, 10) for index in range(num1): rand.Sample() num2 = rand.Next(1, 10) for index in range(num2): rand.Sample() if version == "1.5": rand.Sample() #QI beans if rand.Sample() < 0.5: initialStack = rand.Next(3) * 2 + 1 if rand.Sample() < 0.1: initialStack = 10 if rand.Sample() < 0.01: initialStack = 20 if rand.Sample() < 0.5: case = rand.Next(4) if case == 0 or case == 1: return (390, initialStack) elif case == 2: return (330, 1) else: if geodeType == "Geode": return (86, 1) if geodeType == "Frozen": return (84, 1) if geodeType == "Magma": return (82, 1) if geodeType == "Omni": return (82 + rand.Next(3) * 2, 1)
def giantCrop(seed, daysPlayed, x, y, version="1.3"): if version == "1.3": result = CSRandomLite(seed + daysPlayed + x * 2000 + y).Sample() elif version == "1.4": result = oneTimeRandomGetDouble(seed, daysPlayed, x, y) return result < 0.01
def fairyCropNumbers(seed, days): rand = CSRandomLite(seed + days) for i in range(100): print(rand.Sample())