Sign in to follow this  
JDCAce

Starting Puzzle With Solution

Recommended Posts

I've decided to make a clone of the open-source Android game [url="http://www.aopensource.com/index.php?more=30"]Scrambled Net[/url], but with XNA and for PCs. (Basically, you have one "power node" and have to rotate wires so all computers are connecting to the power node.) So far, I've been able to put random tiles on the board and have them rotate when clicked. Now comes the daunting task of the puzzle logic. I thought it would be easier to put a "solved" puzzle on the board and simply rotate the tiles randomly from there. (The user will not be able to see the solved state, of course.) That means all the necessary tiles are in their places; the user just needs to rotate them correctly. But I'm stuck: How do I generate a "solution?"

I don't even know where to begin. Is this project too complicated for a beginner? Should I pick something simpler, like tic-tac-toe?

Share this post


Link to post
Share on other sites
You do have a logic of connection though?

Just start with a random position, put one tile there (without connections).

Pseudocode:

for number_of_tiles_to_set do
find random position beside on an empty spot beside an already set tile
connect both tiles

Share this post


Link to post
Share on other sites
Not really sure how your game is supposed to work but can you do something like this?

Put that power node on the map.

Make a random path walker that starts on that node. Make a if or switch to move him in a direction put a wire there and a chance to rotate that wire. repeat this X times and put a computer at the end of the path.

Then start that again from the power node X times.

Of course you don't want to cross, or even have adjacent tiles to your previous (or current) paths so you have to check if the way is free.

Look up random/procedural map generation. It should yield many different methods on making things random.

Share this post


Link to post
Share on other sites
Those sound like good starting points. Thanks for the help! I just Googled procedural map generation, and it looks just like what I needed. Edited by JDCAce

Share this post


Link to post
Share on other sites
Do all computers have to be connected directly to the power node, or is via another computer okay? If the latter, I'd say:[list=1]
[*]Start with an empty board.
[*]Randomly place the power node.
[*]Randomly pick a maximum path length.
[*]Randomly pick a filled cell.
[*]Do a random walk from that cell up to the max path length, not allowing any collisions.
[*]Place the computer at the end of the walk.
[*]Go back to 3 as many times as required.
[*]EDIT: Fill the remaining empty cells with random wires.
[/list] Edited by jefferytitan

Share this post


Link to post
Share on other sites
[quote]Do all computers have to be connected directly to the power node, or is via another computer okay?[/quote]
Looking at the image in the link he posted, it looks like computers only have one connected side, so it's probably the former.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this