Sub's coding pool party

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Thanks Shonnie.

The AI is coming along too. I think I just need to add two more things and then it can start improving itself and hopefully become competent.

 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
I think this is pretty damn cool. It basically gets better the more it plays. It started it off with absolutely terrible values. It would die at a score of around 10. 5 minutes later it's averaging around 7000, highest is 9906. That's somewhere around 160 lines before dying.

Going to leave it on all night and see how good it gets. I still need to do a few things that will drastically improve how good it is, but it's nice that it actually works and it hasn't crashed.

edit: So I go to eat and I come back to it with a high score of 48290



I didn't expect it to be able to get a score that high yet since it's still not done code wise.
 
Last edited:
New Member
✔️ HL Verified
💻 Oldtimer
Joined
Nov 14, 2003
Messages
3,974
Best answers
0
so, Sub is going to be the one to develop Skynet?
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
I hope so. I've left it on since the last post and it has a high score of 95,000 right now. It also seems completely stable, hasn't crashed yet, and I imagine it would have if it was going to crash.

It's just analyzing every possible location you can put the current shape + next shape, and assigning each possible location a score based on aspects like height, how many lines you clear, etc. The highest score is the location chosen. The AI learning comes into play in terms of deciding how the value of each aspect of score is determined, and this is done by a process similar to natural selection. Run a few games with different values, pick the best performing values and change them slightly and repeat the process -- if they average a higher score, keep the changes and repeat, if not repeat with the original changes. So if the game started off with assigning height a positive score, then after a few generations it should see a downward trend since placing blocks high up is generally not a good strategy to get a good score (that actually might not be true, but it's the easiest example to give).

I'm surprised it was able to do that well, though, since right now the strategy it uses to select which values are the best is quickly hacked together and needs to be recoded. It also only analyzes the current shape, I need to make it analyze all possibilities between the current and next. It's also only using 6 aspects for determining score, there are a few more I could add in that seem useful.

edit:

http://www.youtube.com/watch?v=HuP7PqDyPdI
 
Last edited:
Just a nice person :)
✔️ HL Verified
Joined
Jul 17, 2009
Messages
262
Best answers
0
Location
The Netherlands / HOLLAND!
Aaaaaand... you got your first like!

Though 1 thing I would like to note is. It teleports the block to the position it thinks is best right?
It would be cool if it actually moves down, not sure if it doesn't already.

One question:
Did u use a third-party graphics library? Or how did you get the window and the drawing mechanics to work?
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Thanks :p

It can either teleport to the position it thinks is best or it can move there like a human would have to. I just set it to teleport because it's faster and we want it to run as fast as possible while it's learning. It can't teleport to a position that it wouldn't be able to normally move to, though.

For this one I'm using c++ and SFML 2.0. SFML is pretty awesome. I think in one of the previous posts I uploaded the source code for the Tetris game without the AI stuff and a few bug fixes, but the program structure is roughly the same.

Also, it's getting a new high score as I type this. 211,122.
 
Last edited:
Just a nice person :)
✔️ HL Verified
Joined
Jul 17, 2009
Messages
262
Best answers
0
Location
The Netherlands / HOLLAND!
Thank you for the detailed post as well.

Well, I never really got into C++. I didn't like the many tricky characters flying all over the place (of course, this is called learning the language..).
But I actually want to start doing some C++ just because it's used all over the world and it seems pretty important for the job I want to do later on.
Not sure how I would like though start though. Even creating a basic windows forms is difficult >.< (It really is a lot of code for just a window).

Now, I could go with C++/CLI but that's just C# with a different syntax, not really worth learning.

Also, good going on that score haha!
I don't think anyone will beat the AI.
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
What do you want to do with programming? If you're doing it as a hobby, you probably don't need to know C++.
 
Just a nice person :)
✔️ HL Verified
Joined
Jul 17, 2009
Messages
262
Best answers
0
Location
The Netherlands / HOLLAND!
It's true, I might not need it.

I want to be a client-side programmer. So maybe programs for databases, graphics, networking.
Of course, the best and funniest thing to do is creating games.
I would like to create some but not sure if game development is reachable for me because
3D games require LOTS of calculations which I don't know anything about. My math is seriously below standard.

But yea, currently it's just a hobby. I'm programming in C#.

EDIT:
Also, C++ usually has the most up to date libraries one can use.
Take Lua for example, love that scripting language.
 
Last edited:

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Someone can feel free to disagree with me, but for most programming that you do you won't need to know complex math. I think graphics programming is an exception to this, but even then I think it's mostly Trig / equations of a line / entirely within most peoples ability to learn. You shouldn't let a lack of knowledge stop you from accomplishing what you want.

If you want to make games, using a premade game engine would drastically reduce the amount of math you need to know. I've been playing around in Unity which uses C# for scripts to interface with the engine. Unity is really nice actually.

On a final note, I also consider myself terrible at math, but I think it's entirely doable with some studying and practice. Just have to keep hitting your head against the wall until it works ;).

You probably need to know C++ if you want a job in the games industry, but I'm not really sure.
 
Last edited:

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
I'm done with the Tetris AI for now. It did pretty well, but progress was halted when I tried to make it analyze not only the current piece, but the next piece as well. I got it working fine, but it was analyzing every single combination between the current piece and the next piece, and the time it took to decide each move became so slow that it was discouraging to work on it.

Now, though, I make a music player. It's going to sound strange, but I've always wanted to make a music player. You give it folders to monitor and it will automatically add any artists you have/add to those folders to the library. Tomorrow I need to work on getting the songs properly formatted so that everything is in the proper column. Not really sure how songs are typically formatted, there seems to be more than one way that this is done (at least in my library), so it might be annoying.

My questionable music preference aside, I think that's going to roughly be the UI, though I'm going to add a search bar somewhere, as well as some icons up top for play / pause, that sort of thing. Also going to add tabs for playlists. I might try to make the UI customizable, but I'm not really sure. At the very least you can alter the colors.

Basically, I'm making the poor man's foobar2k.
 
Last edited:

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Embodiment of the People [need a better name]
A 4X singleplayer TBS civilization-building game


I wasn't going to even tell anyone about this, let alone post anything, but I actually want to get some feedback art-style wise.

I started the project one week ago and the goal is to produce a well polished and professional (by indie standards, anyway) looking game. Right now I'm focusing on trying to get the basic look and feel of the terrain right. This is a bit of a challenge, since I'm about as far from an artist as you can get. If anyone has any criticism or comments for me on how it looks, I'd love to know what you think.

At the moment everything is code generated, there are no sprites used for the tiles. The map shown is 12 x 12 tiles, but this map was only made for testing purposes. Maps in the actual game are going to be the typical size you'd see in other TBS games; maybe 50x80 for normal maps, and something around 75x120 for larger maps. Using SFML and C++.
 
Just a nice person :)
✔️ HL Verified
Joined
Jul 17, 2009
Messages
262
Best answers
0
Location
The Netherlands / HOLLAND!
Well, what you have right now looks good imo.

Of course you could try adding some background effects (maybe particles) or anything you like but I don't think you meant that.
The current terrain is as good as you can get without textures. The sides of the map could do with textures as well if you plan on doing that.
I don't know your artstyle yet but minecrafty textures will do just fine.

Keep up the good work!
 
Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Mar 13, 2005
Messages
3,877
Best answers
0
Looking good man! Looking really good! When you gonna start mapping for the ESF Team. :p

But I gotta say, if you need any Beta testing or anything done, hit me up.

You need to get on Steam more!
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Thanks everyone.

I appreciate the offer Deathshot, but there's really not much to test at the moment. I'll get back to you when it's a bit more complete ^_^
 
Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Mar 13, 2005
Messages
3,877
Best answers
0
Alright. I will probably have the website. I might end up buying a new one soon. It's like $8/month. Free Bandwidth and Free Space.
 
Force Pit Member
Joined
Dec 1, 2002
Messages
874
Best answers
0
Location
Gothenburg, Sweden
I like it Sub, I don't see anything wrong with that map. Seems it will provide some good gameplay! :) You are a great role model going so far with your project of learning programming. You stick to it. Good job!
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Thanks Baaja, I appreciate the kind words :)

Before I even start the rest of this post, I'm going to post the results
http://imgur.com/a/9wuWR#3Y8Pu
edit: Maybe a screen with less rigid edges would be better
http://tinyurl.com/cdrkf42

For comparison, here are some (unfortunately small) screenshots from maps that civilization II generated
http://imgur.com/a/nLWYb

And some Civilization IV maps for comparison
http://imgur.com/a/xnrjW

It strikes me that the Civ2 maps are much better. Granted, mine are still being worked on, but I'm not sure if I like the results at all. I might ditch this line of thought entirely and try to come up with something else.

I don't particularly think Civ IV generates good maps.

So I'm trying to come up good method for generating the basic shape of land on the map. Ideally I want to have control over:

  1. average size of a landmass
  2. % of the map that is water
  3. able to dictate certain areas of the map that are more likely to contain water/land (so for example, if you want a map with a gigantic ocean in the middle, well, it would be nice if the that was taken into account when generating the map)
  4. how many continents appear on the map
  5. the size variance between your continents (that is, how large the largest continent is in relation to the smallest)
  6. how many continents appear on the map
To that end I implemented something that works roughly like this

- make every tile water
while (number_of_land_tiles < number_of_desired_land_tiles) [point 2]
- ContinentStartingTile = RandomTile; [point 3, because if it lands in an area that should favor water, you can pick again)
- Make ContinentStartingTile land
- Add tiles surrounding ContinentStartingTile to a list called TilesToCheck
while (TilesToCheck > 0)
- if the tile at the beginning of the list isn't land​
- determine the %chance that this tile will turn into land. The farther away from ContinentStartingTile, the more likely it is to be land
- we can weight the distance to be very detrimental to the %chance or barely effect it at all, which satisfies point 1 in helping us determine the size of the landmass
- the weight value can also change for every continent, which satisfies point 5

- if we determine to make the tile land​
- add every tile that surrounds this one to the list of tiles to check​
- delete the tile that we just made into land from the tilestocheck list
 
Last edited:

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Location
New York
Still not really entirely sure what I want this thing to look like. I might ditch the height thing and just go with sprites for tiles, I can't get it looking right with a full map and water.
 

Users who are viewing this thread

Top Bottom