View Poll Results: How did you like the O/P Format of the Sudoku Board??
Very elaborate & impressive 45 54.22%
More could have been done 8 9.64%
Hav not run it yet 30 36.14%
Voters: 83. You may not vote on this poll
rai_gandalf's Avatar, Join Date: Nov 2005
Go4Expert Member
The GUI in this program is Text-mode based. It is Non-BGI. So, it isn't that very appealing to the eyes, yet reasonably user-friendly & elaborate to use. Download the code & read the documentation to understand the logic of the Text-based GUI of this program.

Ciao,
Rajiv

PS : BGI can be used to develop an actual Graphics interface that is detailed & developed, for this program.


"Don't take life too seriously; No one gets out alive."

Last edited by rai_gandalf; 15Mar2006 at 17:43..
wizardrycon's Avatar, Join Date: Jul 2006
Newbie Member
I have also been writing a Sudoku solving program but I have been using C# .NET.

When I clean up the objects that do the solve (it will solve a complete puzzle of mediumn complexity. I need to add other algorhythyms to solve for the harder level puzzles). I will post them on this thread for review/comments.

However in the mean time I need some help with my GUI object for this whole project.

I am pretty new to .NET programming and was hoping someone could tell me why this is not working right.

Any help you guys could give me would be greatly appreciated!!!

Source Notes: I am creating 9 panels which divide the main 9x9 grid into 9 smaller 3x3 grids (just like the Sudoku Puzzle). I am hoping by creating the GUI this way, it will be easier to implement the object connections to the actual cell data that will connected to each grid button.

I am also interested in making the buttons size dynamically depending on how big the form is. If anyone can point me in the right direction to do that I will try to implement that feature as well.

OUTPUT (Note only 1 panel paints the buttons, they all paint the same way and I can't for the life of me figure out why the other 8 panels are missing the buttons!!):



SOURCE:

Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace SudokuGridFormA
{
	public class SudokuGridForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Panel [,] panel = new Panel[3,3];
		private System.Windows.Forms.Button [,] GridBtn = new Button[9,9];
		private int TABINDEXNUM = 0;
		

		public SudokuGridForm()
		{
			InitializeComponent();
		}

		private int TABINDEX()
		{
			TABINDEXNUM++;
			return(TABINDEXNUM);
		}

		private void AddPanel(int panelNumX, int panelNumY, int x1, int x2, int y1, int y2)
		{
			this.panel[panelNumX,panelNumY].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

			for(int y=y1; y<=y2; y++)
				for(int x=x1; x<=x2; x++)
				{
					this.GridBtn[x,y] = new System.Windows.Forms.Button();
					this.panel[panelNumX,panelNumY].Controls.Add(this.GridBtn[x,y]);
				}

			this.panel[panelNumX,panelNumY].Location = new System.Drawing.Point(24+(panelNumX*96),32+(panelNumY*96));
			this.panel[panelNumX,panelNumY].Name = "panel" + panelNumX.ToString()+panelNumY.ToString();
			this.panel[panelNumX,panelNumY].Size = new System.Drawing.Size(96, 96);
			this.panel[panelNumX,panelNumY].TabIndex = TABINDEX();

			for(int y=y1; y<=y2; y++)
				for(int x=x1; x<=x2; x++)
				{
					this.GridBtn[x,y].Location = new System.Drawing.Point(0+(x*32), 0+(y*32));
					string BtnName = "GridBtn"+panelNumX.ToString()+panelNumY.ToString()+x.ToString()+y.ToString();
					this.GridBtn[x,y].Name = BtnName;
					this.GridBtn[x,y].Size = new System.Drawing.Size(32, 32);
					this.GridBtn[x,y].Text = panelNumX.ToString()+panelNumY.ToString()+x.ToString()+y.ToString();
					this.GridBtn[x,y].TabIndex = TABINDEX();
				}
		}

		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();

			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
				{
					this.panel[x,y] = new System.Windows.Forms.Panel();
					this.panel[x,y].SuspendLayout();
				}

			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
				this.groupBox1.Controls.Add(this.panel[x,y]);
			
			this.groupBox1.Location = new System.Drawing.Point(16, 24);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(336, 344);
			this.groupBox1.TabIndex = TABINDEX();
			this.groupBox1.TabStop = false;

			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
					AddPanel(x,y,x*3,2+(x*3),y*3,2+(y*3));			
			
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(368, 382);
			this.Controls.Add(this.groupBox1);
			this.Name = "SudokuGridForm";
			this.Text = "SudokuGridForm";
			this.groupBox1.ResumeLayout(false);
			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
					this.panel[x,y].ResumeLayout(false);
			this.ResumeLayout(false);
		}
	}
}
wizardrycon's Avatar, Join Date: Jul 2006
Newbie Member
Nevermind... It was an error in the positioning and not a painting error. I didn't reset it to 0,0 for each panel other than the first one.

Thanks for looking if you were trying to figure it out...
gamehunter101's Avatar, Join Date: Jun 2006
Go4Expert Member
Good work man
anshul gupta's Avatar, Join Date: Aug 2006
Newbie Member
hi rai
even i have worked on a sudoku generator but my basic problem is the time that the problem takes to generate a sudoku.
the logic behind the problem is pretty simple and it is not recurssive in nature .
its like fitting in a solution rather than generatin it.
i will like to take a look at ur basic strategy behind the problem...
plz u can mail me at anshulgolu123@gmail.com
anshul gupta's Avatar, Join Date: Aug 2006
Newbie Member
by the way excellent work man.....
BlasterBlang's Avatar, Join Date: Nov 2006
Go4Expert Member
thanks
durgaprasad's Avatar
Newbie Member
good work gandalf
durgaprasad's Avatar
Newbie Member
mr.gandalf irequest u to write a program in c that allows the user to play tic tac toe with computer
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by durgaprasad
mr.gandalf irequest u to write a program in c that allows the user to play tic tac toe with computer
Why do you want him to write for you when we already have couple of threads having the same.

Tic-Tac-Toe Game in C
TicTacToe in Plain C without using BGI graphics

Also dont jump into some article with your query. Instead try giving your query a new thread with good title to get good responses.