Complete MP5

This commit is contained in:
2022-11-27 17:11:02 -06:00
parent 52d6e079df
commit ae12b42c28
153 changed files with 1344 additions and 215 deletions

Binary file not shown.

View File

@@ -37,9 +37,9 @@
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.resultLabel = new System.Windows.Forms.Label();
this.newGameButton = new System.Windows.Forms.Button();
this.resetButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
@@ -49,7 +49,6 @@
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 56);
this.label1.TabIndex = 0;
this.label1.Text = "X";
//
// label2
//
@@ -58,7 +57,6 @@
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 56);
this.label2.TabIndex = 1;
this.label2.Text = "X";
//
// label3
//
@@ -67,7 +65,6 @@
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 56);
this.label3.TabIndex = 2;
this.label3.Text = "X";
//
// label4
//
@@ -76,7 +73,6 @@
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(53, 56);
this.label4.TabIndex = 5;
this.label4.Text = "X";
//
// label5
//
@@ -85,7 +81,6 @@
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(53, 56);
this.label5.TabIndex = 4;
this.label5.Text = "X";
//
// label6
//
@@ -94,7 +89,6 @@
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(53, 56);
this.label6.TabIndex = 3;
this.label6.Text = "X";
//
// label7
//
@@ -103,7 +97,6 @@
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(53, 56);
this.label7.TabIndex = 8;
this.label7.Text = "X";
//
// label8
//
@@ -112,7 +105,6 @@
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(53, 56);
this.label8.TabIndex = 7;
this.label8.Text = "X";
//
// label9
//
@@ -121,46 +113,45 @@
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(53, 56);
this.label9.TabIndex = 6;
this.label9.Text = "X";
//
// label10
// resultLabel
//
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 32.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label10.Location = new System.Drawing.Point(12, 254);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(297, 50);
this.label10.TabIndex = 9;
this.label10.Text = "Result";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label10.Click += new System.EventHandler(this.label10_Click);
this.resultLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 32.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.resultLabel.Location = new System.Drawing.Point(12, 254);
this.resultLabel.Name = "resultLabel";
this.resultLabel.Size = new System.Drawing.Size(297, 50);
this.resultLabel.TabIndex = 9;
this.resultLabel.Text = "Result";
this.resultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
// newGameButton
//
this.button1.Location = new System.Drawing.Point(87, 338);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 30);
this.button1.TabIndex = 10;
this.button1.Text = "New Game";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
this.newGameButton.Location = new System.Drawing.Point(87, 338);
this.newGameButton.Name = "newGameButton";
this.newGameButton.Size = new System.Drawing.Size(75, 30);
this.newGameButton.TabIndex = 10;
this.newGameButton.Text = "New Game";
this.newGameButton.UseVisualStyleBackColor = true;
this.newGameButton.Click += new System.EventHandler(this.newGameButton_Click);
//
// button2
// resetButton
//
this.button2.Location = new System.Drawing.Point(168, 338);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 30);
this.button2.TabIndex = 11;
this.button2.Text = "Reset";
this.button2.UseVisualStyleBackColor = true;
this.resetButton.Location = new System.Drawing.Point(168, 338);
this.resetButton.Name = "resetButton";
this.resetButton.Size = new System.Drawing.Size(75, 30);
this.resetButton.TabIndex = 11;
this.resetButton.Text = "Reset";
this.resetButton.UseVisualStyleBackColor = true;
this.resetButton.Click += new System.EventHandler(this.resetButton_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(321, 412);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label10);
this.Controls.Add(this.resetButton);
this.Controls.Add(this.newGameButton);
this.Controls.Add(this.resultLabel);
this.Controls.Add(this.label7);
this.Controls.Add(this.label8);
this.Controls.Add(this.label9);
@@ -187,9 +178,9 @@
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label resultLabel;
private System.Windows.Forms.Button newGameButton;
private System.Windows.Forms.Button resetButton;
}
}

View File

@@ -20,18 +20,35 @@ namespace TTT
InitializeComponent();
}
private void label10_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
private void newGameButton_Click(object sender, EventArgs e)
{
populateArray();
displayBoard();
//displayBoard();
while (determineWinner() == -1)
;//relaod table
{
//reload table
resultLabel.Text = "Undetermined";
populateArray();
}
if (determineWinner() == 0)
{
resultLabel.Text = "O Wins!";
}
else if (determineWinner() == 1)
{
resultLabel.Text = "X Wins!";
}
else if (determineWinner() == 2)
{
resultLabel.Text = "Draw";
}
else
{
resultLabel.Text = "Undetermined";
}
displayBoard();
}
void populateArray()
@@ -55,80 +72,170 @@ namespace TTT
int winsOfX = 0;
int winsOfO = 0;
if (this.board[0, 0] == 1 &&
this.board[0, 1] == 1 &&
this.board[0, 2] == 1)
//count all wins of X
// Wins on x axis
if (this.board[0, 0] == 1 &&
this.board[0, 1] == 1 &&
this.board[0, 2] == 1)
winsOfX++;
if (this.board[1, 0] == 1 &&
this.board[1, 1] == 1 &&
this.board[1, 2] == 1)
this.board[1, 1] == 1 &&
this.board[1, 2] == 1)
winsOfX++;
//count all wins of X
//count all the wins of 0
if (this.board[2, 0] == 1 &&
this.board[2, 1] == 1 &&
this.board[2, 2] == 1)
winsOfX++;
// Count all wins for O
//wins on y axis
if (this.board[0, 0] == 0 &&
this.board[1, 0] == 0 &&
this.board[2, 0] == 0)
winsOfO++;
if (this.board[0, 1] == 0 &&
this.board[1, 1] == 0 &&
this.board[2, 1] == 0)
winsOfO++;
if (winsOfX == 1 && winsOfO == 0)
;//x wins
if (this.board[0, 2] == 0 &&
this.board[1, 2] == 0 &&
this.board[2, 2] == 0)
winsOfO++;
if (this.board[0, 0] == 0 &&
this.board[0, 1] == 0 &&
this.board[0, 2] == 0)
winsOfO++;
if (this.board[1, 0] == 0 &&
this.board[1, 1] == 0 &&
this.board[1, 2] == 0)
winsOfO++;
if (this.board[2, 0] == 0 &&
this.board[2, 1] == 0 &&
this.board[2, 2] == 0)
winsOfO++;
//wins on y axis
if (this.board[0, 0] == 0 &&
this.board[1, 0] == 0 &&
this.board[2, 0] == 0)
winsOfO++;
if (this.board[0, 1] == 0 &&
this.board[1, 1] == 0 &&
this.board[2, 1] == 0)
winsOfO++;
if (this.board[0, 2] == 0 &&
this.board[1, 2] == 0 &&
this.board[2, 2] == 0)
winsOfO++;
if (winsOfX == 1 && winsOfO == 0) //x wins
{
return 1;
}
else if (winsOfX == 0 && winsOfO == 1) //o wins
{
return 0;
}
else if (winsOfX == 1 && winsOfO == 1) // Draw
{
return 2;
}
else // Invalid combination
{
return -1;
}
else if (winsOfX == 0 && winsOfO == 1)
;//o wins
else if (winsOfX == 1 && winsOfO == 1)
;//draw
else
;//invalid combination , rload the table with 0's and 1's
return 1;
}
void displayBoard()
void displayBoard()
{
if (board[0, 0] == 0)
label1.Text = "O";
else
else if(board[0, 0] == 1)
label1.Text = "X";
else
label1.Text = "";
if (board[0, 1] == 0)
label2.Text = "O";
else
else if (board[0,1] == 1)
label2.Text = "X";
else
label2.Text = "";
if (board[0, 2] == 0)
label3.Text = "O";
else
else if (board[0,2] == 1)
label3.Text = "X";
else
label3.Text = "";
if (board[1, 0] == 0)
label4.Text = "O";
else
else if (board[1,0] == 1)
label4.Text = "X";
else
label4.Text = "";
if (board[1, 1] == 0)
label5.Text = "O";
else
else if (board[1,1] == 1)
label5.Text = "X";
else
label5.Text = "";
if (board[1, 2] == 0)
label6.Text = "O";
else
else if (board[1,2] == 1)
label6.Text = "X";
else
label6.Text = "";
if (board[2, 0] == 0)
label7.Text = "O";
else
else if (board[2,0] == 1)
label7.Text = "X";
else
label7.Text = "";
if (board[2, 1] == 0)
label8.Text = "O";
else
else if (board[2,1] == 1)
label8.Text = "X";
else
label8.Text = "";
if (board[2, 2] == 0)
label9.Text = "O";
else
else if (board[2,2] == 1)
label9.Text = "X";
else
label9.Text = "";
}
private void resetButton_Click(object sender, EventArgs e)
{
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 3; y++)
board[x, y] = -1;
}
displayBoard();
resultLabel.Text = "";
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -8,3 +8,14 @@ C:\Users\athanasios.markou\source\repos\TTT\obj\Debug\TTT.csproj.GenerateResourc
C:\Users\athanasios.markou\source\repos\TTT\obj\Debug\TTT.csproj.CoreCompileInputs.cache
C:\Users\athanasios.markou\source\repos\TTT\obj\Debug\TTT.exe
C:\Users\athanasios.markou\source\repos\TTT\obj\Debug\TTT.pdb
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\bin\Debug\TTT.exe.config
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\bin\Debug\TTT.exe
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\bin\Debug\TTT.pdb
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.csproj.AssemblyReference.cache
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.csproj.SuggestedBindingRedirects.cache
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.Form1.resources
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.Properties.Resources.resources
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.csproj.GenerateResource.cache
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.csproj.CoreCompileInputs.cache
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.exe
Z:\home\caleb\Documents\ASDV-C-Sharp\MP5\TTT\obj\Debug\TTT.pdb

Binary file not shown.

Binary file not shown.