Esempio n. 1
0
def play_finding_multiple():
    # TODO: make this pass
    # input("Starting: play_finding_multiple")
    S.reset()
    S.set_rack("ERDE")
    play_erde = D.Play("ERDE", "G8", "X")
    L.execute_play(play_erde)
    S.increase_turn()

    S.set_rack("DEN")
    area_den = D.Area("K6", "K8")
    subturn_den = Game.SubTurn(area_den)
    # highest scoring play should be DEN, K6, Y with ERDEN as bonus.
    print("highest scoring play for Area of K6 to K8:")
    print(subturn_den.highest_scoring_play)
    # play_den = D.Play("DEN", "K6", "Y")
    L.execute_play(subturn_den.highest_scoring_play)
    # L.execute_play(play_den)
    S.increase_turn()

    S.set_rack("URNE")
    Display.print_board()
    parallel_area = D.Area("I9", "L9")
    affected_parallel_plays = parallel_area.contested_plays
    print("affected_parallel plays:")
    pprint.pprint(affected_parallel_plays)

    parallel_subturn = Game.SubTurn(parallel_area)
    print("highest scoring play:")
    # expected: Still URNE on I9, X
    # bonus, DU, ER, DENN
    pprint.pprint(parallel_subturn.highest_scoring_play)
    print("Plays possible on I9 to L9:")
    pprint.pprint(parallel_subturn.possible_plays)
Esempio n. 2
0
def log_searching():
    S.reset()
    # finding the plays.
    S.set_rack("ERNSTLÜ")
    play_lustern = D.Play("LÜSTERN", "G8", "X")
    L.execute_play(play_lustern)
    S.increase_turn()
    # Display.print_board()

    # Set BORSTE
    S.set_rack("BORTE")
    play_borste = D.Play("BORSTE", "I5", "Y")
    L.execute_play(play_borste)
    S.increase_turn()
    # Display.print_board()

    # Set ERBE
    S.set_rack("ERE")
    play_erbe = D.Play("ERBE", "G5", "X")
    L.execute_play(play_erbe)
    S.increase_turn()
    # Display.print_board()

    # found_play = WL.find_active_play_by_position("G8")
    # print(found_play)
    # Find BEDARF,
    # Extends ERBE to DERBE
    # Extends LÜSTERN to FLÜSTERN
    # mark both extended-plays as "active" in the WordLog.
    # mark ERBE and LÜSTERN
    S.set_rack("BEDARF")
    test_area_bedarf = D.Area("F3", "F8")
    bedarf_turn = Game.SubTurn(test_area_bedarf.position_list)
    L.execute_play(bedarf_turn.highest_scoring_play)
    S.increase_turn()
    Display.print_board()

    print("All Plays:")
    all_plays = WL.read_log()
    pprint.pprint(all_plays)
    print("Length of all plays:", len(all_plays))

    print("updating to only active plays")
    WL.deactivate_extended_plays()

    print("Only the active plays:")
    active_plays = WL.get_active_plays()
    pprint.pprint(active_plays)
    print("Length of active plays:", len(active_plays))
    # test passes if the active plays are:
    # FLÜSTERN, DERBE, BORSTE and BEDARF
    print("PASSED.")
Esempio n. 3
0
def area_find_occupied_neighbors():
    S.reset()
    S.set_rack("STRUDELN")
    first_play = D.Play("STRUDELN", "F8", "x")
    L.execute_play(first_play)
    S.increase_turn()

    S.set_rack("FARBE")
    second_play = D.Play("FARBEN", "M3", "y")
    L.execute_play(second_play)
    S.increase_turn()

    S.set_rack("BEDARF")
    Display.print_board()
    subturn_area = D.Area("L2", "L14")
    subturn_to_solve = Game.SubTurn(subturn_area)
    pprint.pprint(subturn_to_solve.possible_plays)
Esempio n. 4
0
def first_turn():
    S.reset()
    S.set_rack("ERNSTLU?")

    filled_positions = []
    usable_positions = WS.find_usable_positions("H8", "x")
    print("Usable positions:")
    first_area = D.Area(position_list=usable_positions)
    starting_positions = WS.find_starting_position("STRUDELN", first_area)
    print("starting positions for STRUDELN:")
    print(starting_positions)
    Display.print_board()

    print("Subturn in Turn 1:")
    first_subturn = Game.SubTurn(first_area)
    highest_play = first_subturn.highest_scoring_play
    L.execute_play(highest_play)
    Display.print_board()
Esempio n. 5
0
def area_finding():
    S.set_rack("ERNSTL?")
    test_play_open = D.Play("LÜSTERN", "G8", "X")
    L.execute_play(test_play_open)
    S.increase_turn()
    Display.print_board()

    # Goal: make this consider FLÜSTERN by Building BEDARF on F3, along Y.
    S.set_rack("BEDARF")
    rack = S.get_rack()
    area_list = Scratch.find_all_areas_per_play(test_play_open, "y", rack)
    possible_plays = []
    for current_area in area_list:
        neighbors = current_area.get_area_neighbors()
        sub_turn = Game.SubTurn(current_area.position_list)
        possible_plays.append(sub_turn.highest_scoring_play)

    print(possible_plays)
    print("PASSED.")
Esempio n. 6
0
def play_finding_parallel():
    input("Starting: play_finding_parallel")
    S.reset()
    S.set_rack("ERDE")
    play_erde = D.Play("ERDE", "G8", "X")
    L.execute_play(play_erde)
    S.increase_turn()

    S.set_rack("URNE")
    Display.print_board()
    parallel_area = D.Area("I9", "L9")
    affected_parallel_plays = parallel_area.contested_plays
    print("affected_parallel plays:")
    pprint.pprint(affected_parallel_plays)

    parallel_subturn = Game.SubTurn(parallel_area)
    print("highest scoring play:")
    pprint.pprint(parallel_subturn.highest_scoring_play)
    print("Plays possible on I9 to L9:")
    pprint.pprint(parallel_subturn.possible_plays)
    print("PASSED.")
Esempio n. 7
0
def play_finding_by_position():
    # This passes when the play BEDARF, F3, Y
    # gets points for the 2 plays it extends.
    # (DERBE, E5, X) and (FL?STERN, E8, X)

    # Start by setting LÜSTERN
    S.set_rack("ERNSTL?")
    test_play_open = D.Play("LÜSTERN", "G8", "X")
    L.execute_play(test_play_open)
    S.increase_turn()
    Display.print_board()

    # Set BORSTE
    S.set_rack("BORTE")
    test_play_borste = D.Play("BORSTE", "I5", "Y")
    L.execute_play(test_play_borste)
    S.increase_turn()
    Display.print_board()

    # Set ERBE
    S.set_rack("ERE")
    test_play_erbe = D.Play("ERBE", "G5", "X")
    L.execute_play(test_play_erbe)
    S.increase_turn()
    Display.print_board()

    # found_play = WL.find_active_play_by_position("G8")
    # print(found_play)
    # Find BEDARF,
    # Extends ERBE to DERBE
    # Extends LÜSTERN to FLÜSTERN
    # mark both extended-plays as "active" in the WordLog.
    # mark ERBE and LÜSTERN

    S.set_rack("BEDARF")
    test_area_bedarf = D.Area("F3", "F8")
    # empty_area_with_no_neighbors = D.Area("D3", "D8")

    # Works.
    bedarf_turn = Game.SubTurn(test_area_bedarf.position_list)
    L.execute_play(bedarf_turn.highest_scoring_play)
    S.increase_turn()
    S.set_rack("VERNDE")
    Display.print_board()
    # Works.
    area_verderbende = D.Area("A5", "O5")
    verderbende_turn = Game.SubTurn(area_verderbende.position_list)
    L.execute_play(verderbende_turn.highest_scoring_play)
    S.increase_turn()
    Display.print_board()

    S.set_rack("ZIERENDE")
    area_extends_right = D.Area("N1", "N15")
    extends_right_turn = Game.SubTurn(area_extends_right.position_list)

    print("highest scoring play:")
    pprint.pprint(extends_right_turn.highest_scoring_play)
    L.execute_play(extends_right_turn.highest_scoring_play)
    S.increase_turn()
    Display.print_board()

    # active_plays = WL.get_active_plays()
    # pprint.pprint(active_plays)
    # print("Length of active plays:", len(active_plays))
    #
    # print("All plays of extends_right_turn")
    # pprint.pprint(extends_right_turn.possible_plays)

    # for position in test_area_bedarf.neighbors:
    #     L.set_letter_to_position(".", position)
    # Display.print_board()
    # print("-"*30)
    # print("LÜSTERN can be expanded at:", test_play_open.extendable_at)
    # test_area_flsternd = D.Area("F8", "N8")
    # print("contested at:", test_area_flsternd.contested_at)
    # print("contested play(s):")
    # print(test_area_flsternd.contested_plays)
    # TODO: the exact same play can be contested twice.
    #  -> identical play on 2 different positions

    S.set_rack("ERNSTZUNEHMEND")
    area_non_continuous = D.Area("L1", "L15")
    turn_non_continuous = Game.SubTurn(area_non_continuous.position_list)
    print("Current Rack:", S.get_rack())
    print("Plays possible on L1 to L15:")
    pprint.pprint(turn_non_continuous.possible_plays)

    # TODO, testing:
    # select an area directly adjacent to an existing word, make sure all sub-plays are
    # counted as well

    # UR on E13-F13 should be possible
    # Bonus: DU, E12-E13 // ER, F12-F13
    S.set_rack("ERDE")
    play_erde = D.Play("ERDE", "C12", "X")
    L.execute_play(play_erde)
    S.increase_turn()

    S.set_rack("URNE")
    Display.print_board()
    parallel_area = D.Area("C13", "H13")
    affected_parallel_plays = parallel_area.contested_plays
    print("affected_parallel plays:")
    pprint.pprint(affected_parallel_plays)

    parallel_subturn = Game.SubTurn(parallel_area.position_list)
    print("highest scoring play:")
    pprint.pprint(parallel_subturn.highest_scoring_play)
    print("Plays possible on C13 to F13:")
    pprint.pprint(parallel_subturn.possible_plays)

    # TODO, for Testing.:
    # create a situation on the board where the entire rack is played,
    # the word is vertical and extends all already existing words (7 extensions)

    # TODO: Idea - in an area with 2 or more possible extension_crossovers,
    # try to find the extensions first, then fill the area via regex-words.
    # needs: a function to reserve letters from the rack,
    # the word_search by regex,
    print("PASSED.")