Example Code

Connect Four game with support for custom A.I.

Code and Documents

Attachment

Download All

This is a LabVIEW version of game of Connect Four, with support for custom A.I. players.
The game is very simple, put 4 coins in a row, if you don't know it just try playing.

 

The main VI with game interface is Connect 4.vi. Here you can select the paths of A.I. player VIs, or leave them blank for human players.

One A.I. VI is provided, Snamprogetti.vi.

 

A.I. VIs are normal subVIs which calculate their best move for current state of game. A little coding challenge may be building your own A.I. that can beat people and other A.I.s.
See Example.vi for an example on how to build a custom A.I.
You can use Tournament.vi to run multiple A.I. vs A.I. games.

 

UPDATE: added a second A.I., extracted from another Connect Four implementation by Hekdude (http://decibel.ni.com/content/docs/DOC-15241). Later added a much smaller (possibly faster) version without stats and decorations.

F4.png

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Todd S.
NI Employee (retired)
on

Thanks for posting! This is great stuff!

Todd S.
LabVIEW Community Manager
National Instruments
Snamprogetti
Active Participant
Active Participant
on

A user told me that a subVI of the basic AI was missing, now I've updated the zip with the missing file. So the AI was not working for nearly 10 years? uuuuh...

Contributors