I had several more complex AIs at one time, but here is the source for what I used for the challenge:

**Code:** ```
If N=1
```

Then

4->Y

Return

End

If N=2

Then

If 0=[A](1,3

Then

3->Y

Return

End

If 0=[A](1,5

Then

5->Y

Return

End

End

ClrList L1

7->dim(L1

[[3,4,5,7,5,4,3][4,6,7,10,7,6,4][5,8,11,13,11,8,5][5,8,11,13,11,8,5][4,6,7,10,7,6,4][3,4,5,7,5,4,3]]->[D]

[A]->[B]

1+(1=Z)->T

For(Y,1,7

1+Sigma(0!=[B](A,Y),A,1,6->H

If H<7

Then

[D](H,Y->L1(Y

Y->K

Z->P

prgmCAICHECK

If W

Return

T->P

prgmCAICHECK

If W

Return

If H<6

Then

H+1->H

prgmCAICHECK

If W

~100+L1(Y->L1(Y

Z->P

prgmCAICHECK

If W

~50->L1(Y

End

Else

~1000->L1(Y

End

End

max(L1->B

ClrList L2

For(A,1,7

If B=L1(A

A->L2(1+dim(L2

End

L2(randInt(1,dim(L2->Y

**Code:** ```
1->W
```

0->C

For(A,Y+1,7

If P=[B](H,A

Then

C+1->C

Else

8->A

End

End

For(A,Y-1,1,~1

If P=[B](H,A

Then

C+1->C

Else

0->A

End

End

C->L

If C>2

Return

0->C

For(A,H+1,6

If P=[B](A,Y

Then

C+1->C

Else

7->A

End

End

For(A,H-1,1,~1

If P=[B](A,Y

Then

C+1->C

Else

0->A

End

End

C+L->L

If C>2

Return

0->C

H->A

Y->B

While A<6 and B<7

A+1->A

B+1->B

If P=[B](A,B

Then

C+1->C

Else

7->A

End

End

H->A

Y->B

While A>1 and B>1

A-1->A

B-1->B

If P=[B](A,B

Then

C+1->C

Else

0->A

End

End

C+L->L

If C>2

Return

0->C

H->A

Y->B

While A<6 and B>1

A+1->A

B-1->B

If P=[B](A,B

Then

C+1->C

Else

7->A

End

End

H->A

Y->B

While A>1 and B<7

A-1->A

B+1->B

If P=[B](A,B

Then

C+1->C

Else

0->A

End

End

C+L->L

If C>2

Return

0->W

The basic strategy is:

▪Move in the center for the first move, or in column 3 for the second move (not necessarily the best)

▪Block any winning positions for the other player

▪Take any winning positions for the current player

▪Aggressively avoid moving in a column where the position above is a winning position for the other player

▪Avoid moving in a column where the position above is a winning position for the other player

▪Don't move in a filled column

▪Take the move where the most lines could be made (using the table)

▪Take the only possible move