logic confusion

logic confusion

Postby metulburr » Sat May 10, 2014 4:15 am

Im not sure on how about going on this logic for this game. The game is Flood it.
my repo:
https://github.com/metulburr/FloodIt

the game:
http://floodit.appspot.com/

Basically the idea is.... the top left block color is the starting position/color. And you change your color to touching blocks colors to consume them. The goal being that by before 25 turns, you have the entire board all one color, otherwise you lose.

Ive got the basic UI setup. Im just not sure on how to go about the logic for changing your color to nearby color blocks? Ive sat here for a bit drawing on a white board how to come to a conclusion with this, but i end up getting no where. For some reason i think i am over thinking this, and the answer is simple.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1469
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: logic confusion

Postby Mekire » Sat May 10, 2014 9:37 am

Hmm. I can think of some ideas, but I would probably have to try to implement it myself to give you a confident solution.

You might want to start by looking at flood fill algorithms and think about how you can adapt that kind of idea:
http://en.wikipedia.org/wiki/Flood_fill

I would probably keep the entire board as a dictionary of coordinate to color.
Then I would keep track of several sets of checked coordinates.
Perhaps an open_set containing all the cells that needed to be checked for neighbors, and a closed_set of cells that had already been confirmed to have no neighbors that weren't already the same color. When the length of the closed_set reaches the length of the board dictionary, the player has won.

That is just a rough idea of how I would approach it.

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: logic confusion

Postby metulburr » Sun May 11, 2014 3:08 pm

I used a recursive function that i pretty much barrowed from a replica game.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1469
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: logic confusion

Postby Mekire » Sun May 11, 2014 3:25 pm

Looks pretty nice. Do you understand the algorithm you implemented?

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: logic confusion

Postby metulburr » Sun May 11, 2014 3:37 pm

Do you understand the algorithm you implemented?

Yes. That was more along the lines of what i was thinking, except i wasnt thinking of using recursion to handle neighboring blocks.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1469
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: logic confusion

Postby Mekire » Sun May 11, 2014 3:39 pm

Just glanced at it. Looks pretty clean. I think it is essentially a recursive flood fill.

You should go post it on the pygame subreddit (might want to include how to play for the uninitiated).

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan


Return to Game Development

Who is online

Users browsing this forum: No registered users and 2 guests