Yeah I finally got a fire lit under me. This fire got me to open up this old project and fix some bugs. Was a simple bug but how I got to it was something new.
So python and my monstrous amount of comments wasn't helping me and I needed some variable output. I however did not want to comment out all my debug prints, I've been doing that at work stead and didn't want to continue the practice at home. Realizing that I had an option of making a method to do print outs and just comment out the print there but would be cumbersome and possibly require some debugging itself and smart passing or something I heavily avoided in the past, global variables. Global variables must have bitten me hard at some point in the past but how I don't' remember the specifics. Effectively Global variables does what the box says, makes a variable global, this means you global i here and you change it there, the i will be the changed version later. This can easily lead to variables causing unexpected bugs as you made a temporary variable that shared the same name without realizing it.
With this in mind debug_print_variable came to mind and I slapped it down in front of every method in my level class. Checkign when things were added and when things were moved, all the fun stuff that leads to bugs. Within the first running I realized the problem. The bug of the player character hitting themselves was caused by them being initiated at the start area and then the reset function move the player to it's starting position which cuases the "attack" event to replace the move. Since the player was at the starting position I never noticed this. So good success for "bad" programing practices.
Next up I'll have to figure out what to do next with it. Maybe add a weapon upgrade to pick up.
A blog about things. How novel. Talk about games of the console, computer, and table top kind. Add some programing nonsense and some drawing nonsense. Then season with some random stuff not covered, like how I stretched a buck by eating fried flour that day.
Thursday, December 22, 2011
Tuesday, December 20, 2011
Revenge of the math
Some things just come back and bite you. The past few days I've felt the sting of things I've forgoten or ignored.
I'm horrid at math. Supposedly this is rare in computer science things but I just am. Through school I've generally programmed a calculator, which surprisingly I was allowed to get away with as somehow I knew the things by being able to program them, and just avoided those classes. College I jumped to a related degree that just plain had less math.
Last few days we needed some more graphical things set up. That required lines drawn between nearly the shortest points of some lines and some points, in other words everything I've been avoiding. The crash course has went alright, as this is not completely needed to be automated some corner cutting is needed but it is sad I've spent a lot of the past two days failing at math instead of being stuck on a programing problem. But I suppose that's life.
I'm horrid at math. Supposedly this is rare in computer science things but I just am. Through school I've generally programmed a calculator, which surprisingly I was allowed to get away with as somehow I knew the things by being able to program them, and just avoided those classes. College I jumped to a related degree that just plain had less math.
Last few days we needed some more graphical things set up. That required lines drawn between nearly the shortest points of some lines and some points, in other words everything I've been avoiding. The crash course has went alright, as this is not completely needed to be automated some corner cutting is needed but it is sad I've spent a lot of the past two days failing at math instead of being stuck on a programing problem. But I suppose that's life.
Wednesday, December 14, 2011
Still kicking post trip
Oh boy I haven't put anything up here in a while. I do have half an excuse though. Last week I was a timezone and a few states away from training and this week I have had work to deal with. The trip was interesting and we arrived in a below zero blizzard. Warmed up later though, other than that nothing to say beyond being somewhere else will ruin your ability to game as much as missing a flight home. That was an interesting 16 hours. For now though I still need to recover some more and get used to being in my native time zone and native work load.
Saturday, November 26, 2011
Neural network and work
The past week and leading up to thanksgiving has been a odd at work. They have decided to send me down to Colorado for some training as the software and my workload was sorta put on hold with preparing for this, they don't want me to start a project I can't finish before I leave, and some coworkers taking time off causing the things I could do to be a little less even though I'm at the tail end of most of the project I have. So this left me with a lot of time to think as I document and cleaned up the code and I decided to on break take up setting up some neural networks on my thumb drive.
I won't go too far into neural networks explanation as there are wikis for this. I have a bit of story on my interest in neural networks and other such research based programing though. In college I sat in on a Genetic Algorithm class for fun. I had an interest in it as I actually did some of my own exploration of it in middle or highschool after reading something in some magazine. I was using game maker way back then and doing some messing around in that that actually had some minor results, most of them being the agents evolving to find holes in my test area or simulation. Either way back at the class I was sitting in I learned a lot about them and learned the basic feed forward neural network. I had taken to making one and trying some things that hadn't been done before to my knowledge and have the neural networks learn to play tic tac toe by "learning" off each other.
This wasn't typical neural network training as I was just using the neural network to preform the work and because the concept of them seemed neat. The workhorse was a genetic algorithm picking and mutating wining agents every generation. This didn't quite work, there was something akin to subspecies in the code that more or less played rock paper scissors with each other. lets say there was 3 groups (that's what I sorta came to believe watching the games) group A would try and win diagonally, group B would try and win horizontally, and group C would try and wind vertically. The game was more or less decided on the first piece as each group had a very entrenched first move after an A agent would place it's move a B agent was basically give up and just fill in the board in a pattern that let A win, a group C would continue as normal and end up blocking the A agent while winning. similar relationship between group C and B. This let each group get enough representation in the genetic algorithms choice of fittest agents to have them represented in the next generation, which just leads to the same not really solving the problem and keeping the agents in equilibrium.
I haven't touched this problem in years but I was thinking about it on work, and decided to get some neural networks programed on break. Took a week with a lot of messing around but I got the agents to solve XOR and inverting the input which is my standard for a working neural network as I don't know too much about standards for these. I also made a "produce key" feature which allows a string to be made based on the weights and thresholds of the agent. This is actually very important to what I'm going for. While not completely versed in the genetic algorithm or neural network programing I've seen that it's kind of been leaning far to a naturalistic side of survival of the fittest. The fittest agent is taken and it has offspring that may be exactly the same or slightly different than it which does work but seems to be inefficient and leads to cycles of not solving anything as I've seen before with the tic tac toe test. So with this key I'm able to keep a "gene pool" and see if the offspring is worthwhile of being put in the next generation in regards to solving the problem. I may be wrong on this but my learning years ago didn't go on about pruning the genepool and making sure every agent is unique. So right now I have a working neural network and a will to try and revisit an old experiment and possibly produce something of worthwhile research which is some fun I haven't had in programing in a while.
I won't go too far into neural networks explanation as there are wikis for this. I have a bit of story on my interest in neural networks and other such research based programing though. In college I sat in on a Genetic Algorithm class for fun. I had an interest in it as I actually did some of my own exploration of it in middle or highschool after reading something in some magazine. I was using game maker way back then and doing some messing around in that that actually had some minor results, most of them being the agents evolving to find holes in my test area or simulation. Either way back at the class I was sitting in I learned a lot about them and learned the basic feed forward neural network. I had taken to making one and trying some things that hadn't been done before to my knowledge and have the neural networks learn to play tic tac toe by "learning" off each other.
This wasn't typical neural network training as I was just using the neural network to preform the work and because the concept of them seemed neat. The workhorse was a genetic algorithm picking and mutating wining agents every generation. This didn't quite work, there was something akin to subspecies in the code that more or less played rock paper scissors with each other. lets say there was 3 groups (that's what I sorta came to believe watching the games) group A would try and win diagonally, group B would try and win horizontally, and group C would try and wind vertically. The game was more or less decided on the first piece as each group had a very entrenched first move after an A agent would place it's move a B agent was basically give up and just fill in the board in a pattern that let A win, a group C would continue as normal and end up blocking the A agent while winning. similar relationship between group C and B. This let each group get enough representation in the genetic algorithms choice of fittest agents to have them represented in the next generation, which just leads to the same not really solving the problem and keeping the agents in equilibrium.
I haven't touched this problem in years but I was thinking about it on work, and decided to get some neural networks programed on break. Took a week with a lot of messing around but I got the agents to solve XOR and inverting the input which is my standard for a working neural network as I don't know too much about standards for these. I also made a "produce key" feature which allows a string to be made based on the weights and thresholds of the agent. This is actually very important to what I'm going for. While not completely versed in the genetic algorithm or neural network programing I've seen that it's kind of been leaning far to a naturalistic side of survival of the fittest. The fittest agent is taken and it has offspring that may be exactly the same or slightly different than it which does work but seems to be inefficient and leads to cycles of not solving anything as I've seen before with the tic tac toe test. So with this key I'm able to keep a "gene pool" and see if the offspring is worthwhile of being put in the next generation in regards to solving the problem. I may be wrong on this but my learning years ago didn't go on about pruning the genepool and making sure every agent is unique. So right now I have a working neural network and a will to try and revisit an old experiment and possibly produce something of worthwhile research which is some fun I haven't had in programing in a while.
Thursday, November 17, 2011
Legacy and Lisp
I'm terrible at updating this but still feel I should, saddly it's a life one.
Works been going a bit slow so I've been asking the other guys on some project to do as "training/downtime" things. I almost regret it, I've herad about it being the back bone for some of the systems but I don't really want to learn it. It being Lisp.
I don't hate lisp, but I just don't like working with it. Python took quite a few things from it but one thing they didn't take was it's general syntax. I was annoyed with python indentation at the start but Lisp acts like the illegitimate offspring of C and assembly. Mostly for it's polish (not even reverse polish) approach to operate syntax. A quick example to show would be a while loop and it's set up.
(setq a 0)
(while (< a 20) (setq a (+ a 1))
;worthwhile stuff goes here!
(print a)
)
That's a lot of parenthesis for something that counts from 0 to 19. I get it and easily see it becoming maddening balancing them. Thankfully I can farm out a lot of it by setting variables to be functions and going from there. At least it got me learning.
Works been going a bit slow so I've been asking the other guys on some project to do as "training/downtime" things. I almost regret it, I've herad about it being the back bone for some of the systems but I don't really want to learn it. It being Lisp.
I don't hate lisp, but I just don't like working with it. Python took quite a few things from it but one thing they didn't take was it's general syntax. I was annoyed with python indentation at the start but Lisp acts like the illegitimate offspring of C and assembly. Mostly for it's polish (not even reverse polish) approach to operate syntax. A quick example to show would be a while loop and it's set up.
(setq a 0)
(while (< a 20) (setq a (+ a 1))
;worthwhile stuff goes here!
(print a)
)
That's a lot of parenthesis for something that counts from 0 to 19. I get it and easily see it becoming maddening balancing them. Thankfully I can farm out a lot of it by setting variables to be functions and going from there. At least it got me learning.
Wednesday, November 9, 2011
Boring daily life
Haven't updated as much due to lots of "fun" things going on that weren't fun at all. Though I figure I'll post a brief amusing thing for today.
We just got hit by snow. From this morning to now we've gotten a good 3 inches possibly more and it's still coming down. Horribly wet sticky stuff that prevented me from hitting my daily place for food for lunch. Beyond that it managed to somehow kill the power on the grid at least 3 times. Lot of interesting things said when those power outages hit in a place that's suppose to have an uninterrupted power supply and everyone on a computer.
I may start gearing up for something soon, just been an odd past few weeks. I would like to get the python tutorials to "make your own fighter" stage which shouldn't be hard if I sit down for a few hours one of these days but it's been last on my list. You guys have probably been there before.
We just got hit by snow. From this morning to now we've gotten a good 3 inches possibly more and it's still coming down. Horribly wet sticky stuff that prevented me from hitting my daily place for food for lunch. Beyond that it managed to somehow kill the power on the grid at least 3 times. Lot of interesting things said when those power outages hit in a place that's suppose to have an uninterrupted power supply and everyone on a computer.
I may start gearing up for something soon, just been an odd past few weeks. I would like to get the python tutorials to "make your own fighter" stage which shouldn't be hard if I sit down for a few hours one of these days but it's been last on my list. You guys have probably been there before.
Saturday, October 29, 2011
a roguelike update?
So after weeks of doing nothing with it and playing with other Tkinter components I present.
It's an update. Not the best one and actually glitchy. There are quite a few things I don't like about it but following the ideas for making a roguelike I shouldn't be so hard on myself.
First is that it's hard coded, the 5 lines you see there are positioned there, I'd like it to be at the bottom of the viewable screen. This could possibly be easy to do but I was tired when I finally finished this up so it got hard coded to see it. Not something I should beat myself up over but I like dynamic structures, it helps for changing layouts later.
Second Tkinter canvas centers blocks of text. I do not like this at all. I may have to write my own code to properly justify things to the left. Not sure why Tkinter would think this is a good way to do things considering it works on standard top left coordinate scheme but it's the reality, maybe there is an option to do it that way.
Third it doesn't work. It fills out fine until the sixth item is hit, in which it should "push" all the ones before it up once and the topmost one into nothing. Right now it doesn't do that and I didn't get into the guts to find out why.
Fourth odd glitch. Players will hit themselves after moving on their first spawn. I do not know why but only noticed this with output.
Now for the nice things.
I got it done. It's progress. More than that I discovered a nice feature, with the way I have things move and attack each other enemies moving into each other will attack. This lead to some very confused minutes when I noticed this but it works exactly as it should. I would just need to add in some triggers to count allies as walls for movement purposes to avoid friendly fire, for now it's funny.
It's an update. Not the best one and actually glitchy. There are quite a few things I don't like about it but following the ideas for making a roguelike I shouldn't be so hard on myself.
First is that it's hard coded, the 5 lines you see there are positioned there, I'd like it to be at the bottom of the viewable screen. This could possibly be easy to do but I was tired when I finally finished this up so it got hard coded to see it. Not something I should beat myself up over but I like dynamic structures, it helps for changing layouts later.
Second Tkinter canvas centers blocks of text. I do not like this at all. I may have to write my own code to properly justify things to the left. Not sure why Tkinter would think this is a good way to do things considering it works on standard top left coordinate scheme but it's the reality, maybe there is an option to do it that way.
Third it doesn't work. It fills out fine until the sixth item is hit, in which it should "push" all the ones before it up once and the topmost one into nothing. Right now it doesn't do that and I didn't get into the guts to find out why.
Fourth odd glitch. Players will hit themselves after moving on their first spawn. I do not know why but only noticed this with output.
Now for the nice things.
I got it done. It's progress. More than that I discovered a nice feature, with the way I have things move and attack each other enemies moving into each other will attack. This lead to some very confused minutes when I noticed this but it works exactly as it should. I would just need to add in some triggers to count allies as walls for movement purposes to avoid friendly fire, for now it's funny.
Subscribe to:
Posts (Atom)