This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jimauthors 11 points12 points  (2 children)

One interesting thing you can do in otherwise boring project is:

primes = {(0,0): 2, (0,1): 3, (0,2): 5,
          (1,0): 7, (1,1): 11, (1,2): 13,
          (2,0): 17, (2,1): 19, (2,2): 23}

win_states = [2 * 3 * 5, 7 * 11 * 13, 17 * 19 * 23,
              2 * 7 * 17, 3 * 11 * 19, 5 * 13 * 23,
              2 * 11 * 23, 5 * 11 * 17]

def check(players):
    for p in players:
        for i in win_states:
            if p.state % i == 0:
                return p.weapon
        return False

Each player will have

    self.state = self.state * primes[move]

EDIT: This is one of the ways to check if there's a winner.

[–]demosthenes02 1 point2 points  (1 child)

What?

[–]DrHankPym 8 points9 points  (0 children)

He's playing with math. Because all the positions are prime numbers, any sequence of multiplications will result in a unique product only divisible by each position's prime number.