0

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

2
Contributors
1
Reply
29
Views
4 Years
Discussion Span
Last Post by lancevo3
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.