New answers tagged board-game
0
Zsh + bc, 54 bytes
bc<<<$#1`tr a-z 02210313074020029000033739<<<${1///+}`
Try it online!
Pure Zsh, 55 bytes
<<<$[$#1`tr a-z 02210313074020029000033739<<<${1///+}`]
Try it online!
1
Python 3, 18 bytes
lambda a:a+a%2*2-1
Try it online!
This brilliant AI will always force a tie, and sometimes win if you let it.
The grid is numbered in a spiral, like so:
1 2 3
8 9 4
7 6 5
and the computer always goes first. For the first move, input "10". This is a little redundant because it always goes in the same place, but it's already ...
0
Python 3: 341 bytes
So, my first attempt of code golfing, nice challenge! I thought of something similar myself with a complete game in mind though. Here is the AI code:
def e(b,t):return any([b[i]==b[i+d]==b[i+2*d]==t for i,d in((0,1),(3,1),(6,1),(0,3),(1,3),(2,3),(0,4),(2,2))])
def n(b,t,d=8):
if e(b,t):return 0,1
if e(b,-t):return 0,-1
if all(...
Top 50 recent answers are included
Related Tags
board-game × 67code-golf × 52
game × 20
king-of-the-hill × 8
hexagonal-grid × 6
ascii-art × 5
kolmogorov-complexity × 5
decision-problem × 5
grid × 5
chess × 5
tic-tac-toe × 4
string × 3
code-challenge × 3
graph-theory × 3
fastest-code × 3
python × 3
go × 3
array-manipulation × 2
path-finding × 2
scrabble × 2
number × 1
sequence × 1
popularity-contest × 1
random × 1
matrix × 1