MCPcopy Index your code
hub / github.com/python-websockets/websockets / play

Method play

example/tutorial/step3/connect4.py:40–62  ·  view source on GitHub ↗

Play a move in a column. Returns the row where the checker lands. Raises :exc:`ValueError` if the move is illegal.

(self, player, column)

Source from the content-addressed store, hash-verified

38 return any(b & b >> v & b >> 2 * v & b >> 3 * v for v in [1, 7, 8, 9])
39
40 def play(self, player, column):
41 """
42 Play a move in a column.
43
44 Returns the row where the checker lands.
45
46 Raises :exc:`ValueError` if the move is illegal.
47
48 """
49 if player == self.last_player:
50 raise ValueError("It isn't your turn.")
51
52 row = self.top[column]
53 if row == 6:
54 raise ValueError("This slot is full.")
55
56 self.moves.append((player, column, row))
57 self.top[column] += 1
58
59 if self.winner is None and self.last_player_won:
60 self.winner = self.last_player
61
62 return row

Callers 1

playFunction · 0.45

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected