|
There are a couple of ways to randomise it:
1) Insert each piece of the puzzle at a random location on the board, by using the random number generator to specify the location. This is quick to generate, but as Harold says, it can generate puzzles that can't be solved - you need a post-processing step to ensure that it can.
2) Use the random number generator to generate a direction, and move the pieces that way, exactly as if the user had done so. You then repeat this a number of times to "scramble" the puzzle. This is slower to generate, but the result is always solvable, and it means that a "difficulty level" can be added very simply by changing the number of times the random move is implemented.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I thought about that second method, but concluded that I couldn't guarantee anything about how random the result would be, so I decided against recommending it.
It could be faster though, the way I mentioned has a probability of 0.5 at every step to terminate, you could have bad luck.
|
|
|
|
|
It generally works out pretty random: since at any stage you will have 4, 3, or two possible moves (depending on where the hole is in respect of the edges) it's a pretty simple matter to "ban" the move which reverses the previous one. That does give good randomness in practice - it's down to how many iterations you go for.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I suppose so, but I had to think of that argument for why the "swap any two random elements n times" algorithm doesn't shuffle an array correctly - some configurations have more paths to them than others, so they get chosen too often.
I'm not sure that isn't the case here.
|
|
|
|
|
I was able to solve it using a timer that randomly click the movable button in 5 second and it worked.
Thank you very much for the help guys.
|
|
|
|
|
I have the following questions in regards to to placing a 'gui' interface on the top of a C# 2008 application so users can enter data.
1. I would like to know if it would be better to add a desktop form for an asp.net web forms page to the application? I would like to know what is better and why.
2. In addition, the two project files that are windows form apps currently, I would Like to know if I should make those web form projects, leave the project types alone, and/or what do you recommend? Based on your recommendation can, you tell me or point me to a reference I can use to make the coding change?
The following is a description of the application:
1. This program was originally setup as a console application, but I changed the application so that it would compile and run as a windows form application. I made the changed since I wanted to save all the output messages that were originally written to Dos popup windows to saved to log files for research and deubgging purposes.
2. This application has 4 project files. Two of the project files are class libraries and two of the project files are window form applications that I converted from a console project files to window form proejct files.
3.One of the windows form project files is the 'driver' of the application. I would like to add a 'gui' interface to the application so the user can enter data that can be utilized by the 'driver' project file.
|
|
|
|
|
classy_dog wrote: 1. I would like to know if it would be better to add a desktop form for an
asp.net web forms page to the application? I would like to know what is better
and why.
Impossible to answer seeing as we know nothing of what the app does, how it maintains its state, and how the user interacts with it.
classy_dog wrote: 2. In addition, the two project files that are windows form apps currently, I
would Like to know if I should make those web form projects, leave the project
types alone, and/or what do you recommend? Based on your recommendation can, you
tell me or point me to a reference I can use to make the coding change?
Again, impossible to say. See answer 1.
classy_dog wrote: 1. This program was originally setup as a console application, but I changed the
application so that it would compile and run as a windows form application. I
made the changed since I wanted to save all the output messages that were
originally written to Dos popup windows to saved to log files for research and
deubgging purposes.
You didn't need to change this to a Windows Forms app. All you had to do was write the messages going to the Console to a file. A simple method in your code would have done this very easily.
classy_dog wrote: 3.One of the windows form project files is the 'driver' of the application. I
would like to add a 'gui' interface to the application so the user can enter
data that can be utilized by the 'driver' project file.
Again, impossible to answer.
|
|
|
|
|
|
In a C# desktop application, I am using linq to sql to connect to a sql server 2008 r2 database. The applicatiion is setup to point to various databases depending upon the value in the app.config file.
The problem is code in the *.designer.cs gets overrriden somehow by 'defaults' in the .net problem framework. When this happens the 'using system.configuration' gets removed from the application and the 'default settings' values are used to get the database connection string values.
When I notice this problem occurs, I need to do the following: 1. place the 'using system.configuration' code back into *.designer.cs file, 2. change the code so the database connection info is obtained from the app.config file, 3. remove the property settings so the 'default' database connections are not used.
Thus can you tell me what is causing this problem to occur and how to
solve the problem?
|
|
|
|
|
You cannot modify the designer files at all. Any code you put in there WILL be overwritten and destroyed.
The stuff your'e talking about always goes into your Form.cs files, not the designer files.
|
|
|
|
|
So what you are saying if I place the code in form.cs, then the db connection string values will not be overriden? If so, can you show me some code I can use as a reference?
|
|
|
|
|
Serisouly?? If you need this kind of help, you REALLY need to pickup a beginners book on C# and work through it.
It's no different than if you were putting the same code in the designer file.
|
|
|
|
|
I have the following questions in regards to converting a C# 2008 appliation that is currently executed as a dll and now I want to change the program so that is executed as an api. I have the following comments to make which are:
1. This program was originally setup as a console application, but I changed the application so that it would compile and run as a windows form application. I made the changed since I wanted to save all the output messages that were originally written to Dos popup windows to saved to log files for research and deubgging purposes.
2. This application has 4 project files. Two of the project files are class libraries and two of the project files are window form applications that I converted from a console project files to window form proejct files.
3.One of the windows form project files is the 'driver' of the application. I would like to add a 'gui' interface to the application so the user can enter data that can be utilized by the 'driver' project file.
I have the following questions I would like to ask which include the following:
1. From what I described above, would you tell me what I need to do to convert the application I listed above from being executed as a dll and execute it as api? Is there any special considerations I need to take into consideration? Can you show me code and/or point be to a reference I can utilize to accomplish my goal?
2. Would it be better to make the 'gui' interface where the user enters data a desktop or asp.net web forms application? Can you tell me why one method would be better than another method would be?
|
|
|
|
|
not sure I understand you fully, but, I would move/'refactor' all the non gui/console code functions etc into a dll, and export their function calls etc - this is effectively your 'api'
The dll can then be used in a console or gui program
Im not sure your point in #1 is a good enough reason to change to a windows forms app - If it were logging/catpturing output messages, you could have used log4net for example .. even if you said you wanted to capture them to a DOS type window, that can be done from log4net
[edit]
btw - your second point #2 ..'depends' if only one user is going to be entering data and/or never from a 'remote' desktop, then maybe I'd prefer 'Forms' based - if multiple people may be entering data and you may move the solution to a more 'distributed' space, then, maybe asp.net web forms is the go ..
again, it all comes down to requirements/analysis - seperating the 'work functions' from the 'gui' type functions will help you whatever the case
[/edit]
'g'
modified 26-May-13 19:17pm.
|
|
|
|
|
classy_dog wrote: currently executed as a dll and now I want to change the program so that is executed as an api. An API is merely a set of classes/methods in a DLL.
1. You could just log the messages to a file (see log4net Tutorial[^]), rather than using popups.
3. If it is already a Windows forms application then you already have the GUI. Just add the controls to accept input from the user.
B1. You don't need to do anything, the API is in the DLL.
B2. Depends whether you have users that need to access it across the internet, if not then Windows.Forms is fine.
Use the best guess
|
|
|
|
|
Hi all, I'm a newbie to C# after learning it in AS Computing.
My Father has asked if I could create a program to find Orphaned .XMP Files.
So Here is What he would like to do:
Search for the Camera raw file first and compare it to the Directory to see if there is a .XMP file with the same name, if not then Delete the file. I know this would mean an IF statement.
I would be most grateful of any help or if someone could point me in any direction.
Kind Regards
Jonathan
|
|
|
|
|
Look for examples and tutorials dealing with the system.IO namespace (directoryinfo, fileinfo), these will supply the context of what you are doing. When your research has found some examples, work through them. When you come up against a specific problem come back and ask.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
ok .. how do you identify Camera raw files ?
To get a list of all .XMP files you can do this ..
String[] XMPFileNames = Directory.GetFiles(DirName, "*.xmp", SearchOption.AllDirectories);
Depending on your answer to 'Camera raw files', might change the way I think about the start point ...
|
|
|
|
|
I have made a C#(2010) application which contains a database application connected to oracle 10 g server.Now I am wanting to make a setup file which contains customize form and check .net framework and oracle server while installing others computer if not found then it automatically install these and create the schema s at installation time. Please help me step by step. I am new in C#. Thanks in Advance.
|
|
|
|
|
|
im looking to have a console app
executing a void in my winform
how could i possibly do this
|
|
|
|
|
I think you are looking for InterProcess Communication (IPC)
|
|
|
|
|
You can host a WCF server in the console app and WinForms can act as the client.
If you are using .Net 2.0, you can consider remoting.
|
|
|
|
|
what i need is realy simlpe i need to call a certain void
from my app, call made by my console app
do u think that hosting a server would be good for that
|
|
|
|
|
Member 10074097 wrote: executing a void in my winform What exactly do you mean by that?
Use the best guess
|
|
|
|