Skip to main content
1 of 11
Sp3000
  • 61.9k
  • 13
  • 115
  • 287

#Python 3, 408 bytes

def S(B):
 def F(r,c,i):j=J[r][c]==i;J[r][c]*=1-j;k=j and any([F(a,b,i)for a,b in N(r,c)]);return k|j
 J=[x[:]for x in B];T=range(20);N=lambda r,c:{(max(min(r+x//3-1,19),0),max(min(c+x%3-1+(x//3!=1)*r%2,19),0))for x in[0,1,3,5,6,7]}-{(r,c)};X=lambda r,c,x,y:x==B[r][c]and{y}<{B[a][b]for a,b in N(r,c)};return[round(sum(3*X(r,c,"C",i)+X(r,c,i,"W")+(i in B[r])/20+F(r,c,i)for r in T for c in T))for i in"1234"]

What a massive, massive three-liner. Still a lot more golfing to be done, but I'll come back to this a little later (will post explanation a little later too).

Uses scores 1, 3, 7. Input is a list of lists of chars representing each cell. To test the example board easily, we can do:

board = """
3 3 W . . . 4 . 4 . . 2 W . 4 . . 4 . 4
 3 M W W . 1 1 . . 4 2 W . 3 C 4 4 . . 4
3 M 2 2 W 1 1 1 T 3 2 W 4 3 . 1 4 . 4 .
 M M . W 2 2 . . . 2 2 W 3 . 1 1 1 . . .
. 4 M . W W 2 2 2 2 W W 3 . 1 4 . T . .
 . . . . . W W W W W . 3 C 1 . . 2 2 2 2
. T 1 1 1 1 . . 2 . . 4 . . . 2 2 M M M
 4 . W 4 . C 4 4 . . . . . . 2 M M M M M
. 4 W W . . . 4 M . . W . W . 2 2 2 M M
 . . . . . . . M M . . W W . . . . 2 M .
. . . 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 . 1
 M 3 3 . . . . . . . . 4 . T 2 . 2 4 1 .
M M . C . 4 . 4 . . . . . 1 2 4 2 1 1 .
 M . . 1 . 4 . . . . M M 1 2 . . 2 1 . .
. . . W 1 1 4 1 1 . . . 1 2 . . 2 W W W
 . . 1 1 W 1 T . 1 1 1 1 T . . 2 W . 4 .
. 1 1 W . 3 3 . . . . . . . . 2 W 4 C 3
 C 1 3 3 3 . 3 . 4 . 4 . 4 . . 2 W 1 1 M
4 3 3 4 . M 4 3 . . . . . . . 2 W . . .
 . . . 4 . M M 3 . . 4 4 . 4 . 2 W W . .
"""

board = [row.split() for row in board.strip().split("\n")]
print(S(board))

# [52, 46, 43, 62]
Sp3000
  • 61.9k
  • 13
  • 115
  • 287