Sub's coding pool party

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
So there was a pretty terrible memory leak in the game of life program. I just wasn't freeing a pointer after using it, and this pointer was leaking with every frame, so yeah, it was bad. I fixed that though, and updated the download link to have the fixed program.

http://www.mediafire.com/?aha28fympq178bp

I also figured out how to get the color of a pixel, which lets me do what I want to do with the drug war game. That also led to me thinking about the board game risk, which is something that I've always wanted to make. I wasn't sure how it would be possible to let the computer know where one territory ends and the next begins, but I think I might know how to do that now. There are probably a lot of better ways, but I think that what I have in my head would work. So Risk is going to be next.
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
I don't think anyone cares, but for the hell of it, I updated Game of Life again. I had the thought that it might be cool if the sim generated a new board and restarted automatically after every cell on the board died or was in a stable state (ie: in an infinite loop). I also decided that the game should keep track of and display the highest generation count from when the program was started, and if you click on the text that displays the highest generation count, I thought it would be cool if the game recreated the first generation of the board that produced that highest count.

I managed to get it working without much of a problem. There's an option to toggle this continuous mode on / off by clicking on the on/off text, and it's off by default.

The only thing that's not working 100% at the moment is that it will get stuck on loops/patterns that take longer than 2 generations to restart. This doesn't happen that often, but it happens enough that I'm going to fix it. I tried to fix it by every 10 turns making a copy of which cells are alive on the board. Every single turn this board is compared to the cells alive on the current board, and if the boards are a match, reset the game. That logic seems good to me, so I must have just made a mistake implementing it. Any loops that are longer than 10 turns will cause the game to continue forever, though, which I think is fine.

Currently it will only hold the highest generation since starting the program. I think I might introduce some sort of laughable and rudimentary saving system so that the highest generation and the starting board that produced that highest generation will carry over every time the program starts.

And for fun, here's a random and poor quality .gif I made with the program.



I also asked Sky to move this topic out of off topic and into General Artwork or something, but he told me no :(
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Not really sure if I should go with icons or buttons for the hospital / bank / store. I'm leaning towards icons since they'd be easier to click. Anything that doesn't look aligned was done in MSPaint and should probably be ignored





Icons or buttons?

edit: Also, I just got a really cool idea for my game of life clone. I don't want to post what it is yet, but I'm really damn excited about it. I love this shit.
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
http://www.own3d.tv/Sub-/live/300487
If it's stuck with a pattern going through an infinite loop, just give it a second. It should restart at around generation 2000.

I spent a lot of time today working on my Game of Life clone, I think I made it a lot cooler.

I noticed that cells will sometimes break off from each other and form their own isolated groups, or perhaps they started isolated. I had the thought that it might be cool to show some rudimentary evolution with these groups. The best way to do this is to do it visually, of course, but all that we're dealing with is colored squares. So what if we played around with the color? What if we change the color of each new cell to be an average of the color of its three parents? What if we then changed that color slightly to simulate random mutation? What if, very very rarely, we don't make a new cell a combination of its parents colors but we make it a distinctly different color? We would then have packs of cells visually evolving differently, even if they all start out as the same color.

That's what I spent the 16th doing. I'm pretty much done with that at this point. I'm pretty damn happy with it, and I don't think I'm going to be on my PC much today, so I'm just going to stream that in the continuous mode for a while (continuous mode being whenever the board is dead, it'll automatically generate a new one). I'm doing that because I don't know if many people have ever seen Conway's Game of Life or have any idea what I'm talking about, and I've always been fascinated by it.

I'm still thinking of some things that I want to add to it. In addition to making the scanning for life detect when it gets stuck on infinite loops longer than 2 turns long, I'm thinking of adding an options menu with things like making the board bigger / smaller, or setting the board to be pre-defined patterns. People have discovered some pretty cool stuff with Conway's Game of Life that I could program in there. Also, right now when it generates a new board it starts as one solid color, but I might change that. Dutchmeat said I could add different behavior to the mutated cells which strikes me as an interesting idea. I don't know if I want to change the rules that much, but it might be something worth doing. Like maybe there will be a color range that will breed much better with a color other than itself, but much worse with itself? I'm not really sure, I think I'm going to play around with that.

edit: So I'm actually still playing around with this. I'm not really sure how common mutations should be, or how severe. I toned it down a little, and I also made the board able to generate a mix of colors instead of one solid block of color. I just added a 5th rule which is the first real divergence from Conway's Game of Life that I've made. There's a 1 in 1500 chance that, if a cell has two neighbors and is dead, it will come alive. I think I'll have an options menu where you can toggle the original rules on / off.
 
Last edited:
Death from Above
โœ”๏ธ HL Verified
๐Ÿš‚ Steam Linked
๐Ÿ’ป Oldtimer
Joined
Nov 25, 2001
Messages
4,943
Best answers
0
Location
Get off my couch
Not really sure if I should go with icons or buttons for the hospital / bank / store. I'm leaning towards icons since they'd be easier to click. Anything that doesn't look aligned was done in MSPaint and should probably be ignored

http://i.imgur.com/FaehP.png

http://i.imgur.com/AtsjJ.png

Icons or buttons?

edit: Also, I just got a really cool idea for my game of life clone. I don't want to post what it is yet, but I'm really damn excited about it. I love this shit.
Icons :)
 
Swag
๐ŸŒˆ Beta Tester
๐Ÿ‘ฎ Moderator
โœ”๏ธ HL Verified
๐Ÿš‚ Steam Linked
๐ŸŒŸ Senior Member
Joined
May 9, 2009
Messages
922
Best answers
1
Location
Behind 'yo house!
Already gave you my feedback, Sub. Seriously though, that message log really does speak tha truth!
 

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
In an effort to make the evolution model get better, I keep checking the stream occasionally to see how it's doing (which is a lot of the reason for the stream tbh). So if you turn off all the genetic mutations, introduce a lot of colors randomly around the board at the start of the game and then leave it alone, it has a tendency to turn all black since black is just a combination of all the other colors. I made the genetic mutations function like this at the moment -- it has double the chance to mutate into lighter shades, but if it does mutate into a dark shade, it mutates much more heavily into a dark shade. The goal that I have is for colors to be mostly stable, but occasionally mutate into something much more different. This seems like it might be working well enough, as you can get light strands developing, dark strands developing, and the original strand kind of surviving all at the same time.

I've also been thinking about what Dutchmeat said, though, and I think I like the idea the more I think about it. What if, instead of having it function like described above, I made each mutation much more rare, but a lot more severe. I could have a number of traits that get randomly assigned each time there's a big mutation like that. Any new offspring produced from that cell will share its new trait(s). Most mutated cells would never live to breed, but if one does and it develops a trait that is not fit for survival (ie: perhaps there will be a trait which makes a cell with 3 neighbors have a 1 and 3000 chance every turn at dying [although that might actually be good for survival..]), it would die off. But if it doesn't effect things negatively or effects things positively, and is lucky enough to be able to produce offspring or at the very least survive that turn, you'll see that color spread out among the general population.

A lot of times there are 4 cells clumped together in a square, which is a stable state so it'll stay alive forever. You'll see those can change color quite a bit compared to the other cells on the board, because there are just 3 other cells it needs to average its color out to, and any mutation will live on to the next generation. I think that those might make things pretty interesting if there are rules like above. I'm going to try it out and see how it does.

I'm not really sure what traits I should be looking at though.
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
If you have no idea what I'm talking about and want to know, I'm making Conway's Game of Life with a twist. Cells will have colors, and for every new cell born, its color will be an average of its parents but changed slightly. Very rarely a cell will be born with a big color change, and when this occurs, I'm going to randomly assign it a trait that can change the behavior of that cell and its offspring. Here are some pictures I took which show color in the program

http://imgur.com/a/EffIw


I've kind of mapped out what I want to do from here with this program.

So I'm going to make an options list with a bunch of stuff in it. From here you can
  • Reset the board by pressing a button
  • Place the beginnings of interesting patterns that people have found
  • Place something I'm going to call a color launcher on the board. This will shoot something every x turns (you set the frequency before placing it) that changes the color of a cell hit to whatever color the launcher is shooting [it'll shoot in 9 directions]. I'm thinking that in terms of looks, it'll just be a black square with the color it's shooting in the middle
  • Place something I'm going to call a cell spawner. It'll spawn cells....
  • Change the speed of the game
  • Change the size of the board
  • Change the rules to follow Conway's original rules, or the new rules I'm going to be putting in
  • Invert the boards colors
  • Turn continuous mode on / off [Basically, if the game detects that the board is dead, it'll reset the board and spawn a new one].

Right now mutations are just color changes. With every big color change that occurs, I'm going to randomly assign it a trait. I think that I'm going to make mutations much, much rarer because of this. I really have no idea how the traits are going to effect the game, but I've made of list of some possible traits and I guess I'll try them out to see how they work. The goal is to get the game to produce a board which is resistant to completely dying off, but which develops competing groups of cells. I think that I might do something like have a max number of traits that a cell can have, and perhaps once this number is reached, it's then unable to breed with differing cells? I would need to introduce something that deletes traits or something, though.

With that explained, the final bullet points are as follows:


  • In the menu, you can choose what type of mutation you want to give a cell that you place down, default being none. Mousing over a trait will bring up a popup explaining what the trait does
  • Holding down the middle mouse button will pause the game and, if you mouse over an alive cell, bring up a popup which shows you what traits that cell has

Here's what the menu structure will probably be and a list of the traits
Code:
MENU:
MENU BAR
    START, STOP, OPTIONS, GENERATIONS:  00

OPTIONS
    SPEED, RESIZE BOARD, RULES, TOOLS

        SPEED
            NEXT TURN, SLOW, NORMAL, FAST, FASTEST
    
        RESIZE BOARD
            SMALL, NORMAL, LARGE
    
        RULES
            ORIGINAL RULES, MUTATIONS ON / OFF, CONTINUOUS MODE ON / OFF

        TOOLS
            CLEAR BOARD, SHAPE SPAWNER, COLOR LAUNCHER, CELL SPAWNER, INVERT COLORS, SPAWN CELLS WITH THESE MUTATIONS
            SHAPE SPAWNER
                GET LIST OF SHAPES
            
            COLOR LAUNCHER
                INTERVAL OF SHOTS

    
            
MUTATION LIST:
-  FERTILE 1    
    -  CHANCE OF NEW LIFE IF 2 NEIGHBORS WITH THIS TRAIT [AVERAGE IF DIFFERENT NUMBERS]
-  FERTILE 2
    -  CHANCE OF NEW LIFE IF 4 NEIGHBORS WITH THIS TRAIT [AVERAGE IF DIFFERENT NUMBERS]

-  SUSTAINABLE 1
    - IF 1 NEIGHBORS, CHANCE OF FORMING 4 BLOCK SQUARE TO NOT DIE

-  SUSTAINABLE 2
    - IF 0 NEIGHBORS, CHANCE OF FORMING 4 BLOCK SQUARE TO NOT DIE

-  RESTLESS 
    - IF 3 NEIGHBOR SQUARE, CHANCE OF MOVING ALL NEIGHBORS IN NEW DIRECTION

-  SICKLY 1
    - IF 2 NEIGHBORS, CHANCE OF DEATH
-  SICKLY 2
    - IF 3 NEIGHBORS, CHANCE OF DEATH

-  INDEPENDENT 1
    - IF 1 NEIGHBORS, 80% CHANCE OF SURVIVAL

-  INDEPENDENT 2
    - IF 0 NEIGHBORS, 70% CHANCE OF SURVIVAL

-  DOMINANT
    - IF NEW LIFE IS BORN, COLOR IS AN AVERAGE OF PARENTS + ANOTHER AVERAGE OF THIS COLOR.  
        -  UNSURE IF SHOULD KEEP THIS COLOR AROUND
-  RECESSIVE
    - IF NEW LIFE IS BORN, COLOR IS AN AVERAGE OF PARENTS + ANOTHER AVERAGE OF PARENTS WITHOUT THIS COLOR

- RADIOACTIVE
    - CELLS WITH THIS TRAIT HAVE HIGHER CHANCE OF MUTATION


- TIME BOMB
    -  TRAIT WILL DO NOTHING FOR 100 GENERATIONS
        - AFTER 100 GENERATIONS, 20% CHANCE OF DYING OFF EVERY TURN
            -  LASTS 4 TURNS, THEN TRAIT DISAPPEARS AND ITS OFF SPRING ARE IMMUNE TO THIS PARTICULAR STRAIN (so in other words, it can get infected if with this trait again, but not from the same mutation that was already infected with)
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Thanks, that is pretty cool. I was planning on having some predefined traits like I posted above, but it might be worth trying to get the game to generate its own traits? I don't know, but still, cool stuff, and that paper is rather old, too. From 1994.

I was browsing the 'net last night and stumbled across something similar to all this. There's a project that is attempting to generate music through evolution. They started out with randomly generated sounds and had a group of roughly 6,000 people vote on whether they liked the tune or not. No idea if anyone is interested, but you can listen to what the computer has come up with on their page in the link below. I think it's like 3,000 (or 6,000?) generations in at this point. It's not developing great music or anything, but it's come a long way from the first generations.

http://darwintunes.org/evolve-music
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Spent the time since I last posted on trying to finish up some old projects. My game of life clone I could probably declare done, but I'm still throwing stuff in there. The past few days I've been mostly trying to fix solitaire and get that working correctly, but I think I've given up hope at this point. I also started to read the UML Object Oriented design book Harsens recommended.

I spent a few hours maybe two weeks ago on a new project, a clone of the game Hex Empires. I'm calling it Sins of a Hex Empire, a play on the name Sins of a Solar Empire. Last time I got a hex board up and running, and then took a break when I couldn't get the next thing I needed to do working.

I spent a few more hours on it tonight and I've made progress. It's now generating interesting maps that I'm happy enough with. The blue hexes are water, the green hexes are land, the hexes with a blue oval inside are cities (cities produce units for you each turn), and the missing hexes in the corners are where the capitals will be. You capture a capital, you kill that player. Still need to add ports to the map generation, units have to be on a port hex before they can enter into the water.
http://imgur.com/a/gN4sw









 
Swag
๐ŸŒˆ Beta Tester
๐Ÿ‘ฎ Moderator
โœ”๏ธ HL Verified
๐Ÿš‚ Steam Linked
๐ŸŒŸ Senior Member
Joined
May 9, 2009
Messages
922
Best answers
1
Location
Behind 'yo house!
Looks neat. ;)
 

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Civilization is probably my favorite game in the world. If you're making a Civ clone, might be worthwhile to check out Free Civ. It's pretty much Civilization II / III, but it's open source so you can take a look at the code to see how they did everything. I'd love to see some screenshots of it at somepoint if you'd be comfortable with showing it, I love Civ.

And yeah, I'm not sure if there are any other ways to do it, but if I remember correctly, I just made a class called Hex which had XY coordinates and a row number / column number, made a class called board which created an array of 200 something hexes upon being created, and then set the xy coordinates for each hex to be one hex down - 1 pixel, and for every other row, the x value is to the left, although I don't remember how I determined how far it was to the left.
 

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
I've been working on this for the past few days and I've made a bit of progress. 90% of my time was spent cursing in trying to figure something out, but I think I'm past that now. This is a screenshot of where it's at now



Right now the player picks which nation he wants to control at the start of the game, units are in and you can move it around, it can move 2 spaces from its starting location each turn. If you move into a space and one of the neighboring tiles doesn't belong to you (and isn't a city or capital or occupied by another players unit), you capture that tile and it belongs to you. This does two things -- Changes the color of the hex, and adds a number onto the unit that captured the tile. Units have two values that determine how strong they are, how many troops are in the hex and how many tiles its captured, both max out at 99.

Still need to do the AI and the map generation still doesn't add in any ports so you can't traverse water right now. Need to add in turns and cities are supposed to spawn units every turn. Also, the tank sprite covers up the capital / city if you're on top of it. Not sure what to do about that, it's annoying. Also need to put in a way of letting the player know how many units are in a given hex -- I think if you hover over a unit or you have a unit selected, the tank sprites on the map will be replaced with the number of troops in a tile and the strength it gets from exploring tiles.
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
I'm having trouble figuring out how to convey information to the player. I removed the tank sprites in favor of, well I guess you could call them walking army size indicators.

When there's no unit selected, this is how it looks



You see how many troops you have in a hex when they're not in a city. In a city, you just get an indicator that there are troops there.

When you have a unit selected, you see how many units you have on every tile, but you still can't see how many troops an enemy has if they're in a city.



This is fine I think, but I wanted units to have a second strength indicator other than army size. If a unit expanded the borders by moving, I wanted them to fill up something similar to the army size indicator but for borders. I have no idea how to display that strength to the player, though.
 

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Thought about it and I think I'm going to do something like this.........



A units strength is made up by combining two values -- However many units are in the hex (9 max) + however many experience points it has (9 max, experience is gained by either winning a battle or for each hex you add onto your borders). So this is represented by having 9 crosses on a hex, a black cross to represent an army in that space, a white cross to represent no army, and a black outline around a cross for each experience point that unit has. So in the above screen, that unit has 6 armies in the hex with 7 experience points.

It's a bit harder to make out what's going on, but it's the best I've come up with so far *shrugs*
 
Last edited:

sub

Active Member
๐Ÿ’ป Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
I think I'm done with everything in the game at this point, other than AI which I haven't started yet. There's a surprising amount of logic in some seemingly simple stuff. For example, getting the transfer of units from one hex to another behave correctly, mostly from when you move to a hex which already has a unit.

I really have no idea how to do AI, but I'll figure it out. And now that I think about it, I have to do a user interface too, something that tells you how many more units you can move a turn, what turn # turn you're on, a button to generate a new map, that sort of thing.
--

I sent a preview version of the game out to get some feedback. Here's what the critics are saying about Sins of a Hex Empire

This is the greatest game in the history of mankind
~ Sub

I'm so proud of you
~ My mother

I wish I was as good at coding as Sub is
~ Raven

Stop showing me this shit I don't care
~ Zoo

So strong is Sub's creativity and artistic vision that it ripped a hole in the fabric of time and space, which allowed me to capture a glimpse of the game so that I could steal the idea from him before he actually made it
~ Creator of Hex Empire, a game I totally didn't copy

I really don't know how much more proof anyone could need. This game is going to be amazing.
 
Last edited:
Swag
๐ŸŒˆ Beta Tester
๐Ÿ‘ฎ Moderator
โœ”๏ธ HL Verified
๐Ÿš‚ Steam Linked
๐ŸŒŸ Senior Member
Joined
May 9, 2009
Messages
922
Best answers
1
Location
Behind 'yo house!
Where're my reviews? :(
 

sg2

New Member
Joined
Apr 20, 2011
Messages
37
Best answers
0
I sent a preview version of the game out to get some feedback. Here's what the critics are saying about Sins of a Hex Empire

This is the greatest game in the history of mankind
~ Sub

I'm so proud of you
~ My mother

I wish I was as good at coding as Sub is
~ Raven

Stop showing me this shit I don't care
~ Zoo

So strong is Sub's creativity and artistic vision that it ripped a hole in the fabric of time and space, which allowed me to capture a glimpse of the game so that I could steal the idea from him before he actually made it
~ Creator of Hex Empire, a game I totally didn't copy

I really don't know how much more proof anyone could need. This game is going to be amazing.
That was too damn hilarious!

You know, that gives me an idea for a real critic: old game mechanism might be old fashioned and out of date, but add your humor to it and you really got a creative and artistic game.
- It's still too early to do so, I know, since you're just learning to code basics; but definitely once it gets "natural" to you, you should implement humor as your main spice.
 

Users who are viewing this thread

Top Bottom