Wednesday, September 28, 2011

Functionaly mad : Playing with snakes 5 slither harder

Been a while since I've touched on this so here we go playing with snakes. For this one I'll be trying my best to explain what is seemingly a confusing subject, functions and scope. I would just do functions but scopes and functions go hand in hand. There is one thing they are very useful for but that's more advanced and saved for later.

Functions are very useful for programing in python. First they cut down code. For instance you could write.

print (1*1)+(2*2)
print (2*2)+(2*2)
print (4*4)+(2*2)

Yes I know there is inbuilt things for powers but might as well go whole hog here

 So the age old A squared + B squared to get a number that would be the last part of a right triangle. Lots of finicky stuff you do over and over while being easy to screw up but there is a simpler way and it's called a function and you can write one in the shell. Write the following

def right_triangle(a,b):
Now with annoying color
 return (a*a)+(b*b)

Hit enter twice and you'll be back to "ground level" in the shell. Now we're going to have some problems here due to blog not doing tabs right. Python for functions and scopes require indentation with whitespace, for blog code I'll use spaces, for real coding my preference is tabs. Either way I'll include what I did to the right so I can explain it a bit with graphical aids.

First you have to use def, underlined in red I'll explain why it's important latter, to create the method. After that is your methods name, it can be any thing as long as it is "one" continuous block of characters and avoids some special characters. Dashes are fine though otherwise not so much and I haven't tempted fate enough to learn the results. A space after that is your parameters or arguments underlined in green. In it's simplest form you can use as many as you want or as little as you want, even none you just put (), but you have to give them a name like any other variable and separate them with a comma. Trailing this is the colon which is the first indication of a change in scope. What this means I'll get back to later.

The right_triangle method we created is rather simple. It only has one line of code after it with a return statement followed by things I underlined in yellow. I'll get to that in a second but first lets use the method. Please type the following.

with the power of cropping you'll not see the mistake!
print right_triangle(1,2)
print right_triangle(2,2)
print right_triangle(4,2)



Admittedly this would be more impressive if the text to invoke right_triangle was less than the straight up code with the numbers that it produces. Methods allow you to reuse code and return results. Before there was the underlined piece of code with the variables a and b in it. The a and the b were the arguments passed when right_triangle was invoked in the code. The reason you have to use all the variables is that the code expects them. In the scope after it a will effectivly be whatever is passed first while b is whatever passed second. Now they don't have to be named a,b,c or any sort of sequence. Like the functions name you can name them whatever you wish as long as you separate with commas and enclose with parenthesis.

Now this doesn't have to be one line long. It can be multiple lines as long as the indentation is correct. For example.

The red line is what I called "ground level" for the code. This is where we've been typing everything out. Variables can be used and changed after we type them but now the rules are changed. Inside the function is a different scope as seen by the blue line. It is indented one more than where the def is, hence why I pointed it out before. The arguments passed through the parameter will only exsist as the variables in there and any new variables made inside will only exist until the scope ends. Scope ends by the indentation returning to normal or return statemtn is used, regardless if it returns something ro not. This functionality of return will be important later but for now it's just a neat trick.

Now this wasn't a very useful function. As I said before you could type out what it was doing in less typing than it took to make it, but once it starts getting lines long or used for other things that involve later ideas it'll start looking like a good choice. Till then hopefully I didn't butcher this idea too badly.

Sunday, September 25, 2011

Some things actualy "completed"

Well I stayed up far too much the past two days to try and "reset" my sleep pattern to a better time. Seemingly works as I wasn't tired at all when I woke up early this morning. During those two days I manged to do a bit of programing which surprisingly worked out.

A while ago I had some results of a simple roguelike. It worked out on my end but for whatever reason no one I knew could get it to work for some odd reason. This was annoying and pretty much made me stop working with pygames. Though I had some inspiration working with Tkinter even though I had some bad experiences with it due to a friend and got into some interesting things.

Look ma no pygame.
I looked into the canvas widget which is for drawing polygons and what have you to itself. A bit more reading and I found you could do the same for text. Without too much rigging and reusing some code from the other version I got effectively the same thing down and even went so far as to add some stupid AI to it. May have some bugs but its' done and can be gotten here. Since it's just using Tkinter an inbuilt module of python it shouldn't have errors. Even if it's an earlier or later version I don't think it'll break with how consistent they have kept Tkinter which is very nice.

That said I have looked into Combat Project too with some mixed feelings. For one the code has gotten very long, and very unorganized. I did not plan adding AI well at all. I do have some minor results with it and a lot of time behind it but it's a headache currently trying to add the new features to it. I think I may be putting it on hiatus or taking what I have and working from the ground up around it, because as it stands it's not quite as workable as I like. The system itself may benifit from being moved to something with a GUI as it stands it wouldn't be fun to test. So for now Combat Project is dead until I have a better grasp of how to throw it together. Hopefuly not too long but I stared at it for a half hour just getting my bearings after taking a little break from it and that's a bad sign. Mostly due to my part of not planing ahead. Code can grow like a bad cancer of spaghetti if not thought through and this is a result that I started organizing too late.

To take it's stead I think I will be trying something a bit simplifier. With the current roguelike system in place the "How to Write a Roguelike in 15 Steps" has popped into my head. While I skipped a few things I may start working on a simple roguelike, not that most roguelikes are simple but I'm not going to be trying to reinvent the wheel here. So project 'Simple' Roguelike is go. Though looking at the steps it seems I've skiped a few like saving. Mostly due to just wanting to get something to hit as any roguelike should have but we'll rectify that later.


I could put up a cleaned version of Current Combat project though if anyone wanted though it doesn't have much without the attack AI for the enemy fully functioning.

Friday, September 23, 2011

Thoughts about older RPGs

Combat project has sorta been on hiatus with all the job junk but I've been thinking about turn based games. Asking a question akin to "how would you make turn based RPGs competitive" to some people got a few answers. Some not so worthwhile to me as they were subjective such "awesome graphics" and "Epic plot" but a few managed to get my attention.

Pre-battle Tactics
This one got my attention, though not much of an explanation, as I may have never seen this explored. In most traditional RPGs the most you did before a battle was buy then equip the best items, maybe use some monster repel to keep random encounters down, and recover. That's it, quite little you do that does have an impact in battle but not much of a choice until you're low on supplies. While I didn't get a proper explanation there was a few thoughts on this. The most overwhelming thought was of "buff" spells.

In most old games, I say most as I haven't seen them all, enhancement spells only last until the end of battle. After that the only thing that sticks with you is a number of negative status effects like poison. While this could have been due to memory issues it may have been a hold over from earlier games. The thought upon hearing Pre-battle tactics was a very simple idea of "everyone gets to cast a free enhancement spell". Using some menu you could set up your battle strategy and get all your buff spells or possibly abilities cast. Personally in every RPG I never used buff spells besides bosses for the simple reason that the turn you spent casting them could used defeating the enemies, it only served to make the battle one turn longer for the random encounters to me. How true this is I'm not sure but given a system of setting up some insurance on battles would tempt me into using them, a good strategy for making MP more valuable as it could be expended a lot more.

Beyond that I'm not sure. I'm not the most creative thinker in this sort of thing but for a more traditional Turn based RPG this seems like very unexplored territory so it's gotten me interested in it. Maybe something to look more into for later musings.


Menu System Reduction
I had mixed feelings on this but it's true. There are a lot of menus in RPGs. Often you'll go through a few sunscreens to do something other than the basic attack, even then you'll have to select the enemy which might as well count as a menu. It's a hard thing to solve for me though there may be a few ways to go about it.

While I have not played Mass effect I have seen it in action. The ability to pull up your non standard attack actions with one button then use a mouse/direction to select which one and target at the same time hides a lot of the menu systems without taking away from the number of it. Excuse me if I'm misremember a bit here though, it's been a bit over a year since a viewing of a Mass Effect game in action was seen here. While it may just be hiding the steps it's a lot better to look at.

This is sorta something that I was beginning to realize in combat project, 4 to 5 options every attack was seeming to be a lot. May be ways to reduce this as skipping some of them but at minimum you need to do 2 selections unless some sort of macro system was in place to automate a few decisions. More work needed on that thought though if that gets done soon you guys may not benefit from it.


Either way some lite thinking going on. I will try to get back to putting something up here but it may be hectic till I get an understanding of the situation. Though with how it goes I tend to do more little things like my own projects or drawing the more work I need to do. Either way if you have seen games which do some of these things I'd like to hear about them to look into it.

Wednesday, September 21, 2011

Still alive and looking at things

Haven't been posting for the past few days with mandatory drug tests, pre job paper work, and getting transportation set up. Between that just been trying to keep it cool as I'm going to probalby have a tough first few weeks.

To prepair for that I've looked into some "advanced python programing" on a whim not sure what It'd spit out. And got this video on youtube. "Advanced Python or Understanding Python"is presentation hosted by google for "advanced" topics on python. The quotes are there as I'm not sure where advanced starts and guts of the system begins. It's one of those things that even with the amount of time I've spent with python haven't really gotten into. I can get the gist of most of it especially the objects, some of which I've used such as generators, but some of it went over my head. Some things blow my mind such as the ability and execution of functions inside functions and the possible ability to contain more functions within.

Though there is a positive note to this. While I know that I am not the best python programer out there if this is labeled "advanced" and seemingly things that may never be used by me I might do alright. Beyond that a friend of mine is tentivly looking to try and make a game and I've been trying force him into python using tkinter to help him out with it. Playing with snakes post I made are me trying to refine what the points I was trying to get to him when I tried to "teach" him for giggles at one point.

Other than that been sleeping in as much as possible because the days I can do that are soon to come to an end. Though I'll finally have a job programing which is what I've been after for a long time. But for tonight it's Wings night, wonderful yet horrible for you buffalo wings from Pizza hut. Their "WingStreet" wings have a deal every Wednesday which means I can grab a box of them for nearly 4 bucks. For that price I'm up for getting take out.

All rights for this image owned by pizza hut, please don't sue me.
 While not the best wings I've gotten there isn't much choice around here. Not that many restaurants in the area though there are quite a few bars but doubt they are known for their chicken wings. I've had a quite a few failed attempts at cooking good chicken. Either way it's a nice spicy thing that I do enjoy even it's bad for my health. So with this a question for you guys. Anything you get regularly that's horrible for you but eat/drink it anyways?

Saturday, September 17, 2011

Busy past few days.

Well it looks like Combat project is being delayed but this time not of my own laziness entirely this time. I had gone in for an interview about a week ago and was calling in to see if I was passed up and told to come in and talk, figured it was a very formal and nice "well this is what we didn't like" thing. Long story short is that I manged to squeek into the place and will possibly be working in about a weeks time.

I'm posting this here because I do not know what I will be doing with this blog. I was having this as something to work on regularly while unemployed and now that I'm getting employed I do not know if I'll have time for it. I may end up cutting back on posts do to work but we'll see. I'll try to finish up Combat test and maybe a few other musings though but we'll see. For now I have to get prepared for some of the job things, buy a few more articles of clothing as the dress code is a little higher than I thought it would be. Either way it's an exciting time right now, I may actually get to program in a professional degree and python was actually the thing that got me in the door.

Thursday, September 15, 2011

Planing ahead

Got framework for ai punisher use for combat project done. I may or may not get it out monday but I'm close. I just need to refine a bit more but am happy how close I am. I will have to do a grammar check or something cause as it stands it has some intentional and unintentional phrasing that looks like it came out of a bad translation.

Other than that I have been making some plans for more M&M. Last time we tested a very odd character design against something that was plainly created from my experience with group fights. So something that may not be soloable at all being fought by something that abused a bit of the energy system we were using. So to make a more fair test I'm making something that isn't quite as gimmicky for both sides.

While I have some tricks for the "boss" it isn't quite as bad as the other one. Last one had some healing mechanics, position ones (knocking PC down and away so they'd take a full turn to get back), and just a lot of toughness to get through. A lot was learned but it wasn't quite a typical case. This one is more "standard" some defense tricks with psuedo summons but nothing quite as bad as the other. Throw on some standard and slightly non standard attacks and it should work alright. For the test PC I have something that is called a "blaster" in M&M's ideas. Ranged attack and nothing too fancy.

It'll be interesting to see what the energy expenditure is. For the real game the idea was you defeat monster to get energy from them, run out bad things happen. Defeating these monsters is the only way to get such energy so DM would need a good estimate on what a regular character uses in a fight. I think he vastly underestimated it with original ideas but by how much I'm not sure. It'll be an interesting experiment if we could set aside the few hours for it.I might come back here with results, I like working on M&M but have few people to talk to about it with them being DMs or players of mine.

Other than that I have one game finishing up and another that could use a bit more work on. A sandbox horror game with lots of "surprises" for my players to find. Far too many NPCs for me to keep track of and I really need to define all their quirks and relation with other NPCs. They were generated from tarot draws a while ago and have some simple back story on each one but with around two dozen even a bunch of simple back stories takes  while to flesh out.

So that's my long term entertainment. What are you guys looking forward to working on?

Wednesday, September 14, 2011

progress and doodling

I think I have my variables double checked now. Even noticed a glitch with the attack tags which I fixed. Now I need to do a few more tests and finish up implementation of AI punisher move use. After that some difficulty check and I'll just have this test be "pick a guy and beat him up". Not too involved but should be a good test to see if this idea was worth it.

Other than that I've been trying to do some more drawing and revisiting some of the things I used to do. There is a little exercise that we had in class doing "gesture drawing". The basic idea is we get a model or have a picture shown via projector for 30 to a minute and we try and get down as much as possible. Mostly an exercise for few but accurate and descriptive lines as we can't rely on a model or a scene staying the same for any extended amount of time. I did decently well with this sort of thing, in fact before formal classes I used to do something I called ten minute drawing with some guy I knew online.

Basic idea was we'd throw the other an idea and see what we could get done with it in ten minutes. Results were usually laughable and over ambitious but I always found it good practice. Tried doing some last night with friends and while the results were laughable it was good to get back into the habit so I'll see what I can get done later in it and with some gesture drawings nightly.

A tool I have abused is this site. Posemaniacs is from what I know an English translation of a Japanese site. it has a lot of 3d render models of mostly a muscle layer in various poses for both genders. The thing I used the most was the gesture drawing tool of "30 second drawing". This was practicalyl made for testing your gesture drawing skills as it will go for 30 seconds than instantly change to another random picture from it's library. I've seen a few around that do this but I like this sites. You can even shorten or lengthen the amount of time up to 90 seconds if you are just getting started at the whole thing and don't have a teacher to yell "stop" and force you to draw quicker.

That's about it, any of you doodle in your free time? Or if you're particularly brave/bored apt to throwing a link to something that you throw down in the 30 second drawing flash ap.