From f01b3f48c9d2ed03068f328fb4e3456e2212a0be Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 6 Jan 2024 11:25:07 -0500 Subject: chains and palindromes (+39) --- randomizer/generator.gd | 122 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 2 deletions(-) (limited to 'randomizer') diff --git a/randomizer/generator.gd b/randomizer/generator.gd index ad6263d..fca9aa9 100644 --- a/randomizer/generator.gd +++ b/randomizer/generator.gd @@ -22,6 +22,7 @@ var _answers_by_unique_pool = {} var _needs_reuse = [] var _possible_reuse = [] +const kOrangeMiddle = -2 const kWhiteMiddle = -1 const kWhiteTop = 0 const kWhiteBottom = 1 @@ -63,6 +64,7 @@ const kPuzzleTypes = [ const kMustReuseAnswer = 1 const kObscureHint = 2 const kShortAnswer = 4 +const kForcePalindrome = 8 signal generator_status @@ -265,6 +267,8 @@ func generate(chosen_seed): _gSingle("Challenge Room/Panel_nevertrusted_maladjusted", kPurpleMiddle) _gSingle("Challenge Room/Panel_writer_songwriter", kBlueMiddle) _gSingle("Challenge Room/Panel_lobs_lobster", kBlueMiddle) + _gChain("Challenge Room/Panel_grub_burger", [kBlackMiddle, kBlueMiddle]) + _gChain("Challenge Room/Panel_open_nepotism", [kBlackMiddle, kBlueMiddle]) _setUniquePool("red") _gSingle("Hangry Room/Panel_red_bot_1", kRedBottom) @@ -280,6 +284,7 @@ func generate(chosen_seed): _gSingle("Shuffle Room/Panel_lost_found", kBlackBottom) _gSingle("Shuffle Room/Panel_clockwise_counterclockwise", kBlackBottom) _gSingle("Shuffle Room/Panel_order_chaos", kBlackBottom) + _gChain("Shuffle Room/Panel_runt3", [kYellowMiddle, kBlueMiddle]) _gSingle("Maze Room/Panel_down_up", kBlackBottom) _gSingle("Maze Room/Panel_strays_maze", kPurpleTop) @@ -318,6 +323,11 @@ func generate(chosen_seed): _gSingle("Color Arrow Room/Panel_hues_colors", kWhiteBottom) + _gDouble("Open Areas/Panel_rise_horizon", "Open Areas/Panel_rise_sunrise", kBlueTop) + _gDouble("Open Areas/Panel_son_horizon", "Open Areas/Panel_son_sunrise", kBlueTop) + + _gChain("Lingo Room/Panel_lingo_7", [kOrangeMiddle, kBlueMiddle]) + # Now we'll generate puzzles that don't need to be reused, and hopefully cover # all previously generated answers. _clearFlag(kMustReuseAnswer) @@ -358,7 +368,15 @@ func generate(chosen_seed): _gSingle("Palindrome Room/Panel_dread_dead", kRedMiddle) _gSingle("Palindrome Room/Panel_massacred_sacred", kRedMiddle) _gSingle("Palindrome Room/Panel_decay_day", kRedMiddle) - # do palindromes + + _setFlag(kForcePalindrome) + _gSingle("Palindrome Room/Panel_solos_solos", kWhiteMiddle) + _gSingle("Palindrome Room/Panel_racecar_racecar", kWhiteMiddle) + _gSingle("Palindrome Room/Panel_level_level", kWhiteMiddle) + _gCopyHidden("Palindrome Room/Panel_solos_solos", "Palindrome Room/Panel_solos_solos_2") + _gCopyHidden("Palindrome Room/Panel_racecar_racecar", "Palindrome Room/Panel_racecar_racecar_2") + _gCopyHidden("Palindrome Room/Panel_level_level", "Palindrome Room/Panel_level_level_2") + _clearFlag(kForcePalindrome) _setUniquePool("discerning") _gSingle("Sun Room/Panel_hits_this", kYellowMiddle) @@ -374,6 +392,20 @@ func generate(chosen_seed): _gDouble("Sun Room/Panel_arts_star", "Sun Room/Panel_tsar_star", kYellowMiddle) _gDouble("Sun Room/Panel_dear_read", "Sun Room/Panel_dare_read", kYellowMiddle) + _setUniquePool("bearer") + _gChain("Cross Room/Panel_part_rap", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_heart_tar", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_smile_lime", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_snow_won", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_warts_star", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_pots_top", [kYellowMiddle, kRedMiddle]) + _gChain("Cross Room/Panel_silent_list", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_silent_list_2", [kYellowMiddle, kRedMiddle]) + _gChain("Cross Room/Panel_tent_net", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_peace_ape", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_space_cape", [kRedMiddle, kYellowMiddle]) + _gChain("Cross Room/Panel_bowl_low", [kRedMiddle, kYellowMiddle]) + _setUniquePool("bold") _gSingle("Truncate Room/Panel_sushi_hi", kRedMiddle) _gSingle("Truncate Room/Panel_thistle_this", kRedMiddle) @@ -450,6 +482,8 @@ func generate(chosen_seed): _gSingle("Naps Room/Panel_same_mace", kBlackTop) _gSingle("Naps Room/Panel_safe_face", kBlackTop) _gSingle("Naps Room/Panel_might_time", kBlackTop) + _gChain("Naps Room/Panel_one_none", [kWhiteTop, kBlackBottom]) + _gChain("Naps Room/Panel_one_many", [kBlackBottom, kWhiteTop]) _setUniquePool("unchallenged") _setFlag(kObscureHint) @@ -465,6 +499,7 @@ func generate(chosen_seed): _gSingle("Challenge Room/Panel_double_anagram_4", kYellowMiddle) _gSingle("Challenge Room/Panel_double_anagram_5", kYellowMiddle) _gSingle("Challenge Room/Panel_double_anagram_6", kYellowMiddle) + _gChain("Challenge Room/Panel_tales_stale", [kOrangeMiddle, kYellowMiddle]) _setUniquePool("ecstatic") _gSingle("Smiley Room/Panel_anagram_7_1", kYellowTop) @@ -529,6 +564,7 @@ func generate(chosen_seed): _gSingle("Painting Room/Panel_any_many", kBlueMiddle) _gSingle("Painting Room/Panel_man_many", kBlueMiddle) _clearFlag(kShortAnswer) + _gSingle("Painting Room/Panel_runts_turns", kYellowMiddle) _gOrangeAddition("Painting Room/Panel_send_use_turns") _gOrangeWord("Painting Room/Panel_trust_06890") _gOrangeNumber("Painting Room/Panel_06890_trust") @@ -638,6 +674,9 @@ func generate(chosen_seed): _gPaintingPuzzle("Panel Room/Panel_painting_owl", "owl_painting_gray") _gPaintingPuzzle("Panel Room/Panel_painting_panda", "panda_painting_gray") + _gStack2("Open Areas/Panel_angered_enraged", kYellowMiddle, "", kWhiteBottom) + _gStack2("Open Areas/Panel_vote_veto", kYellowMiddle, "", kBlackBottom) + _setFlag(kObscureHint) _gSingle("Entry Room/Panel_forward_forward", kWhiteMiddle) _gSingle("Entry Room/Panel_between_between", kWhiteMiddle) @@ -663,6 +702,16 @@ func generate(chosen_seed): _gSingle("Double Room/Panel_leap_leap", kWhiteMiddle) + _gPaired("Appendix Room/Panel_left_left", "Appendix Room/Panel_right_right", kWhiteMiddle) + + _gSingle("Hallway Room/Panel_hollow_hollow", kWhiteMiddle) + _gSingle("Hallway Room/Panel_out_out", kWhiteMiddle) + + _gSingle("Open Areas/Panel_staircase", kWhiteMiddle) + _gSingle("Open Areas/Panel_smile_smile", kWhiteMiddle) + _gSingle("Open Areas/Panel_undistracted", kWhiteMiddle) + _gSingle("Open Areas/Panel_stargazer_stargazer", kWhiteMiddle) + _gSingle("Backside Room/Panel_backside_1", kWhiteMiddle) _gSingle("Backside Room/Panel_backside_2", kWhiteMiddle) _gSingle("Backside Room/Panel_backside_3", kWhiteMiddle) @@ -673,6 +722,8 @@ func generate(chosen_seed): _gSingle("Backside Room/Panel_second_second", kWhiteMiddle) _gSingle("Backside Room/Panel_third_third", kWhiteMiddle) _gSingle("Backside Room/Panel_fourth_fourth", kWhiteMiddle) + _gSingle("Backside Room/Panel_paranoid_paranoid", kWhiteMiddle) + _gPaired("Backside Room/Panel_salt_pepper", "Backside Room/Panel_pepper_salt", kBlackBottom) _gExactLength("Backside Room/Panel_four_four", kWhiteMiddle, 4) _gExactLength("Backside Room/Panel_four_four_2", kWhiteMiddle, 4) @@ -728,10 +779,18 @@ func generate(chosen_seed): func apply(scene): var panels_parent = scene.get_node("Panels") + var found_panels = [] for puzzle in panel_mapping: var panel = panels_parent.get_node(puzzle[0]) panel.text = puzzle[1] panel.answer = puzzle[2] + found_panels.append(puzzle[0]) + + for panel_group in panels_parent.get_children(): + for panel_panel in panel_group.get_children(): + var relpath = String(panels_parent.get_path_to(panel_panel)) + if !found_panels.has(relpath): + print("Unrandomized: %s" % relpath) for mapping in painting_mapping: var scene_path = "res://nodes/paintings/%s.tscn" % mapping[1] @@ -880,7 +939,57 @@ func _gStack2(panel1_path, puzzle_type1, panel2_path, puzzle_type2): var hint2_choices = _puzzle_by_id[answer_id][1][puzzle_type2] var hint2_id = _pickRandom(hint2_choices) _setPanel(panel1_path, hint1_id, answer_id) - _setPanel(panel2_path, hint2_id, answer_id) + if panel2_path != "": + _setPanel(panel2_path, hint2_id, answer_id) + + +func _gChain(panel_path, puzzle_types): + var remaining = [] + puzzle_types.invert() + for ptype in puzzle_types: + if remaining.empty(): + for answer in _answers_by_type[ptype]: + for choice in _puzzle_by_id[answer][1][ptype]: + remaining.append([choice, answer]) + elif ptype == kOrangeMiddle: + var newrem = [] + for puzzle in remaining: + if _generated_puzzles.wanderlust.has(puzzle[0]): + newrem.append(puzzle) + if newrem.empty(): + print("No possible puzzles for panel %s" % panel_path) + return + remaining = newrem + else: + var newrem = [] + for puzzle in remaining: + if _puzzle_by_id[puzzle[0]][1].has(ptype): + for choice in _puzzle_by_id[puzzle[0]][1][ptype]: + newrem.append([choice, puzzle[1]]) + if newrem.empty(): + print("No possible puzzles for panel %s" % panel_path) + return + remaining = newrem + var just_answers = [] + var hints_by_answer = {} + for puzzle in remaining: + if !just_answers.has(puzzle[1]): + just_answers.append(puzzle[1]) + hints_by_answer[puzzle[1]] = [puzzle[0]] + else: + hints_by_answer[puzzle[1]].append(puzzle[0]) + var puzzle_choices = _filterBestPuzzles(just_answers) + if puzzle_choices.empty(): + print("No possible puzzles for panel %s" % panel_path) + else: + var answer_id = _pickRandom(puzzle_choices) + var hint_choices = hints_by_answer[answer_id] + var hint_id = _pickRandom(hint_choices) + if puzzle_types[puzzle_types.size()-1] == kOrangeMiddle: + var hint = _applyCipher(_answer_by_id[hint_id]) + _writePanel(panel_path, hint, _answer_by_id[answer_id]) + else: + _setPanel(panel_path, hint_id, answer_id) func _gCopy(panel1_path, panel2_path): @@ -978,6 +1087,8 @@ func _filterBestPuzzles(input): continue if _isFlag(kShortAnswer) and _answer_by_id[word_id].length() > 4: continue + if _isFlag(kForcePalindrome) and _answer_by_id[word_id] != _reverseString(_answer_by_id[word_id]): + continue acceptable.append(word_id) #if _isFlag(kMustReuseAnswer): # var possible = [] @@ -1029,3 +1140,10 @@ func _writePanel(panel_path, hint, answer): _answer_by_path[panel_path] = answer _total_generated += 1 emit_signal("generator_status", "Generating puzzles... (%d/?)" % _total_generated) + + +func _reverseString(s): + var r = "" + for i in range(s.length()-1, -1, -1): + r += s[i] + return r -- cgit 1.4.1