GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Sep-2005, 06:30
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Knights Tour - Reloaded .


Hey guys.

Last night I was thinking about the Knight's tour thread.
I decided to write some code and try to solve the problem with the next approach :

I keep track of the places I already visited and avoid calling the recursion function "knight" if I recognize a pre-visited cell.
Now, when I print the board it seems that the function "legal" allows illegal moves, but I think that the illegal moves are created because of a logical bug I'm having (and I can't track).
I also add a function "print_visit" to display an error (probably the same logical error) I have. How could it be that any "visit[i][j]" gets a value other than 1 ?

Anyone notices the bug(s) ?

Here is my code :

CPP / C++ / C Code:
#include <stdlib.h>
#include <stdio.h>

#define n	8

int		legal	(int x,int y,int nx,int ny);
int		visited (int x,int y);
void	knight	(int x,int y,int count);
void	print_board();
void	print_visit();
int		init();

int path_found = 0;
int board[n][n];
int visit[n][n];

int main()
{
	(void)init();
	knight(0,0,1);
	print_board();
	print_visit();
}

//Checks if a move is legal (not taking board size into consideration).
int legal(int x,int y,int nx,int ny)
{
	int result = 0;
	if	(	((nx >= 0) && (ny >= 0))
		&&	(((nx == x-2)	&& (ny == y-1))
		||	((nx == x-2)	&& (ny == y+1))
		||	((nx == x-1)	&& (ny == y-2))
		||	((nx == x-1)	&& (ny == y+2))
		||	((nx == x+1)	&& (ny == y-2))
		||	((nx == x+1)	&& (ny == y+2))
		||	((nx == x+2)	&& (ny == y-1))
		||	((nx == x+2)	&& (ny == y+1))))
		result = 1;
	return (result);
}

int visited (int x,int y)
{
	int result = visit[x][y];
	return (result); 
}

int init()
{
	int i,j;
	for (i=0;i<n;i++)
		for (j=0;j<n;j++)
		{
			board[i][j] = 0;
			visit[i][j] = 0;
		}
	return (0);
}

void knight(int x,int y,int count)
{
	board[x][y] = count;
	visit[x][y] = 1;
	if (count == n*n)
		path_found = 1;
	if (path_found)
		return;
	else
	{
		if (legal(x,y,x-2,y-1) && visit[x-2][y-1] == 0)
			knight(x-2,y-1,count+1);
		if (legal(x,y,x-2,y+1) && visit[x-2][y+1] == 0)
			knight(x-2,y+1,count+1);
		if (legal(x,y,x-1,y-2) && visit[x-1][y-2] == 0)
			knight(x-1,y-2,count+1);
		if (legal(x,y,x-1,y+2) && visit[x-1][y+2] == 0)
			knight(x-1,y+2,count+1);
		if (legal(x,y,x+1,y-2) && visit[x+1][y-2] == 0)
			knight(x+1,y-2,count+1);
		if (legal(x,y,x+1,y+2) && visit[x+1][y+2] == 0)
			knight(x+1,y+2,count+1);
		if (legal(x,y,x+2,y-1) && visit[x+2][y-1] == 0)
			knight(x+2,y-1,count+1);
		if (legal(x,y,x+2,y+1) && visit[x+2][y+1] == 0)
			knight(x+2,y+1,count+1);
	}
}

void	print_board()
{
	int i,j;
	for (i=0;i<n;i++)
	{
		printf("\n");
		for (j=0;j<n;j++)
			printf("%4d",board[i][j]);
	}
	printf("\n");
}

void	print_visit()
{
	int i,j;
	for (i=0;i<n;i++)
	{
		printf("\n");
		for (j=0;j<n;j++)
			printf("%4d",visit[i][j]);
	}
	printf("\n");
}

Oh, and yes, I use globals ...
I'll fix it when I track the problem.

Best Regards,
Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
  #2  
Old 28-Sep-2005, 10:11
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Knights Tour - Reloaded .


O.k , Here is one error :

I didn't check upper array bound ...

Here is the fixed start of the "if" statement :
CPP / C++ / C Code:
if	(	((nx >= 0) && (ny >= 0) && (nx <= n-1) && (ny <= n-1))

Now, I need to check the other bugs (like how come my app gives duplicate numbers to different cells.

Kobi.
__________________
It's actually a one time thing (it just happens alot).
  #3  
Old 28-Sep-2005, 18:45
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

The code so far.


At the end, I wish to repeat the test done a few years ago :
For each given dimension of the board, I will look for all the solutions available and store them in a linked list.

Here is the code for the knight's tour I have this far :
CPP / C++ / C Code:
#include <stdlib.h>
#include <stdio.h>

//These three functions where written by our senior member Dave ("davekw7x") and slightly edited
//Only in indentation and output format.
int	**allocate_int_array(int row, int col);
void	print_int_array(int **array, int row, int col);
void	deallocate_int_array(int **array, int row);

int	legal(int x,int y,int nx,int ny,int dimension);
void	knight(int x,int y,int count,int dimension,int **board,int **visited);


int main()
{

	int **board;
	int **visited;
	int dimension;
	int i,j;

	printf("Please Enter board dimension : ");
	scanf("%d",&dimension);

	board = allocate_int_array(dimension, dimension);
	if (!board) 
	{
		printf("allocate_int_array(%d, %d) failed\n", dimension, dimension);
		return 0;
	}

	visited = allocate_int_array(dimension, dimension);
	if (!visited) 
	{
		printf("allocate_int_array(%d, %d) failed\n", dimension, dimension);
		return 0;
	}

	//Init board and visited.
	for (i = 0; i < dimension; i++) 
	{
		for (j = 0 ;j < dimension; j++)
		{
			board[i][j] = 0;
			visited[i][j] = 0;
		}
	}

	knight(0,0,1,dimension,board,visited);

	print_int_array(board, dimension, dimension);

	deallocate_int_array(board,dimension);
	deallocate_int_array(visited,dimension);

	return 0;
}
      

int **allocate_int_array(int nrows, int ncolumns)
{
	int i, j;
	int **array = malloc(nrows * sizeof(int *));
	if (!array) 
	{
		printf("malloc nrows failed\n");
		return NULL;
	}
	for(i = 0; i < nrows; i++) 
	{
		array[i] = malloc(ncolumns * sizeof(int));
		if (!array[i]) 
		{
			printf("malloc ncolumns failed on row number %d\n", i);
			for (j = i-1; j>= 0; j--) 
			{
				free(array[j]);
			}
			free(array);
			return NULL;
		}
	}
	return array;
}


void deallocate_int_array(int **array, int nrows)
{
	int i;
	for (i = 0; i < nrows; i++) 
	{
		free(array[i]);
	}
	free(array);
}

void print_int_array(int **array, int nrows, int ncolumns)
{
	int i, j;
	for (i = 0; i < nrows; i++) 
	{
		printf("\n");
		for (j = 0; j < ncolumns; j++) 
		{
			printf("%5d", array[i][j]);
		}
		printf("\n");
	}
}

//Checks if a move is legal (not taking board size into consideration).
int legal(int x,int y,int nx,int ny,int dimension)
{
	int result = 0;
	if	(	((nx >= 0) && (ny >= 0) && (nx <= dimension-1) && (ny <= dimension-1))
		&&	(((nx == x-1)	&& (ny == y+2))
		||	((nx == x+1)	&& (ny == y+2))
		||	((nx == x-2)	&& (ny == y+1))
		||	((nx == x+2)	&& (ny == y+1))
		||	((nx == x-2)	&& (ny == y-1))
		||	((nx == x+2)	&& (ny == y-1))
		||	((nx == x-1)	&& (ny == y-2))
		||	((nx == x+1)	&& (ny == y-2))))
		result = 1;
	return (result);
}

void knight(int x,int y,int count,int dimension,int **board,int **visited)
{
	board[x][y] = count;
	visited[x][y] = 1;
	if (count == (dimension * dimension))
	{
		return;
	}
	else
	{
		if (legal(x,y,x-1,y+2,dimension) && visited[x-1][y+2] == 0)
		{
			knight(x-1,y+2,count+1,dimension,board,visited);
		}
		else 
		{
			if (legal(x,y,x+1,y+2,dimension) && visited[x+1][y+2] == 0)
			{
				knight(x+1,y+2,count+1,dimension,board,visited);
			}
			else 
			{
				if (legal(x,y,x-2,y+1,dimension) && visited[x-2][y+1] == 0)
				{
					knight(x-2,y+1,count+1,dimension,board,visited);
				}
				else 
				{	
					if (legal(x,y,x+2,y+1,dimension) && visited[x+2][y+1] == 0)
					{
						knight(x+2,y+1,count+1,dimension,board,visited);
					}
					else 
					{
						if (legal(x,y,x-2,y-1,dimension) && visited[x-2][y-1] == 0)
						{
							knight(x-2,y-1,count+1,dimension,board,visited);
						}
						else 
						{
							if (legal(x,y,x+2,y-1,dimension) && visited[x+2][y-1] == 0)
							{
								knight(x+2,y-1,count+1,dimension,board,visited);
							}
							else 
							{
								if (legal(x,y,x-1,y-2,dimension) && visited[x-1][y-2] == 0)
								{
									knight(x-1,y-2,count+1,dimension,board,visited);
								}
								else 
								{
									if (legal(x,y,x+1,y-2,dimension) && visited[x+1][y-2] == 0)
									{
										knight(x+1,y-2,count+1,dimension,board,visited);
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

This has to be debuged yet. I solved the problem of duality of "moves" that was with the pre posted code.You can see the differences in the flow control of the program.

Soon to be updated.
Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
Last edited by JdS : 29-Sep-2005 at 07:10. Reason: Please insert your C code between [c] & [/c] tags
  #4  
Old 30-Sep-2005, 14:08
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Knights Tour - Reloaded .


Hey guys.
I see I'm the only one interested in this little puzzle.
I promised my code and here it is (Dave supplied the skeleton for some of the code - Thanks alot.):

CPP / C++ / C Code:
#include <stdlib.h>
#include <stdio.h>

int		**allocate_int_array(unsigned rows,unsigned columns);
void	init_int_array(int **the_array,unsigned rows,unsigned columns,int value);
void	deallocate_int_array(int **array, unsigned rows);
void	print_int_array(int **array, unsigned rows, unsigned columns);
int		is_legal_move(unsigned x,unsigned y,unsigned new_x,unsigned new_y,unsigned rows,unsigned columns);
int		knight(int **board,unsigned x,unsigned y,unsigned rows,unsigned columns,unsigned count);

int main()
{
	unsigned	rows,columns;
	int			**board;
	printf	("Please enter number of rows and number of columns :");
	scanf	("%u %u",&rows,&columns);
	printf	("Creating %ux%u dimension array ... ",rows,columns);
	board = allocate_int_array(rows,columns);
	if (board != NULL)
		printf ("Done.\n");
	else
	{
		printf ("Failed.\n");
		return (0);
	}


	//Test area.
	


	//

	init_int_array(board,rows,columns,0);
	knight(board,0,0,rows,columns,1);
	return (1);
}

int **allocate_int_array(unsigned rows,unsigned columns)
{
	unsigned i, j;
	int **array = malloc(rows * sizeof(int *));
	if (array == NULL) 
	{
		return (NULL);
	}
	for(i = 0; i < rows; i++) 
	{
		array[i] = malloc(columns * sizeof(int));
		if (array[i] == NULL) 
		{
			for (j = i-1; j>= 0; j--) 
			{
				free(array[j]);
			}
			free(array);
			return (NULL);
		}
	}
	return (array);
}

void	init_int_array(int **the_array,unsigned rows,unsigned columns,int value)
{
	unsigned i,j;
	for (i = 0;i < rows; i++)
		for (j = 0; j < columns; j++)
			the_array[i][j] = value;
}
void deallocate_int_array(int **array, unsigned rows)
{
	unsigned i;
	for (i = 0; i < rows; i++) 
	{
		free(array[i]);
	}
	free(array);
}

void print_int_array(int **array, unsigned rows, unsigned columns)
{
	unsigned i, j;
	for (i = 0; i < rows; i++) 
	{
		printf("\n");
		for (j = 0; j < columns; j++) 
		{
			printf("%5d", array[i][j]);
		}
		printf("\n");
	}
}

int		is_legal_move(unsigned x,unsigned y,unsigned new_x,unsigned new_y,unsigned rows,unsigned columns)
{
	int result = 0;
	if (
			((new_x <= rows - 1) && (new_x >= 0) && (new_y <= columns - 1) && (new_y >= 0)) 
			&&	(			((new_x == x-1)	&& (new_y == y+2))
					||		((new_x == x+1)	&& (new_y == y+2))
					||		((new_x == x-2)	&& (new_y == y+1))
					||		((new_x == x+2)	&& (new_y == y+1))
					||		((new_x == x-2)	&& (new_y == y-1))
					||		((new_x == x+2)	&& (new_y == y-1))
					||		((new_x == x-1)	&& (new_y == y-2))
					||		((new_x == x+1)	&& (new_y == y-2))
				)
		)
			result = 1;
	return (result);
}

int		knight(int **board,unsigned x,unsigned y,unsigned rows,unsigned columns,unsigned count)
{
	board[x][y] = count;
	if (count == rows * columns)
	{
		//We found A solution.
		printf ("A solution was found :\n");
		print_int_array(board,rows,columns);
		return (1);
	}
	else
	{
			//Some moves are possible.
			if ((is_legal_move(x,y,x-1,y+2,rows,columns) && board[x-1][y+2] == 0))
			{
				knight(board,x-1,y+2,rows,columns,count + 1);
				board[x-1][y+2] = 0;
			}

			if ((is_legal_move(x,y,x+1,y+2,rows,columns) && board[x+1][y+2] == 0))
			{
				knight(board,x+1,y+2,rows,columns,count + 1);
				board[x+1][y+2] = 0;
			}

			if ((is_legal_move(x,y,x-2,y+1,rows,columns) && board[x-2][y+1] == 0))
			{
				knight(board,x-2,y+1,rows,columns,count + 1);
				board[x-2][y+1] = 0;
			}

			if ((is_legal_move(x,y,x+2,y+1,rows,columns) && board[x+2][y+1] == 0))
			{
				knight(board,x+2,y+1,rows,columns,count + 1);
				board[x+2][y+1] = 0;
			}

			if ((is_legal_move(x,y,x-2,y-1,rows,columns) && board[x-2][y-1] == 0))
			{
				knight(board,x-2,y-1,rows,columns,count + 1);
				board[x-2][y-1] = 0;
			}

			if ((is_legal_move(x,y,x+2,y-1,rows,columns) && board[x+2][y-1] == 0))
			{
				knight(board,x+2,y-1,rows,columns,count + 1);
				board[x+2][y-1] = 0;
			}

			if ((is_legal_move(x,y,x-1,y-2,rows,columns) && board[x-1][y-2] == 0))
			{
				knight(board,x-1,y-2,rows,columns,count + 1);
				board[x-1][y-2] = 0;
			}

			if ((is_legal_move(x,y,x+1,y-2,rows,columns) && board[x+1][y-2] == 0))
			{
				knight(board,x+1,y-2,rows,columns,count + 1);
				board[x+1][y-2] = 0;
			}
	}

	return (1);
}

Currently, All the solutions are being found.
I'm working on checking the solutions ...

Shabat shalom to you all.
Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
  #5  
Old 01-Oct-2005, 09:09
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Knights Tour - Reloaded .


Hey guys.

Sorry if I'm boring you. Somehow, this knight's tour problem caught me and I had to implement a solution.
Here is the final code I'll post about this.
Try it if you wish, I think it's interesting.

CPP / C++ / C Code:
//Filename	:	knight.c
//Writen by	:	Kobi Hikri.
//Release date	:	01/10/2005

// This application searches for All the Knight tour's available within a given grid.

// mathworld.wolfram.com : "A knight's tour of a chessboard (or any other grid) 
// is a sequence of moves (i.e., a tour) by a knight chess piece 
// (which may only make moves which simultaneously shift one square along one 
// axis and two along the other) such that each square of the board is visited 
// exactly once (i.e., a Hamiltonian path)."
 

#include <stdlib.h>
#include <stdio.h>

int	**allocate_int_array(unsigned rows,unsigned columns);
void	init_int_array(int **the_array,unsigned rows,unsigned columns,int value);
void	deallocate_int_array(int **array, unsigned rows);
void	print_int_array(int **array, unsigned rows, unsigned columns);
int	is_legal_move(unsigned x,unsigned y,unsigned new_x,unsigned new_y,unsigned rows,unsigned columns);
int	knight(int **board,unsigned x,unsigned y,unsigned rows,unsigned columns,unsigned count,int *recursion_counter);

int main()
{
	unsigned	rows,columns;
	int			recursion_counter;
	int			**board;
	printf	("Please enter number of rows and number of columns :");
	scanf	("%u %u",&rows,&columns);
	printf	("Creating %ux%u dimension array	... ",rows,columns);
	board = allocate_int_array(rows,columns);
	if (board != NULL)
		printf ("Done.\n");
	else
	{
		printf ("Failed.\n");
		return (0);
	}

	recursion_counter = 0;
	printf	("Initializing board	... "); 
	init_int_array(board,rows,columns,0);
	printf	("Done.\n");
	knight(board,0,0,rows,columns,1,&recursion_counter);
	deallocate_int_array(board,rows);
	return (1);
}

int **allocate_int_array(unsigned rows,unsigned columns)
{
	unsigned i, j;
	int **array = malloc(rows * sizeof(int *));
	if (array == NULL) 
	{
		return (NULL);
	}
	for(i = 0; i < rows; i++) 
	{
		array[i] = malloc(columns * sizeof(int));
		if (array[i] == NULL) 
		{
			for (j = i-1; j>= 0; j--) 
			{
				free(array[j]);
			}
			free(array);
			return (NULL);
		}
	}
	return (array);
}

void	init_int_array(int **the_array,unsigned rows,unsigned columns,int value)
{
	unsigned i,j;
	for (i = 0;i < rows; i++)
		for (j = 0; j < columns; j++)
			the_array[i][j] = value;
}
void deallocate_int_array(int **array, unsigned rows)
{
	unsigned i;
	for (i = 0; i < rows; i++) 
	{
		free(array[i]);
	}
	free(array);
}

void print_int_array(int **array, unsigned rows, unsigned columns)
{
	unsigned i, j;
	for (i = 0; i < rows; i++) 
	{
		printf("\n");
		for (j = 0; j < columns; j++) 
		{
			printf("%5d", array[i][j]);
		}
		printf("\n");
	}
}

int	is_legal_move(unsigned x,unsigned y,unsigned new_x,unsigned new_y,unsigned rows,unsigned columns)
{
	int result = 0;
	if (
			((new_x <= rows - 1) && (new_x >= 0) && (new_y <= columns - 1) && (new_y >= 0)) 
			&&	(			((new_x == x-1)	&& (new_y == y+2))
					||		((new_x == x+1)	&& (new_y == y+2))
					||		((new_x == x-2)	&& (new_y == y+1))
					||		((new_x == x+2)	&& (new_y == y+1))
					||		((new_x == x-2)	&& (new_y == y-1))
					||		((new_x == x+2)	&& (new_y == y-1))
					||		((new_x == x-1)	&& (new_y == y-2))
					||		((new_x == x+1)	&& (new_y == y-2))
				)
		)
			result = 1;
	return (result);
}

int	knight(int **board,unsigned x,unsigned y,unsigned rows,unsigned columns,unsigned count,int *recursion_counter)
{
	(*recursion_counter)++;
	printf("Recursion # : %d \n",*recursion_counter);
	board[x][y] = count;
	if (count == rows * columns)
	{
		//We found A solution.
		printf ("A solution was found :\n");
		print_int_array(board,rows,columns);
		(void)getchar();
		return (1);
	}
	else
	{
			//Some moves are possible.
			if ((is_legal_move(x,y,x-1,y+2,rows,columns) && board[x-1][y+2] == 0))
			{
				knight(board,x-1,y+2,rows,columns,count + 1,recursion_counter);
				board[x-1][y+2] = 0;
			}

			if ((is_legal_move(x,y,x+1,y+2,rows,columns) && board[x+1][y+2] == 0))
			{
				knight(board,x+1,y+2,rows,columns,count + 1,recursion_counter);
				board[x+1][y+2] = 0;
			}

			if ((is_legal_move(x,y,x-2,y+1,rows,columns) && board[x-2][y+1] == 0))
			{
				knight(board,x-2,y+1,rows,columns,count + 1,recursion_counter);
				board[x-2][y+1] = 0;
			}

			if ((is_legal_move(x,y,x+2,y+1,rows,columns) && board[x+2][y+1] == 0))
			{
				knight(board,x+2,y+1,rows,columns,count + 1,recursion_counter);
				board[x+2][y+1] = 0;
			}

			if ((is_legal_move(x,y,x-2,y-1,rows,columns) && board[x-2][y-1] == 0))
			{
				knight(board,x-2,y-1,rows,columns,count + 1,recursion_counter);
				board[x-2][y-1] = 0;
			}

			if ((is_legal_move(x,y,x+2,y-1,rows,columns) && board[x+2][y-1] == 0))
			{
				knight(board,x+2,y-1,rows,columns,count + 1,recursion_counter);
				board[x+2][y-1] = 0;
			}

			if ((is_legal_move(x,y,x-1,y-2,rows,columns) && board[x-1][y-2] == 0))
			{
				knight(board,x-1,y-2,rows,columns,count + 1,recursion_counter);
				board[x-1][y-2] = 0;
			}

			if ((is_legal_move(x,y,x+1,y-2,rows,columns) && board[x+1][y-2] == 0))
			{
				knight(board,x+1,y-2,rows,columns,count + 1,recursion_counter);
				board[x+1][y-2] = 0;
			}
	}

	return (1);
}

Best regards,
Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
  #6  
Old 01-Oct-2005, 10:58
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,160
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Knights Tour - Reloaded .


Quote:
Originally Posted by kobi_hikri
Hey guys.

Sorry if I'm boring you.

The topic of using a simple recursive implementation to investigate a centuries-old problem is not boring to me, and I appreciate your efforts. (I haven't actually tried to run your code.)

How the heck did those guys a couple of hundred years ago (or even more ancient) come up with all of those solutions that you can find by browsing the web?

How about giving us a little information about the sizes of boards for which you have data. Summary of results, run time (on what system?), etc.

Regards,

Dave
  #7  
Old 01-Oct-2005, 11:30
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Florina, Greece
Posts: 1,112
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Knights Tour - Reloaded .


Quote:
Originally Posted by kobi_hikri
Sorry if I'm boring you. Somehow, this knight's tour problem caught me...

I started a reply to this earlier today but got sidetracked. It essentially echoed Dave's sentiment. Effort such as yours is exactly what I find so interesting about this forum. Perhaps I can shed some light on what I have found in the short time I have been here.

As you well know by now, the bulk of the posts are requests for help with a particular task. Some are well thought out, some, well, not so much. Some try to learn the rules of the road (at least our short list from the Guidelines Thread) and others come in like a blown 454 jammed in a heavy hunk of Detroit Iron entered into a pickup demolition derby match. In my humble opinion, adding to the colorfulness of it all.

It would be my guess based on my own experience that many a person has read your thread and perhaps even learned a bit from it. I know I have, so you can take that one to the bank. The fun part is, since you were not actually asking for help, the response on this type of post is minimal. Take it as a complement. You stated your goals, posted a handfull of posts with code, and found an endpoint. Your last post compiled fine for me with my CygWin gcc and the -Wall option. It ran and gave results for me with various board sizes. I had to quit out of my attempt at a 7x7 board, it was pegging my processor for about a half hour and reached a pair of millions and a half on the recursion counter. No reason for my quitting except I had other things to convince my processor to do this fine morning.

Bored, not even close. I say Thank You and keep them coming. Good examples that compile cleanly are EXACTLY what we seem to strive for here. Interesting, "You bet your Bippy!"
__________________

"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs

Stories from the NICU Blog
  #8  
Old 01-Oct-2005, 12:25
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Knights Tour - Reloaded .


Quote:
Originally Posted by davekw7x
How about giving us a little information about the sizes of boards for which you have data. Summary of results, run time (on what system?), etc.

I will summarize my results soon (how did you know I was doing that ? ),
As my compulsive character drives me to.
It will take a few days ...

Thanks again for your guidance with some issues (don't be so humble, Dave ).
Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
  #9  
Old 01-Oct-2005, 12:29
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Knights Tour - Reloaded .


Quote:
Originally Posted by cable_guy_67
Your last post compiled fine for me with my CygWin gcc and the -Wall option.

Hey Mark.

What is the Wall option ? I've read about CygWin earlier today (even tried to install two dll's I downloaded).

Thanks for your support, it is really important.
Kobi.
__________________
It's actually a one time thing (it just happens alot).
  #10  
Old 01-Oct-2005, 12:40
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Florina, Greece
Posts: 1,112
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Knights Tour - Reloaded .


Quote:
Originally Posted by kobi_hikri
What is the Wall option ? I've read about CygWin earlier today (even tried to install two dll's I downloaded).

As you most likely know, the number of switches available to get GCC to do your bidding is monsterous. One of the simpler is the level of error reporting that will be given. Using -Wall will enable warnings that you would not usually see. Things like declared but unused variables, "falling off the end" of functions that declare a return type, etc, etc.

For the curious, google ISBN 0954161793 for an open source book "An Introduction to GCC", it will give a good foundation for using the compiler from the command line.

Quote:
Originally Posted by kobi_hikri
Thanks for your support, it is really important.
Kobi.

You are most welcome, my mother used to tell us endlessly while we were young,
"If you don't have anything nice to say, don't say it."

Simple and to the point, kind of what we do around here. Inversely speaking, if you do, don't hesitate to open your pie hole. (she never said that, I just kind of picked it up along the way)

Mark
__________________

"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs

Stories from the NICU Blog
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free 1 GB Space PLESK RELOADED Reseller Account - Unmetered Bandwidth john_robot Free Web Hosting 2 02-Oct-2005 23:09
knight tour (chess program) kai85 C++ Forum 10 25-Mar-2005 07:12
Knight tour (arrays help needed) dilmv C++ Forum 7 18-Oct-2004 14:31
Robs World Tour jrobbio Open Discussion Forum 3 29-Mar-2004 23:04

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:33.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.