123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|681|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Concept/Design -> Atomino

Sun, 24 Oct 2010, 12:11
Jayenkai
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.

-=-=-
''Load, Next List!''
Wed, 27 Oct 2010, 14:51
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 -
https://socoder.net/uploads/124/atoms.rar



-=-=-
Check out my excellent homepage!
Wed, 27 Oct 2010, 15:07
Jayenkai
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

-=-=-
''Load, Next List!''
Sat, 30 Oct 2010, 08:07
spinal
Not really working its removing single 'full' atoms even when ajoining ones are not full...



-=-=-
Check out my excellent homepage!
Sat, 30 Oct 2010, 10:03
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

-=-=-
Check out my excellent homepage!
Sat, 30 Oct 2010, 16:43
spinal
made a little (very little) progress, it seems to be correctly checking the full molecules, but then doing nothing about them



-=-=-
Check out my excellent homepage!
Sun, 31 Oct 2010, 09:10
Jayenkai
Blimey, that's chaotic.

If you can follow my additions, here ya go!



-=-=-
''Load, Next List!''
Sun, 31 Oct 2010, 09:14
Jayenkai
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..

-=-=-
''Load, Next List!''
Sun, 31 Oct 2010, 10:05
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


-=-=-
Check out my excellent homepage!
Sun, 31 Oct 2010, 10:14
Jayenkai
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

-=-=-
''Load, Next List!''
Sun, 31 Oct 2010, 10:16
spinal
Anyway, your way works and mine doesn't... either way, thanx, I wouldn't have figured it out by myself.

-=-=-
Check out my excellent homepage!