title: 2 in a row c# program game
body: <p>here is the <a href="http://s1119.beta.photobucket.com/user/arled/media/Untitled-4.jpg.html" rel="nofollow">game board</a> just to give you an idea of how it looks like (this board will be expanded to a 7x6)</p>
  
  <p>what i want to do is detect a winner when 2 colors are in a row similar to the game "conmect four" taking into account diagonal combos too. BUT i want to do this with out using brute-force enumeration..</p>
  
  <p>this the code that goes behind the program i have made I'm not asking for solution i just need a bit of help on an effective algorithm</p>
  
  <pre><code>namespace WindowsFormsApplication1
  {
      public partial class Form1 : Form
      {
  
          private Button[] btns;
          private Button[] btns2;
  
          public Form1()
          {
              InitializeComponent();
  
              btns = new Button[] { button2, button3 };
              btns2 = new Button[] { button4, button5 };
  
  
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
  
              foreach (var btn in btns)
              {
                  btn.Enabled = false;
                  btn.BackColor = Color.LightCyan;
              }
  
              foreach (var btn in btns2)
              {
                  btn.Enabled = false;
                  btn.BackColor = Color.LightCyan;
              }
          }
          public int state;
          int cc = 0;
          private void button1_Click(object sender, EventArgs e)
          {
              foreach (var btn in btns)
              {
                    {
                      if (!btn.Enabled)
                      {
                          btn.Enabled = true;
  
                          if (cc == 0)
                          {
                              cc = 1;
                              btn.BackColor = Color.Red;
                          }
                          else
                          {
                              cc = 0;
                              btn.BackColor = Color.Yellow;
                          }
                          return;
                      }
  
                  }
              }       
          }
  
          private void button6_Click(object sender, EventArgs e)
          {
              foreach (var btn in btns2)
              {
                  if (!btn.Enabled)
                  {
                      btn.Enabled = true;
  
                      if (cc == 0)
                      {
                          cc = 1;
                          btn.BackColor = Color.Red;
                      }
                      else
                      {
                          cc = 0;
                          btn.BackColor = Color.Yellow;
  
                      }
  
                      return;
                  }
              }
          }
      }
  }
  </code></pre>