Note that there are some explanatory texts on larger screens.

plurals
  1. PO2 in a row game in c#
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/o1gZs.jpg" alt="the board "></p> <p>above is the image of the board</p> <p>i am finding it hard to work out how to detect 2 color in a row to determine winner with out using brute-force enumeration..</p> <p>i have an algorithm and i have been trying to implement it but i cant seem to get it working would anyone know how to do this.. would be great help thanks..</p> <p>i want to detect winner diagonal vertical and horizontal..</p> <p>p.s i don't normally ask for solutions but this time i really need some help. many thanks</p> <p>here is the code that i have for the program that allows u to put the peaces</p> <pre><code>namespace WindowsFormsApplication1 { public partial class Form1 : Form { private Button[] btns; private Button[] btns2; private Button[] btns3; public Color[] col; // public var x; public Form1() { InitializeComponent(); btns = new Button[2] { button2, button3 }; btns2 = new Button[2] { button4, button5 }; btns3 = new Button[2] { button9, button8 }; col = new Color[2] { Color.Red, Color.Yellow }; Color x = col[0]; Color y = col[1]; } 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; } foreach (var btn in btns3) { 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 = col[0]; } else { cc = 0; btn.BackColor = col[1]; } 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 = col[0]; } else { cc = 0; btn.BackColor = col[1]; } return; } } } private void button7_Click(object sender, EventArgs e) { foreach (var btn in btns3) { if (!btn.Enabled) { btn.Enabled = true; if (cc == 0) { cc = 1; btn.BackColor = col[0]; } else { cc = 0; btn.BackColor = col[1]; } return; } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload