when making slight changes to an an automatic chess.com bot, I came along this error:
Exception has occurred: MoveTargetOutOfBoundsException
Message: move target out of bounds
With the code:
result = engine.play(board, limit)
origin = find_loc(str(result.move)[:2])
target = find_loc(str(result.move)[2:4])
offset = [a - b for a, b in zip(target, origin)]
offset[0] *= piece_size
offset[1] *= -piece_size
origin_push = driver.find_element_by_xpath(f"//div[contains(@class, 'piece') and contains(@class, 'square-{origin[0]}{origin[1]}')]")
action_chains = ActionChains(driver)
action_chains.drag_and_drop_by_offset(origin_push, offset[0], offset[1]).perform()
The code above finds the orgin of the piece it's attempting to move, find the target, and then calulate the offset (how far the piece should move on the board). I'm having issues with the origin_push, giving the error above.
I know about drag_and_drop_by_offset()
errors in the past, but this is the first time I've attempted to solve one, and any help would be appriciated.