# Replace Cluster Element

## Recommended Posts

I'm making a Tic Tac Toe game using a cluster of 9 picture rings to represent X, O, or a blank spot.  If I were to be doing a one player game vs the computer, is there a way I could make the computer make a move?  I've tried a few things, and none of them worked.  If you want to see the VI, which isn't finished nor cleaned up yet, I have it attached.  Thanks

Tic Tac Toe Game.zip

##### Share on other sites

Are you asking for an algorithm or how to create a system/architecture for getting an AI to make the next move?

In terms of the algorithm, given that there are only 9 boxes, you can basically predict the possible moves for several turns and give them scores.  eg if a particular combination leads to the player winning in 2 moves, that will get a low score where as if another combination can lead to the AI winning in 3 moves that gets a high score and so on.  And the AI can go through every possible combination and score each one accordingly, then pick the path with the highest score.  If you then want to have an computer with Hard/Medium/Easy game, you can get the AI to chose Higher or Lower score moves respectively.

just some thoughts...

Its an interesting project.  well done.

##### Share on other sites

First off, neil, fantastic xkcd haha.  And curiouspuya, I'm not really looking for an algorithm actually.  That was my first thought, but I'm not skilled enough yet in LabVIEW to work with them just yet.  I was more along the lines trying to use Random Number In Range (OpenG) to pick a number 0 through 9 for an index of sorts (as you see, I converted my cluster to a 1D Array) and start at the nearest integer to search for an open spot.  In this case, an open spot would be a picture ring value of 0.  If the player is X, and the open spot is available, the computer would place an O.  Vice versa applies.  So, is there anyway I can do basically what I just described using clusters?  Also, thank you for your compliment!

##### Share on other sites

I figured it out!  If you want to see the final product, I attached it.

Enjoy

Moderator Comment: It's been reported that there are missing VIs to this attachment.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×