Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8219805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:18:06+00:00 2026-06-07T13:18:06+00:00

Found the problem in the function HerusticSort , I’ll check that. I wrote a

  • 0

Found the problem in the function HerusticSort, I’ll check that.


I wrote a piece of python code using nested list like:

opentab = [[start], [0], [None]]

node = opentab[0].pop(0)

But when executing the code, it prompted

File "\Herustic Search.py", line 97, in HerusticSearchA

node = opentab[0].pop(0)

AttributeError: ‘tuple’ object has no attribute ‘pop’

It’s very weird because I didn’t change it’s class and I’ve already define it as nested list.


After the problem, I set an assertion to make sure it’s right.

assert isinstance(opentab[0], list)

And of course now I got an AssertionError

I also tried in IDLE one by one, and no problem.

I just put complete code piece here, I don’t know why this happened…


def HerusticSearchA(start, end):
    '''
    
    '''

    def H_Function(state, depth):
        '''
        state is a 3 x 3 list, stands for the puzzle state.
        returns the herustic assessment value
        g for the depth of the node, h for the incorrect tile number
        '''
        crit = copy.deepcopy(end)
        count = 0
        for i in range(len(state)):
            for j in range(len(state[0])):
                if state[i][j] - crit[i][j] != 0:
                    count += 1
        return depth + count


    #1. Variables
    #[[state], [value], [father]]
    opentab = [[start], [0], [None]]
    close = [[], [], []]

    depth = 0
    done = False

    print(start, end)
    while len(opentab[0]) > 0:
    #2. Nothing to continue
        if opentab == [[], [], []]:
            return None
    #3. remove n from OPEN
        assert isinstance(opentab[0], list)

        node = opentab[0].pop(0)
        nodevalue = opentab[1].pop(0)
        father = opentab[2].pop(0)
        close[0].append(node)
        close[1].append(nodevalue)
        close[2].append(father)
    #4. Got result
        if node == target:
            close[0].append(node)
            close[1].append(nodevalue)
            close[2].append(father)
            done = True
            break
    #5. Extract followers
        else:
            nexts = NextStep(node)
            for subnode in nexts:
                newvalue = H_Function(subnode, depth)
                #conditions:
                #6.
                if subnode not in opentab[0] and subnode not in close[0]:
                    opentab[0].append(subnode)
                    opentab[1].append(newvalue)
                    opentab[2].append(node)
                #7.
                if subnode in opentab[0]:
                    idx = opentab[0].index(subnode)
                    if newvalue < opentab[1][idx]:
                        opentab[1][idx] = newvalue
                        opentab[2][idx] = node
                #8.
                if subnode in close[0]:
                    idx = close[0].index(subnode)
                    if newvalue < close[1][idx]:
                        close[1][idx] = newvalue
                        close[2][idx] = node
        #9. sort opentab
        HerusticSort(opentab, 1)
        depth += 1

    return close
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:18:07+00:00Added an answer on June 7, 2026 at 1:18 pm

    The only line in this program that could possibly change opentab[0] to a tuple — under normal circumstances — is HeuristicSort. Unfortunately, the source of HeuristicSort isn’t here, so I can’t be certain that’s the problem. I’m posting this as requested, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
FINAL_EDIT: Found the problem, in a for loop the counter, that was used as
I have function that scrolls to a anchor position in a list function snapToAnchor(anchor)
I have a project that is C++ WIN32 project. I found a problem that
I found a code snippet which I want to implement. Now is the problem
We have encountered a very strange class not found problem in our web app
Seem to run into a service endpoint not found problem when trying to get
I'am currently working on GWTs Activity-Place implementation. Now I have found problem with the
I found a problem with host - client float standard in OpenCL. The problem
I found some problem. When i running apc_store and more times update a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.