Jump to content

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

Link to post
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.

Link to post
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!

Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

  • Similar Content

    • By Fred chen
      When I call the DLL, there is a structure:
      struct Signal { uint32 nStartBit; uint32 nLen; double nFactor; double nOffset; double nMin; double nMax; double nValue; uint64 nRawValue; bool is_signed; char unit[11]; char strName[66]; char strComment[201]; };  
      There is another  Message structure to the above Signal:
      struct Message { uint32 nSignalCount; uint32 nID; uint8 nExtend; uint32 nSize; Signal vSignals[513]; char strName[66]; char strComment[201]; }  
        The point is  Signal vSignals[513];
      I've tried to solve it like this,but the program will crash.
      How to create struct Message ,any good suggestions?  Thanks a lot.

    • By Taylorh140
      After working on the set cluster element by name xnode, it made me realize i could use the same concept to convert a variant array to a cluster. The technique is actually pretty simple, the xnode generates a case structure for each element in a cluster in cluster order, wherein a bundle by name is used to set the value and an unbundle by name is used to get the type, a variant to data is used to convert the data. This has some benefits over some methods, you are not limited to 255 elements, although that is not usually the case some of us are paranoid that clusterosaurus giganticous will be larger than expected. It also has a draw back  that is that when converting from a variant array all the elements must have unique, non-blank names, and this is usually the case. 

      I think this technique (though very brute-force) might be useful for some other things let me know what you guys think.

    • By Taylorh140
      This Xnode allows setting a cluster element by label string without using references. I pulled a great deal of inspiration from Hooovahhs Variant Array to cluster xnode, which i suppose this could be used for, another benefit is its not limited to 255 elements. Its mostly experimental because I haven't used it much. 

    • By liskped
      Im working on this prosjekt where I have a TCP communication between two computers (Server & Klient). I have managed to get communication between those two. (Sending and reciving one cluster.) But I want to send and recive more than one. I looked at det Topic "Passing Cluster and Datatype Through TCP" on how to use the OpenG, but I have a problem with "the Variant to Data". 
      What am I doing wrong? Or is there another way to send more data?
      The Klient side:

      The Server side: 

    • By Porter
      Is there any way to automatically wire an index array block to a bundle by name block?

      Auto-wire (pressing space) just adds one wire.
      Note that my cluster contains data of different types so converting the cluster to an array doesn't work.
      If there is a quick-drop shortcut for this I would be very impressed.
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.