summary refs log tree commit diff stats
path: root/randomizer
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-01-06 11:25:07 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-01-06 11:25:07 -0500
commitf01b3f48c9d2ed03068f328fb4e3456e2212a0be (patch)
tree2bb1aa662e9f9b17ef4f715fd84040871e0977d4 /randomizer
parent5355160de1bf99615cecdbcf918a96ccc292b1fa (diff)
downloadlingo-randomizer-f01b3f48c9d2ed03068f328fb4e3456e2212a0be.tar.gz
lingo-randomizer-f01b3f48c9d2ed03068f328fb4e3456e2212a0be.tar.bz2
lingo-randomizer-f01b3f48c9d2ed03068f328fb4e3456e2212a0be.zip
chains and palindromes (+39)
Diffstat (limited to 'randomizer')
-rw-r--r--randomizer/generator.gd122
1 files changed, 120 insertions, 2 deletions
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 = {}
22var _needs_reuse = [] 22var _needs_reuse = []
23var _possible_reuse = [] 23var _possible_reuse = []
24 24
25const kOrangeMiddle = -2
25const kWhiteMiddle = -1 26const kWhiteMiddle = -1
26const kWhiteTop = 0 27const kWhiteTop = 0
27const kWhiteBottom = 1 28const kWhiteBottom = 1
@@ -63,6 +64,7 @@ const kPuzzleTypes = [
63const kMustReuseAnswer = 1 64const kMustReuseAnswer = 1
64const kObscureHint = 2 65const kObscureHint = 2
65const kShortAnswer = 4 66const kShortAnswer = 4
67const kForcePalindrome = 8
66 68
67signal generator_status 69signal generator_status
68 70
@@ -265,6 +267,8 @@ func generate(chosen_seed):
265 _gSingle("Challenge Room/Panel_nevertrusted_maladjusted", kPurpleMiddle) 267 _gSingle("Challenge Room/Panel_nevertrusted_maladjusted", kPurpleMiddle)
266 _gSingle("Challenge Room/Panel_writer_songwriter", kBlueMiddle) 268 _gSingle("Challenge Room/Panel_writer_songwriter", kBlueMiddle)
267 _gSingle("Challenge Room/Panel_lobs_lobster", kBlueMiddle) 269 _gSingle("Challenge Room/Panel_lobs_lobster", kBlueMiddle)
270 _gChain("Challenge Room/Panel_grub_burger", [kBlackMiddle, kBlueMiddle])
271 _gChain("Challenge Room/Panel_open_nepotism", [kBlackMiddle, kBlueMiddle])
268 272
269 _setUniquePool("red") 273 _setUniquePool("red")
270 _gSingle("Hangry Room/Panel_red_bot_1", kRedBottom) 274 _gSingle("Hangry Room/Panel_red_bot_1", kRedBottom)
@@ -280,6 +284,7 @@ func generate(chosen_seed):
280 _gSingle("Shuffle Room/Panel_lost_found", kBlackBottom) 284 _gSingle("Shuffle Room/Panel_lost_found", kBlackBottom)
281 _gSingle("Shuffle Room/Panel_clockwise_counterclockwise", kBlackBottom) 285 _gSingle("Shuffle Room/Panel_clockwise_counterclockwise", kBlackBottom)
282 _gSingle("Shuffle Room/Panel_order_chaos", kBlackBottom) 286 _gSingle("Shuffle Room/Panel_order_chaos", kBlackBottom)
287 _gChain("Shuffle Room/Panel_runt3", [kYellowMiddle, kBlueMiddle])
283 288
284 _gSingle("Maze Room/Panel_down_up", kBlackBottom) 289 _gSingle("Maze Room/Panel_down_up", kBlackBottom)
285 _gSingle("Maze Room/Panel_strays_maze", kPurpleTop) 290 _gSingle("Maze Room/Panel_strays_maze", kPurpleTop)
@@ -318,6 +323,11 @@ func generate(chosen_seed):
318 323
319 _gSingle("Color Arrow Room/Panel_hues_colors", kWhiteBottom) 324 _gSingle("Color Arrow Room/Panel_hues_colors", kWhiteBottom)
320 325
326 _gDouble("Open Areas/Panel_rise_horizon", "Open Areas/Panel_rise_sunrise", kBlueTop)
327 _gDouble("Open Areas/Panel_son_horizon", "Open Areas/Panel_son_sunrise", kBlueTop)
328
329 _gChain("Lingo Room/Panel_lingo_7", [kOrangeMiddle, kBlueMiddle])
330
321 # Now we'll generate puzzles that don't need to be reused, and hopefully cover 331 # Now we'll generate puzzles that don't need to be reused, and hopefully cover
322 # all previously generated answers. 332 # all previously generated answers.
323 _clearFlag(kMustReuseAnswer) 333 _clearFlag(kMustReuseAnswer)
@@ -358,7 +368,15 @@ func generate(chosen_seed):
358 _gSingle("Palindrome Room/Panel_dread_dead", kRedMiddle) 368 _gSingle("Palindrome Room/Panel_dread_dead", kRedMiddle)
359 _gSingle("Palindrome Room/Panel_massacred_sacred", kRedMiddle) 369 _gSingle("Palindrome Room/Panel_massacred_sacred", kRedMiddle)
360 _gSingle("Palindrome Room/Panel_decay_day", kRedMiddle) 370 _gSingle("Palindrome Room/Panel_decay_day", kRedMiddle)
361 # do palindromes 371
372 _setFlag(kForcePalindrome)
373 _gSingle("Palindrome Room/Panel_solos_solos", kWhiteMiddle)
374 _gSingle("Palindrome Room/Panel_racecar_racecar", kWhiteMiddle)
375 _gSingle("Palindrome Room/Panel_level_level", kWhiteMiddle)
376 _gCopyHidden("Palindrome Room/Panel_solos_solos", "Palindrome Room/Panel_solos_solos_2")
377 _gCopyHidden("Palindrome Room/Panel_racecar_racecar", "Palindrome Room/Panel_racecar_racecar_2")
378 _gCopyHidden("Palindrome Room/Panel_level_level", "Palindrome Room/Panel_level_level_2")
379 _clearFlag(kForcePalindrome)
362 380
363 _setUniquePool("discerning") 381 _setUniquePool("discerning")
364 _gSingle("Sun Room/Panel_hits_this", kYellowMiddle) 382 _gSingle("Sun Room/Panel_hits_this", kYellowMiddle)
@@ -374,6 +392,20 @@ func generate(chosen_seed):
374 _gDouble("Sun Room/Panel_arts_star", "Sun Room/Panel_tsar_star", kYellowMiddle) 392 _gDouble("Sun Room/Panel_arts_star", "Sun Room/Panel_tsar_star", kYellowMiddle)
375 _gDouble("Sun Room/Panel_dear_read", "Sun Room/Panel_dare_read", kYellowMiddle) 393 _gDouble("Sun Room/Panel_dear_read", "Sun Room/Panel_dare_read", kYellowMiddle)
376 394
395 _setUniquePool("bearer")
396 _gChain("Cross Room/Panel_part_rap", [kRedMiddle, kYellowMiddle])
397 _gChain("Cross Room/Panel_heart_tar", [kRedMiddle, kYellowMiddle])
398 _gChain("Cross Room/Panel_smile_lime", [kRedMiddle, kYellowMiddle])
399 _gChain("Cross Room/Panel_snow_won", [kRedMiddle, kYellowMiddle])
400 _gChain("Cross Room/Panel_warts_star", [kRedMiddle, kYellowMiddle])
401 _gChain("Cross Room/Panel_pots_top", [kYellowMiddle, kRedMiddle])
402 _gChain("Cross Room/Panel_silent_list", [kRedMiddle, kYellowMiddle])
403 _gChain("Cross Room/Panel_silent_list_2", [kYellowMiddle, kRedMiddle])
404 _gChain("Cross Room/Panel_tent_net", [kRedMiddle, kYellowMiddle])
405 _gChain("Cross Room/Panel_peace_ape", [kRedMiddle, kYellowMiddle])
406 _gChain("Cross Room/Panel_space_cape", [kRedMiddle, kYellowMiddle])
407 _gChain("Cross Room/Panel_bowl_low", [kRedMiddle, kYellowMiddle])
408
377 _setUniquePool("bold") 409 _setUniquePool("bold")
378 _gSingle("Truncate Room/Panel_sushi_hi", kRedMiddle) 410 _gSingle("Truncate Room/Panel_sushi_hi", kRedMiddle)
379 _gSingle("Truncate Room/Panel_thistle_this", kRedMiddle) 411 _gSingle("Truncate Room/Panel_thistle_this", kRedMiddle)
@@ -450,6 +482,8 @@ func generate(chosen_seed):
450 _gSingle("Naps Room/Panel_same_mace", kBlackTop) 482 _gSingle("Naps Room/Panel_same_mace", kBlackTop)
451 _gSingle("Naps Room/Panel_safe_face", kBlackTop) 483 _gSingle("Naps Room/Panel_safe_face", kBlackTop)
452 _gSingle("Naps Room/Panel_might_time", kBlackTop) 484 _gSingle("Naps Room/Panel_might_time", kBlackTop)
485 _gChain("Naps Room/Panel_one_none", [kWhiteTop, kBlackBottom])
486 _gChain("Naps Room/Panel_one_many", [kBlackBottom, kWhiteTop])
453 487
454 _setUniquePool("unchallenged") 488 _setUniquePool("unchallenged")
455 _setFlag(kObscureHint) 489 _setFlag(kObscureHint)
@@ -465,6 +499,7 @@ func generate(chosen_seed):
465 _gSingle("Challenge Room/Panel_double_anagram_4", kYellowMiddle) 499 _gSingle("Challenge Room/Panel_double_anagram_4", kYellowMiddle)
466 _gSingle("Challenge Room/Panel_double_anagram_5", kYellowMiddle) 500 _gSingle("Challenge Room/Panel_double_anagram_5", kYellowMiddle)
467 _gSingle("Challenge Room/Panel_double_anagram_6", kYellowMiddle) 501 _gSingle("Challenge Room/Panel_double_anagram_6", kYellowMiddle)
502 _gChain("Challenge Room/Panel_tales_stale", [kOrangeMiddle, kYellowMiddle])
468 503
469 _setUniquePool("ecstatic") 504 _setUniquePool("ecstatic")
470 _gSingle("Smiley Room/Panel_anagram_7_1", kYellowTop) 505 _gSingle("Smiley Room/Panel_anagram_7_1", kYellowTop)
@@ -529,6 +564,7 @@ func generate(chosen_seed):
529 _gSingle("Painting Room/Panel_any_many", kBlueMiddle) 564 _gSingle("Painting Room/Panel_any_many", kBlueMiddle)
530 _gSingle("Painting Room/Panel_man_many", kBlueMiddle) 565 _gSingle("Painting Room/Panel_man_many", kBlueMiddle)
531 _clearFlag(kShortAnswer) 566 _clearFlag(kShortAnswer)
567 _gSingle("Painting Room/Panel_runts_turns", kYellowMiddle)
532 _gOrangeAddition("Painting Room/Panel_send_use_turns") 568 _gOrangeAddition("Painting Room/Panel_send_use_turns")
533 _gOrangeWord("Painting Room/Panel_trust_06890") 569 _gOrangeWord("Painting Room/Panel_trust_06890")
534 _gOrangeNumber("Painting Room/Panel_06890_trust") 570 _gOrangeNumber("Painting Room/Panel_06890_trust")
@@ -638,6 +674,9 @@ func generate(chosen_seed):
638 _gPaintingPuzzle("Panel Room/Panel_painting_owl", "owl_painting_gray") 674 _gPaintingPuzzle("Panel Room/Panel_painting_owl", "owl_painting_gray")
639 _gPaintingPuzzle("Panel Room/Panel_painting_panda", "panda_painting_gray") 675 _gPaintingPuzzle("Panel Room/Panel_painting_panda", "panda_painting_gray")
640 676
677 _gStack2("Open Areas/Panel_angered_enraged", kYellowMiddle, "", kWhiteBottom)
678 _gStack2("Open Areas/Panel_vote_veto", kYellowMiddle, "", kBlackBottom)
679
641 _setFlag(kObscureHint) 680 _setFlag(kObscureHint)
642 _gSingle("Entry Room/Panel_forward_forward", kWhiteMiddle) 681 _gSingle("Entry Room/Panel_forward_forward", kWhiteMiddle)
643 _gSingle("Entry Room/Panel_between_between", kWhiteMiddle) 682 _gSingle("Entry Room/Panel_between_between", kWhiteMiddle)
@@ -663,6 +702,16 @@ func generate(chosen_seed):
663 702
664 _gSingle("Double Room/Panel_leap_leap", kWhiteMiddle) 703 _gSingle("Double Room/Panel_leap_leap", kWhiteMiddle)
665 704
705 _gPaired("Appendix Room/Panel_left_left", "Appendix Room/Panel_right_right", kWhiteMiddle)
706
707 _gSingle("Hallway Room/Panel_hollow_hollow", kWhiteMiddle)
708 _gSingle("Hallway Room/Panel_out_out", kWhiteMiddle)
709
710 _gSingle("Open Areas/Panel_staircase", kWhiteMiddle)
711 _gSingle("Open Areas/Panel_smile_smile", kWhiteMiddle)
712 _gSingle("Open Areas/Panel_undistracted", kWhiteMiddle)
713 _gSingle("Open Areas/Panel_stargazer_stargazer", kWhiteMiddle)
714
666 _gSingle("Backside Room/Panel_backside_1", kWhiteMiddle) 715 _gSingle("Backside Room/Panel_backside_1", kWhiteMiddle)
667 _gSingle("Backside Room/Panel_backside_2", kWhiteMiddle) 716 _gSingle("Backside Room/Panel_backside_2", kWhiteMiddle)
668 _gSingle("Backside Room/Panel_backside_3", kWhiteMiddle) 717 _gSingle("Backside Room/Panel_backside_3", kWhiteMiddle)
@@ -673,6 +722,8 @@ func generate(chosen_seed):
673 _gSingle("Backside Room/Panel_second_second", kWhiteMiddle) 722 _gSingle("Backside Room/Panel_second_second", kWhiteMiddle)
674 _gSingle("Backside Room/Panel_third_third", kWhiteMiddle) 723 _gSingle("Backside Room/Panel_third_third", kWhiteMiddle)
675 _gSingle("Backside Room/Panel_fourth_fourth", kWhiteMiddle) 724 _gSingle("Backside Room/Panel_fourth_fourth", kWhiteMiddle)
725 _gSingle("Backside Room/Panel_paranoid_paranoid", kWhiteMiddle)
726 _gPaired("Backside Room/Panel_salt_pepper", "Backside Room/Panel_pepper_salt", kBlackBottom)
676 727
677 _gExactLength("Backside Room/Panel_four_four", kWhiteMiddle, 4) 728 _gExactLength("Backside Room/Panel_four_four", kWhiteMiddle, 4)
678 _gExactLength("Backside Room/Panel_four_four_2", kWhiteMiddle, 4) 729 _gExactLength("Backside Room/Panel_four_four_2", kWhiteMiddle, 4)
@@ -728,10 +779,18 @@ func generate(chosen_seed):
728 779
729func apply(scene): 780func apply(scene):
730 var panels_parent = scene.get_node("Panels") 781 var panels_parent = scene.get_node("Panels")
782 var found_panels = []
731 for puzzle in panel_mapping: 783 for puzzle in panel_mapping:
732 var panel = panels_parent.get_node(puzzle[0]) 784 var panel = panels_parent.get_node(puzzle[0])
733 panel.text = puzzle[1] 785 panel.text = puzzle[1]
734 panel.answer = puzzle[2] 786 panel.answer = puzzle[2]
787 found_panels.append(puzzle[0])
788
789 for panel_group in panels_parent.get_children():
790 for panel_panel in panel_group.get_children():
791 var relpath = String(panels_parent.get_path_to(panel_panel))
792 if !found_panels.has(relpath):
793 print("Unrandomized: %s" % relpath)
735 794
736 for mapping in painting_mapping: 795 for mapping in painting_mapping:
737 var scene_path = "res://nodes/paintings/%s.tscn" % mapping[1] 796 var scene_path = "res://nodes/paintings/%s.tscn" % mapping[1]
@@ -880,7 +939,57 @@ func _gStack2(panel1_path, puzzle_type1, panel2_path, puzzle_type2):
880 var hint2_choices = _puzzle_by_id[answer_id][1][puzzle_type2] 939 var hint2_choices = _puzzle_by_id[answer_id][1][puzzle_type2]
881 var hint2_id = _pickRandom(hint2_choices) 940 var hint2_id = _pickRandom(hint2_choices)
882 _setPanel(panel1_path, hint1_id, answer_id) 941 _setPanel(panel1_path, hint1_id, answer_id)
883 _setPanel(panel2_path, hint2_id, answer_id) 942 if panel2_path != "":
943 _setPanel(panel2_path, hint2_id, answer_id)
944
945
946func _gChain(panel_path, puzzle_types):
947 var remaining = []
948 puzzle_types.invert()
949 for ptype in puzzle_types:
950 if remaining.empty():
951 for answer in _answers_by_type[ptype]:
952 for choice in _puzzle_by_id[answer][1][ptype]:
953 remaining.append([choice, answer])
954 elif ptype == kOrangeMiddle:
955 var newrem = []
956 for puzzle in remaining:
957 if _generated_puzzles.wanderlust.has(puzzle[0]):
958 newrem.append(puzzle)
959 if newrem.empty():
960 print("No possible puzzles for panel %s" % panel_path)
961 return
962 remaining = newrem
963 else:
964 var newrem = []
965 for puzzle in remaining:
966 if _puzzle_by_id[puzzle[0]][1].has(ptype):
967 for choice in _puzzle_by_id[puzzle[0]][1][ptype]:
968 newrem.append([choice, puzzle[1]])
969 if newrem.empty():
970 print("No possible puzzles for panel %s" % panel_path)
971 return
972 remaining = newrem
973 var just_answers = []
974 var hints_by_answer = {}
975 for puzzle in remaining:
976 if !just_answers.has(puzzle[1]):
977 just_answers.append(puzzle[1])
978 hints_by_answer[puzzle[1]] = [puzzle[0]]
979 else:
980 hints_by_answer[puzzle[1]].append(puzzle[0])
981 var puzzle_choices = _filterBestPuzzles(just_answers)
982 if puzzle_choices.empty():
983 print("No possible puzzles for panel %s" % panel_path)
984 else:
985 var answer_id = _pickRandom(puzzle_choices)
986 var hint_choices = hints_by_answer[answer_id]
987 var hint_id = _pickRandom(hint_choices)
988 if puzzle_types[puzzle_types.size()-1] == kOrangeMiddle:
989 var hint = _applyCipher(_answer_by_id[hint_id])
990 _writePanel(panel_path, hint, _answer_by_id[answer_id])
991 else:
992 _setPanel(panel_path, hint_id, answer_id)
884 993
885 994
886func _gCopy(panel1_path, panel2_path): 995func _gCopy(panel1_path, panel2_path):
@@ -978,6 +1087,8 @@ func _filterBestPuzzles(input):
978 continue 1087 continue
979 if _isFlag(kShortAnswer) and _answer_by_id[word_id].length() > 4: 1088 if _isFlag(kShortAnswer) and _answer_by_id[word_id].length() > 4:
980 continue 1089 continue
1090 if _isFlag(kForcePalindrome) and _answer_by_id[word_id] != _reverseString(_answer_by_id[word_id]):
1091 continue
981 acceptable.append(word_id) 1092 acceptable.append(word_id)
982 #if _isFlag(kMustReuseAnswer): 1093 #if _isFlag(kMustReuseAnswer):
983 # var possible = [] 1094 # var possible = []
@@ -1029,3 +1140,10 @@ func _writePanel(panel_path, hint, answer):
1029 _answer_by_path[panel_path] = answer 1140 _answer_by_path[panel_path] = answer
1030 _total_generated += 1 1141 _total_generated += 1
1031 emit_signal("generator_status", "Generating puzzles... (%d/?)" % _total_generated) 1142 emit_signal("generator_status", "Generating puzzles... (%d/?)" % _total_generated)
1143
1144
1145func _reverseString(s):
1146 var r = ""
1147 for i in range(s.length()-1, -1, -1):
1148 r += s[i]
1149 return r