import random


def noiseFilter(move, noise):
    """Turns 'move' into its opposite with the probability noise."""
    if random.random() < noise:
        if move == 1:  return 0
        else:  return 1
    else:  return move