forked from lloydwindrim/connect4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_bot.py
More file actions
27 lines (18 loc) · 743 Bytes
/
Copy pathrandom_bot.py
File metadata and controls
27 lines (18 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
import useful_tools
def bot( gameState , round, playerID ):
# ---------------------------------------------------
# description:
# # randomly chooses a column to place token
# inputs:
# gameState ==> a copy of the current board (incl. tokens)
# round ==> the iteration number for the game (starting at 1)
# outputs:
# col ==> column location to place token (between 1 and boardSize)
# ---------------------------------------------------
[nRows , nCols] = np.shape( gameState )
while (1):
col = np.random.randint(nCols) + 1
if (useful_tools.isValid(col,nCols)) & (not useful_tools.isColumnFull(col,gameState)):
break
return col