LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LED sous quadrillage

Solved!
Go to solution

Bonjour, je programme un jeu sur labview qui est un morpion suprême 9 morpions, le but du jeu est le suivant: quand un joueur joue dans une case X, le joueur adversaire doit jouer dans le morpion X ... le premier à aligner 3 symboles dans n'importe lequel des morpions gagne. 

Ma question est la suivante, je veux que lorsque c'est le tour d'un joueur, le morpion 3x3 dans lequel il doit jouer s'allume et quand le joueur click dedans il s'éteigne et le joueur adversaire joue dans son morpion allumé. 

Pour cela j'ai essayé de prendre des booléens led (9) que j'ai mis sur mes 9 grand morpions . et j'ai créer un build array des 9 booléens en locale variable que j'envoie dans une boucle for et je compare les coordonnées que j'envoie à mon adversaires ( exemple il doit jouer dans le morpions 4 ) avec le "i" de la boucle for si c'est true alors il faut éclairer le morpion 4 et quand il aura jouer l'éteindre après .

Je ne parviens pas à savoir comment faire pour que le TRUE s'applique au morpion voulu et que celui ci s'éteigne après ? 

Enfin c'est peut etre évident mais comme c'est des led booléennes, elles sont au dessus de mes décorations et de mon quadrillages donc je veux les passer derrière pour que le morpions s'allulmes juste par derrière.

 

Voila mes questions, merci pour retour si quelqu'un sait comment faire 🙂 

0 Kudos
Message 1 of 9
(342 Views)

Attaching your simple VI would describe much better what you are doing and where the problems are. Words alone are too ambiguous in any language.

 

In any case, I would recommend an array of picture rings. For some ideas, have a look at my old 4x4 version.

 

altenbach_0-1779474473182.png

 

0 Kudos
Message 2 of 9
(320 Views)

LOLO_0-1779520440204.png

LOLO_1-1779520488621.png

Bonjour, voila des images de mon labview, ce que j'essaye de faire donc, c'est deja mettre les leds carrées en arrière plan de mon quadrillage de jeu pour que il s'éclaire par dessous. et enfin je ne vois pas comment relier mon test d'égalité dans la boucle for, à ma variable locale concernée pour qu'elle s'allume et une fois le joueur ayant clické dedans, et que elle s'éteigne après. ( les booléens à droite je ne sais pas trop quoi en faire car j'en ai pas besoin normalement je ne vois pas à quoi les relier).

Merci d'avance ! 

 

0 Kudos
Message 3 of 9
(283 Views)

J'ai mis en pièce jointe le serveur.vi pour jouer ( je n'ai pas encore fais de conditions de victoires) pour gagner il faut 3 pions alignés dans 1 des 9 morpions, ca me parait assez compliqué à faire. 

 

Le serveur test.vi est celui ou j'essaye de faire allumé le quadrillage ou le joueur doit jouer.

Download All
0 Kudos
Message 4 of 9
(278 Views)

Many here cannot open code saved in LabVIEW 2025. Please do a "save for previous" (LabVIEW 2020 or below).

0 Kudos
Message 5 of 9
(249 Views)

Bonjour, voici mon programme enregistré sous différentes versions.

J'ai enregistré le test de la version 2018 à 2021 et le serveur classique, la version 2020 et 2019

0 Kudos
Message 6 of 9
(215 Views)

It is very confusing to attach VIs that have different versions, but having the same name. How can we tell what's what?

(If I do a "download all", I only get one each and the version is random).

 

Sorry, my monitor is not really big enough to debug that oversized code. What is the difference between serveur and serveur_test?

Why are two of the booleans in serveur_test controls while most are indicators? How are we supposed to run and operate it and what should happen? It would seem much simpler to use a 2D array of booleans (you can make the container transparent!). 9x less places for bugs to hide. Most of your outer sequence structures have no purpose at all.

 

What's on the other side of the TCP connection?

0 Kudos
Message 7 of 9
(196 Views)
Solution
Accepted by LOLO

Translated from French:

 

Hello, I'm programming a game in LabVIEW which is a 9-piece Supreme Tic-Tac-Toe game. The goal is as follows: when a player plays in square X, the opposing player must play in Tic-Tac-Toe X... the first player to align 3 symbols in any of the Tic-Tac-Toe boards wins.

 

My question is this: I want to implement a visual cue so that when it is a player's turn, the specific 3x3 board where they are required to play lights up. Once the player clicks inside that board to make their move, it should turn off, and the opposing player's designated board should then light up for their turn.

 

 To achieve this, I tried using nine Boolean LED controls, which I placed over my nine large Tic-Tac-Toe boards. I created a "Build Array" containing these nine Boolean values, stored it as a Local Variable, and passed it into a For Loop. Inside the loop, I compare the coordinates indicating the opponent's required move (for example, if they must play in board #4) against the loop's iteration index (*i*). If the condition evaluates to TRUE, the corresponding board (e.g., board #4) should light up; once the player has made their move, that board should subsequently turn off.

 

I am currently stuck on how to ensure that the TRUE state is applied specifically to the intended board, and—crucially—how to make that specific board turn off again *after* the player has made their move.

 

Finally—and this may be an obvious fix—since I am using Boolean LED controls, they currently appear *on top* of my background graphics and grid lines. I would like to send them to the back (behind the other elements) so that the "lighting up" effect appears to glow from *behind* the Tic-Tac-Toe board itself.

 

Thank you for providing your code.  There are multiple "problems" with it that make it difficult to evaluate (unless we make some effort to "clean it up" -- the Block Diagram looks like it requires about 25 "laptop screens" in a 5-by-5 grid arrangement to fit the code you submitted.  I got it down to almost fit in a single laptop screen by a combination of using the "Clean-up" tool (the "Broom" symbol on the Block Diagram Toolbar), and deleting most of the Frame Sequences (except for the pair within the While loop, which I left intact for now).

 

     Here are some ideas to consider:

  • One way to design a Tic-Tac-Toe Board is as a 3x3 Array of "TTT Square" (Tic-Tac-Toe Square), something that can take on 3 possible values -- <Blank> (not marked), "X" (marked with an X) or "O" (marked with an O).  The Board would be initialized to all "Blank".  Each Player can only select a blank Square, with Player 1's selection changing to "X", and Player 2's to "O".  Make this 3x3 Array into a Type Definition (TypeDef) called TYPE TTT Board (in French, of course).
  • For your game, you make a 3x3 Array of TTT Boards and create another TypeDef (I don't have a good name, maybe "Super TTT Board") that contains a TTT Board (defined above as a 3x3 Array of TTT Square) and a "Solution" code, <Blank>, "X", or "O" set after X or O makes a move in that board.
  • My friend Altenbach probably has a very nice algorithm to detect after X or O makes a move whether their move creates a Solution.  But you can just check each row (3 choices), each column (3 choices) and each diagonal (2 choices) for three X's or 3 O's.  If "Yes", then the "Solution" code is marked on the specific Super TTT Board.  If three such Boards have Solutions, the game ends with X (or O) the Winner.  If nobody can play (all squares filled without three "solved" Boards), nobody wins (when my mother taught me to play, we called this "The Cat wins").

Speaking of Altenbach, have you studied his code to see how he "chooses" which square X or O has chosen on his (or her) term?  [I must confess I have not studied it carefully ...]

 

Some suggestions that will help you in learning LabVIEW and developing clean code.

  • Try to keep your wires running horizontally left-to-right with as few bends as possible.
  • Data (wires) should (almost) always come in on the left and go out on the right, with as few bends as possible.
  • Structure your Data to fit the problem.  A Tic-Tac-Toe board has three rows and 3 columns, a 2D Array of "something".  If you call the "something" Blank, X, and O (I just thought of a name -- Cell Type), then a Board is a 3x3 Array of Cell Type.
  • Before building your Super Tic-Tac-Toe game, build (using the ideas above) the simple one-board game and get the bugs out.
  • I just realized when discussing the 3x3 Array of Boards, that the Solution code is wrong -- I forgot to add "C", for "Cat" (all squares chosen, but neither X or O has a win.
  • So now there are three "endings" -- X wins 3 Boards, Y wins 3 Boards, or the Cat wins enough Boards that neither X nor Y can win 3.

Thank you for a very entertaining "Super Tic-Tac-Toe" game idea.

 

Bob Schor

0 Kudos
Message 8 of 9
(177 Views)

Merci à vous pour votre retour.

je vais essayer d’appliquer tous les conseils que vous m’avez donné.

je vous remercie pour votre temps!

 

0 Kudos
Message 9 of 9
(140 Views)