Home c# How to write zolki crossbars over the network on C #?

How to write zolki crossbars over the network on C #?

Author

Date

Category

How to write noliki crossbars on the network on C #?
You need to use WinForms and Broadcast. So that on one PC could run two copies of the program and play. I do not quite understand the concept.


Answer 1, Authority 100%

Approximately such an algorithm I see (these are the highlights) you will need to come up with your communication protocol, I cite and clean for the example the easiest.

  1. Run two applications client a and b
  2. Each application at startup generates a unique ID and send a message “Hi I’m ready to play” + your unique ID (messages must be repeated with some periodicity, whatever the launched players have seen you on the network)
  3. Each running application receives such a message and displays potential partners for the game
  4. man with the app and chooses from the list of parterer b and tickle “play”
  5. Invitation message sent to the network “Hi I’m ready” + partner ID + your ID
  6. Again, everyone gets this message, but only that which the ID is indicated in the invitation respondents by the message “Play” + the partner ID + its ID (if at the moment the partner B has already turned off, it simply will not be an answer and the first client will not be the answer and deletes Its from the list)
  7. The game started, the client and makes the move and send to the client B wherever he set (for example, the cross) + partner ID + his ID (again these messages see everything but respond to it only a partner in his ID in the telephone message!) And so on ….

Google examples of working with UDP, how here


Answer 2

using system;
Using System.Collections.Genic;
Using System.Linq;
Using System.Text;
using system.threading.tasks;
Namespace ConsoleApp17
{
  Class Program
  {
    Static Void Main (String [] Args)
    {
      Console.WriteLine ("Start the game? (Yes / no)");
      String OtVet = Console.ReadLine ();
      While (otvet == "yes")
      {
        int oh = 1;
        int [,] b = new int [3, 3];
        Console.WriteLine ("Auxiliary Table:");
        for (int u = 0; u & lt; 3; u ++)
        {
          for (int i = 0; i & lt; 3; i ++)
          {
            b [u, i] = oh;
            Console.Write (B [U, i] + "");
            OH ++;
          }
          Console.Writeline ();
        }
        Console.Writeline ();
        String [,] a = new string [3, 3];
        for (int u = 0; u & lt; 3; u ++)
        {
          for (int i = 0; i & lt; 3; i ++)
          {
            a [u, i] = ".";
            Console.Write (A [U, I] + ");
          }
          Console.Writeline ();
        }
        While (otvet == "yes")
        {
          int s = convert.TOINT32 (Console.ReadLine ());
          if (s == 1)
          {
            a [0, 0] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (A [U, I] + ");
              }
              Console.Writeline ();
            }
          }
          if (s == 2)
          {
            a [0, 1] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (A [U, I] + ");
              }
              Console.Writeline ();
            }
          }
          if (s == 3)
          {
            a [0, 2] = "x";
            for (int u = 0; u & lt; 3; u ++) 
{
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (a [u, i] + "");
              }
              Console.WriteLine ();
            }
          }
          if (s == 4)
          {
            a [1, 0] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (a [u, i] + "");
              }
              Console.WriteLine ();
            }
          }
          if (s == 5)
          {
            a [1, 1] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (a [u, i] + "");
              }
              Console.WriteLine ();
            }
          }
          if (s == 6)
          {
            a [1, 2] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (a [u, i] + "");
              }
              Console.WriteLine ();
            }
          }
          if (s == 7)
          {
            a [2, 0] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (a [u, i] + "");
              }
              Console.WriteLine ();
            }
          }
          if (s == 8)
          {
            a [2, 1] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (a [u, i] + "");
              }
              Console.WriteLine ();
            }
          }
          if (s == 9)
          {
            a [2, 2] = "x";
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                Console.Write (a [u, i] + "");
              }
              Console.WriteLine ();
            }
          }
          if ("x" == a [0, 0] & amp; & amp; "x" == a [1, 1] & amp; & amp; "x" == a [2, 2] || "x" == a [0, 2] & amp; & amp; "x" == a [1, 1] & amp; & amp; "x" == a [2, 0] || "x" == a [0, 0] & amp ; & amp; "x" == a [1, 0] & amp; & amp; "x" == a [2, 0] || "x" == a [0, 1] & amp; & amp; "x" = = a [1, 1] & amp; & amp; "x" == a [2, 1] || "x" == a [0, 2] & amp; & amp; "x" == a [1, 2] & amp; & amp; "x" == a [2, 2] || "x" == a [0, 0] & amp; & amp; "x" == a [0, 1] & amp; & amp; "x" == a [0, 2] || "x" == a [1, 0] & amp; & amp; "x" == a [1, 1] & amp; & amp; "x" == a [1, 2 ] || "x" == a [2, 0] & amp; & amp; "x" == a [2, 1] & amp; & amp; "x" == a [2, 2])
          {
            Console.WriteLine ("The cross won !!");
            Console.WriteLine ("Start over? (Yes / no)");
            otvet = Console.ReadLine ();
            oh = 1;
            Console.WriteLine ("Auxiliary table:");
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                b [u, i] = oh;
                Console.Write (b [u, i] + ""); 
OH ++;
              }
              Console.Writeline ();
            }
            Console.Writeline ();
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                a [u, i] = ".";
                Console.Write (A [U, I] + ");
              }
              Console.Writeline ();
            }
          }
          If ("."! = a [0] & amp; & amp; "."! = a [0, 1] & amp; & amp; ""! = a [0, 2] & amp; & amp; "." ! = a [1, 0] & amp; & amp; ""! = a [1, 1] & amp; & amp; "."! = a [1, 2] & amp; & amp; "."! = a [2 , 0] & amp; & amp; ""! = A [2, 1] & amp; & amp; "."! = A [2, 2])
          {
            Console.Writeline ("Draw !!!");
            Console.WriteLine ("Start anew? (Yes / no)");
            OtVet = Console.ReadLine ();
            OH = 1;
            Console.WriteLine ("Auxiliary Table:");
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                b [u, i] = oh;
                Console.Write (B [U, i] + "");
                OH ++;
              }
              Console.Writeline ();
            }
            Console.Writeline ();
            for (int u = 0; u & lt; 3; u ++)
            {
              for (int i = 0; i & lt; 3; i ++)
              {
                a [u, i] = ".";
                Console.Write (A [U, I] + ");
              }
              Console.Writeline ();
            }
          }
            Console.Writeline ();
            int ss = convert.TOINT32 (Console.ReadLine ());
            if (ss == 1)
            {
              a [0] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 2)
            {
              a [0, 1] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 3)
            {
              a [0, 2] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 4)
            {
              a [1, 0] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 5)
            { 
a [1, 1] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 6)
            {
              a [1, 2] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 7)
            {
              a [2, 0] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 8)
            {
              a [2, 1] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            if (ss == 9)
            {
              a [2, 2] = "o";
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            If ("O" == A [0, 0] & amp; & amp; "o" == A [1, 1] & amp; & amp; "o" == A [2, 2] || "O" == a [0, 2] & amp; & amp; "o" == A [1, 1] & amp; & amp; "o" == a [2, 0] || "o" == A [0] & amp ; & amp; "O" == A [1, 0] & amp; & amp; "o" == A [2, 0] || "O" == A [0, 1] & amp; & amp; "o" = = A [1, 1] & amp; & amp; "o" == A [2, 1] || "O" == A [0, 2] & amp; & amp; "o" == A [1, 2] & amp; & amp; "o" == A [2, 2] || "O" == A [0] & amp; & amp; "o" == a [0, 1] & amp; & amp; "o" == A [0, 2] || "o" == A [1, 0] & amp; & amp; "o" == A [1, 1] & amp; & amp; "o" == a [1, 2 ] || "O" == A [2, 0] & amp; & amp; "o" == A [2, 1] & amp; & amp; "o" == a [2, 2])
            {
              Console.WriteLine ("Nolik won !!");
              Console.WriteLine ("Start anew? (Yes / no)");
              OtVet = Console.ReadLine ();
              OH = 1;
              Console.WriteLine ("Auxiliary Table:");
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  b [u, i] = oh;
                  Console.Write (B [U, i] + "");
                  OH ++;
                }
                Console.Writeline ();
              }
              Console.Writeline ();
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  a [u, i] = ".";
                  Console.Write (A [U, I] + ");
                } 
Console.Writeline ();
              }
            }
            if (ss == s)
            {
              Console.WriteLine ("You are scorn!");
              Console.WriteLine ("Start anew? (Yes / no)");
              OtVet = Console.ReadLine ();
              OH = 1;
              Console.WriteLine ("Auxiliary Table:");
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  b [u, i] = oh;
                  Console.Write (B [U, i] + "");
                  OH ++;
                }
                Console.Writeline ();
              }
              Console.Writeline ();
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  a [u, i] = ".";
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
            If ("."! = a [0] & amp; & amp; "."! = a [0, 1] & amp; & amp; ""! = a [0, 2] & amp; & amp; "." ! = a [1, 0] & amp; & amp; ""! = a [1, 1] & amp; & amp; "."! = a [1, 2] & amp; & amp; "."! = a [2 , 0] & amp; & amp; ""! = A [2, 1] & amp; & amp; "."! = A [2, 2])
            {
              Console.Writeline ("Draw !!!");
              Console.WriteLine ("Start anew? (Yes / no)");
              OtVet = Console.ReadLine ();
              OH = 1;
              Console.WriteLine ("Auxiliary Table:");
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  b [u, i] = oh;
                  Console.Write (B [U, i] + "");
                  OH ++;
                }
                Console.Writeline ();
              }
              Console.Writeline ();
              for (int u = 0; u & lt; 3; u ++)
              {
                for (int i = 0; i & lt; 3; i ++)
                {
                  a [u, i] = ".";
                  Console.Write (A [U, I] + ");
                }
                Console.Writeline ();
              }
            }
          }
        }
      }
    }
  }

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions