Files
Grinch-AP/worlds/stardew_valley/test/long/TestRandomWorlds.py
agilbert1412 52e65e208e Stardew Valley: 5.x.x - The Allsanity Update (#2764)
Major Content update for Stardew Valley, including the following features

- Major performance improvements all across the Stardew Valley apworld, including a significant reduction in the test time
- Randomized Farm Type
- Bundles rework (Remixed Bundles and Missing Bundle!)
- New Settings:
  * Shipsanity - Shipping individual items
  * Monstersanity - Slaying monsters
  * Cooksanity - Cooking individual recipes
  * Chefsanity - Learning individual recipes
  * Craftsanity - Crafting individual items
- New Goals:
  * Protector of the Valley - Complete every monster slayer goal
  * Full Shipment - Ship every item
  * Craftmaster - Craft every item
  * Gourmet Chef - Cook every recipe
  * Legend - Earn 10 000 000g
  * Mystery of the Stardrops - Find every stardrop (Maguffin Hunt)
  * Allsanity - Complete every check in your slot
- Building Shuffle: Cheaper options
- Tool Shuffle: Cheaper options
- Money rework
- New traps
- New isolated checks and items, including the farm cave, the movie theater, etc
- Mod Support: SVE [Albrekka]
- Mod Support: Distant Lands [Albrekka]
- Mod Support: Hat Mouse Lacey [Albrekka]
- Mod Support: Boarding House [Albrekka]

Co-authored-by: Witchybun <elnendil@gmail.com>
Co-authored-by: Witchybun <96719127+Witchybun@users.noreply.github.com>
Co-authored-by: Jouramie <jouramie@hotmail.com>
Co-authored-by: Alchav <59858495+Alchav@users.noreply.github.com>
2024-03-15 13:05:14 +01:00

91 lines
3.5 KiB
Python

import random
from typing import Dict
from BaseClasses import MultiWorld, get_seed
from Options import NamedRange, Range
from .option_names import options_to_include
from .. import setup_solo_multiworld, SVTestCase
from ..assertion import GoalAssertMixin, OptionAssertMixin, WorldAssertMixin
def get_option_choices(option) -> Dict[str, int]:
if issubclass(option, NamedRange):
return option.special_range_names
if issubclass(option, Range):
return {f"{val}": val for val in range(option.range_start, option.range_end + 1)}
elif option.options:
return option.options
return {}
def generate_random_multiworld(world_id: int):
world_options = generate_random_world_options(world_id)
multiworld = setup_solo_multiworld(world_options, seed=world_id)
return multiworld
def generate_random_world_options(seed: int) -> Dict[str, int]:
num_options = len(options_to_include)
world_options = dict()
rng = random.Random(seed)
for option_index in range(0, num_options):
option = options_to_include[option_index]
option_choices = get_option_choices(option)
if not option_choices:
continue
chosen_option_value = rng.choice(list(option_choices.values()))
world_options[option.internal_name] = chosen_option_value
return world_options
def get_number_log_steps(number_worlds: int) -> int:
if number_worlds <= 10:
return 2
if number_worlds <= 100:
return 5
if number_worlds <= 500:
return 10
if number_worlds <= 1000:
return 20
if number_worlds <= 5000:
return 25
if number_worlds <= 10000:
return 50
return 100
class TestGenerateManyWorlds(GoalAssertMixin, OptionAssertMixin, WorldAssertMixin, SVTestCase):
def test_generate_many_worlds_then_check_results(self):
if self.skip_long_tests:
return
number_worlds = 10 if self.skip_long_tests else 1000
seed = get_seed()
self.generate_and_check_many_worlds(number_worlds, seed)
def generate_and_check_many_worlds(self, number_worlds: int, seed: int):
num_steps = get_number_log_steps(number_worlds)
log_step = number_worlds / num_steps
print(f"Generating {number_worlds} Solo Multiworlds [Start Seed: {seed}] for Stardew Valley...")
for world_number in range(0, number_worlds + 1):
world_seed = world_number + seed
world_options = generate_random_world_options(world_seed)
with self.solo_world_sub_test(f"Multiworld: {world_seed}", world_options, seed=world_seed, world_caching=False) as (multiworld, _):
self.assert_multiworld_is_valid(multiworld)
if world_number > 0 and world_number % log_step == 0:
print(f"Generated and Verified {world_number}/{number_worlds} worlds [{(world_number * 100) // number_worlds}%]")
print(f"Finished generating and verifying {number_worlds} Solo Multiworlds for Stardew Valley")
def assert_multiworld_is_valid(self, multiworld: MultiWorld):
self.assert_victory_exists(multiworld)
self.assert_same_number_items_locations(multiworld)
self.assert_goal_world_is_valid(multiworld)
self.assert_can_reach_island_if_should(multiworld)
self.assert_cropsanity_same_number_items_and_locations(multiworld)
self.assert_festivals_give_access_to_deluxe_scarecrow(multiworld)
self.assert_has_festival_recipes(multiworld)