def verifyNeighbor (boardWidth, boardHeight, neighbor, me):

        my_row=me/boardWidth


    neighbor_row=neighbor/boardWidth
    if my_row==neighbor_row and abs(me-neighbor)==1:
            result=True
    else:
            result=False
    my_column=me/boardHeight
    neighbor_column=neighbor/boardHeight
    my_column=neighbor_column
    if my_column==neighbor_column and abs(me-neighbor)==boardHeight:
            result=True
    else:
            result=False
    x=boardWidth*boardHeight
    if neighbor>x:
            result=False
    else:
            result=True
    if neighbor<0:
            result=False
    else:
            result=True

    return result

given a board of height like 4,5 etc and a width of say 5,6,4,3 etc and given a tile say 0,2,3 etc verify if the neighbor tile is next to the me tile. I wrote it but dont know what is wrong i keep geting true result any help

maybe try to do if int(neighbor) > int(x)

i had a problem recently with a while loop that wouldn't stop and from someones advice on here i used the above and it solved the issue. perhaps someone with more knowledge could ellaborate on it and/or correct me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.