Atomino| User | Message | |
Posted : Sunday, 24 October 2010, 11:11 | Permalink | Mark Here |
Jayenkai

 
WW Entries : 103
|
FFS, Spinal, this is far too complex for the shoutbox!
People, use the forum!!
Right, IIRC, Atomino was about little atoms, each one had a preset number of pegs, and you needed to attach an atom to each peg without any leftover pegs.
...or, something, been a long long time!
*checks a Youtube vid to be sure*
It's REALLY easy to do this, and you're overthinking things with your idea for a flood fill.
ArrayS!!
First array is Atom(x,y), where 0 = nothing, 1=blue, 2=red, etc.
Pop a red on the grid, Atom(x,y)=2
Next, a Peg(x,y) array.
Peg is a binary number, where 1=A Peg Up is here, 2= A Peg Right is here, 4=A Peg Down is here, 8 = A Peg Left is here, and OR combinations are the various combinations thereof.
eg..
Array(5,5)=2;Peg(5,5)=6
display red atom, draw a right facing peg, and a down facing peg.
So, you've got your red atom at, say 5,5
No pegs yet.
We place a second red atom at 5,6
Peg(5,6-1) isn't yet using all 2 pegs, (bin$(peg(x,y)), count the 1's) so allow a connection here.. Peg(5,6-1)=Peg(5,6-1)+4, and Peg(5,6)=Peg(5,6)+0
Whereas is Peg(5,6-1) has no pegs left, you wouldn't add a connection.
Do it whenever you place a new atom, and it'll keep track whilst you go.
If you erase an atom, be sure to clear it's pegs!
You might also want to flick through all the atoms once every few frames, to be sure there are no connections that could be made.
-----
 |
 | |
| Posted : Wednesday, 27 October 2010, 13:51 | Permalink | Mark Here |
spinal

 
|
You're correct, that part is not too hard, it was the next part that I was thinking of. Detecting if a bunch of atoms have been joined completely with each other... which I'm lost with.
bmp image -
http://socoder.net/uploads/124/atoms.rar
-->
-----

3DS - 1762-2660-3218 |
 | |
| Posted : Wednesday, 27 October 2010, 14:07 | Permalink | Mark Here |
Jayenkai

 
WW Entries : 103
|
Aaah, then that bits a Forward/Backward/Up/down check.
Done this one plenty, too, it's not too tricky..(ish)
HasAll(x,y)
first to flag 'em on.
for x=0 to wide
for y=0 to high
HasAll(x,y)=1
if Atom doesn't have all pegs, and atom>0 then HasAll(x,y)=0
next
next
Next to combine ajoined.
for y=high to 0 step -1
for x=wide to 0 step -1
if y>0 and atom is here then if "peg up" is on and HasAll(x,y-1)=0 and there's an atom there, then HasAll(x,y)=0
and below
and left
and right
next
next
then again to double check
for x=0 to wide ; note the order's the other way around
for y=0 to high
if y>0 and atom is here then if "peg up" is on and HasAll(x,y-1)=0 and there's an atom there, then HasAll(x,y)=0
and below
and left
and right
next
next
And once more for good luck...
for y=high to 0 step -1
for x=0 to wide
if y>0 and atom is here then if "peg up" is on and HasAll(x,y-1)=0 and there's an atom there, then HasAll(x,y)=0
and below
and left
and right
next
next
Then flick through, and if a whole bunch have HasAll, then they should be removable..
That should do it..
Maybe..
Worth a triple/quadruple check, maybe, just to be on the safe side 
-----
 |
 | |
| Posted : Saturday, 30 October 2010, 07:07 | Permalink | Mark Here |
spinal

 
|
Not really working its removing single 'full' atoms even when ajoining ones are not full...
-->
-----

3DS - 1762-2660-3218 |
 | |
| Posted : Saturday, 30 October 2010, 09:03 | Permalink | Mark Here |
spinal

 
|
In my head, the following solution should work, recursively checking each atom from the click point, then if the result is that all atoms are completely joined, clear then...
-->
But it's failing and as this is the first time I have ever attempted recursion for any reason, I have no idea where I going wrong 
-----

3DS - 1762-2660-3218 |
 | |
| Posted : Saturday, 30 October 2010, 15:43 | Permalink | Mark Here |
spinal

 
|
made a little (very little) progress, it seems to be correctly checking the full molecules, but then doing nothing about them 
-->
-----

3DS - 1762-2660-3218 |
 | |
| Posted : Sunday, 31 October 2010, 08:10 | Permalink | Mark Here |
Jayenkai

 
WW Entries : 103
|
Blimey, that's chaotic.
If you can follow my additions, here ya go!
-->
-----
 |
 | |
| Posted : Sunday, 31 October 2010, 08:14 | Permalink | Mark Here |
Jayenkai

 
WW Entries : 103
|
You'll also want to check your "if Atom>Peg" thing, because Peg isn't a number 1-4, it's a binary number..
and there's a handful of other quirks in there, too.
Quick test, blue atom left, blue atom right, red atom inbetween = red atom only connects to the left, not the right..
-----
 |
 | |
| Posted : Sunday, 31 October 2010, 09:05 | Permalink | Mark Here |
spinal

 
|
I'm not 100% sure...
sparkly(x,y) is recording which atoms are getting checked and then im lost how is it different from checked(x,y)?
atom>peg fix -- you're right, it works much better now 
-->
-----

3DS - 1762-2660-3218 |
 | |
| Posted : Sunday, 31 October 2010, 09:14 | Permalink | Mark Here |
Jayenkai

 
WW Entries : 103
|
It probably was the same, I just wasn't quite sure what it was you were doing, so threw my own equivalent version in there, instead 
-----
 |
 | |
| Posted : Sunday, 31 October 2010, 09:16 | Permalink | Mark Here |
spinal

 
|
Anyway, your way works and mine doesn't... either way, thanx, I wouldn't have figured it out by myself.
-----

3DS - 1762-2660-3218 |
 | |
|
|