Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Simulator/Generator/Something else Program  (Read 2586 times)

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Simulator/Generator/Something else Program
« Reply #15 on: August 19, 2011, 11:01:07 am »

It's not like it's hard for some people to make ideas. I have more than I could ever make myself. Basically, chill out is what I'm saying. Everyone has creative slumps, and working on something you otherwise never would have helps to push through them.
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

ottottott

  • Bay Watcher
    • View Profile
Re: Simulator/Generator/Something else Program
« Reply #16 on: August 19, 2011, 02:00:53 pm »

Eagle, I'll get back to your 2nd to last reply soon, don't have time to give a good opinion right now. =( I do like the idea though, and would definitely try to make something.
Virex, sorry, but oh good lore too much complicated reading without a clear purpose for me.
Brigg, that's a rather harsh way to put it, and not entirely true. I wait until I get an idea that I know how to make. 'cause something that generates the outcome of a paradox... Well it's a joke anyways.
« Last Edit: August 23, 2011, 05:22:42 am by ottottott »
Logged

ottottott

  • Bay Watcher
    • View Profile
Re: Simulator/Generator/Something else Program
« Reply #17 on: August 23, 2011, 05:30:34 am »

I've tried making something from the idea Eagleon gave me. Surprisingly, I haven't had much time. I got over 2KB of ideas, and over 5.5KB of code. (And comments. I like putting comments everywhere, where it might not be clear, when looked on. I make them short though. That way they take little space, but help me, and others, who would like to change something.)
Would there be anyone, who'd want to try this? You'd need to have Python (2.7.x I don't know, why I never started to use 3.x.x) installed, which is probably too much to do just for this.
« Last Edit: August 23, 2011, 07:19:34 am by ottottott »
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Simulator/Generator/Something else Program
« Reply #18 on: August 24, 2011, 12:50:58 am »

Would like to look at what you have. I've been considering working on it myself if you didn't want to continue it, haha.
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

ottottott

  • Bay Watcher
    • View Profile
Re: Simulator/Generator/Something else Program
« Reply #19 on: August 24, 2011, 10:21:00 am »

I'd say the part, where you get damaged in combat, is complete. Currently, it just hits you in a random location, with random strength, calculates any pain, damage, blood loss... Stuff like that. Any feedback is appreciated.
The file is here.
The ideas are here.
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Simulator/Generator/Something else Program
« Reply #20 on: August 24, 2011, 02:30:26 pm »

Looks like a good start :) For further inspiration I suggest playing Godwars II, that's where the idea germinated. If I had that combined with something like Magicka I'd be a very happy bread.

Out of curiosity, why are you abandoning Python? Not that you shouldn't learn C++, but there are a lot of uses for it where C++ is less forgiving. Since you can link one to the other, there's no reason you couldn't keep learning both if you like Python's structure/grammar.
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Simulator/Generator/Something else Program
« Reply #21 on: August 24, 2011, 02:58:21 pm »

I'd say the part, where you get damaged in combat, is complete. Currently, it just hits you in a random location, with random strength, calculates any pain, damage, blood loss... Stuff like that. Any feedback is appreciated.
The file is here.
The ideas are here.
I admire your patience, but a 18-part else-if statement is usually a sign that you're doing something the hard way (and as a programmer you should usually shun the hard way ;) ). In this case you're associating the different parts of a body with a numeric value, which though very possible, could easily lead to bugs later on because you switched two numeric values in your mind or something. In this case I'd make a body part class that stores the name and status of every body part and store all those body parts in the player class (to which you can later add more auxiliary data if needed). for information on how to use classes in python, see this or consult your favorite source.
Logged

Biag

  • Bay Watcher
  • Huzzah!
    • View Profile
Re: Simulator/Generator/Something else Program
« Reply #22 on: August 24, 2011, 03:45:53 pm »

I very much agree with Virex. Changing the 'player' variable from a nested list to a class would do a lot to improve readability, as well.
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Simulator/Generator/Something else Program
« Reply #23 on: August 25, 2011, 12:07:08 am »

I agree to an extent. You're still going to have to spend just as long initializing each part if you make a part class as the nested statement. As long as you're willing to pay the price in reusability, reverting to procedural programming in OOP can help a bit. Using integers is ugly, though - much better to use a bitmask, or just something like this
Code: [Select]
public Connection (BodyPart startpoint, BodyPart endpoint, String name, String type) {
A = startpoint;
B = endpoint;
Name = name;
Health = (A.Health + B.Health)/2;
Resist = (type.contains("R") ? (A.Resist + B.Resist) : 0);
Blood = (type.contains("D") ? 0 : Blood);
Blood = (type.contains("V") ? ((startpoint.Blood + endpoint.Blood)/2) : 0);
Nerve = (type.contains("N") ? 100 : 0);
VitalA = type.contains("XA");
VitalB = type.contains("XB");
Surround = type.contains("S");
Part = type.contains("P");
}
Lovely, lovely ternary operators. Why have I neglected you for so long? Used if statements, then I looked for a way to convert booleans to 1 or 0 so that I could multiply by my desired value, then I found out it's not even necessary. I miss working on new stuff for this, I always end up appreciating some other feature I hadn't cared about before.

Don't give me guff about using a string as a compact parameter - I'd rather remember a few letters than have to deal with some monsterously ugly 20-parameter constructor, and a parameter class would be just as irritating, just elsewhere :P

ottottott - would it be off-putting if I continued this? I seriously don't want to step on your shoes here, and I want to see where you take it, it's just that sometimes an idea will seize me and it can be very hard to stop. The above is after a night tinkering at a friend's house. If it helps, I'll probably get bored and return to my regularly scheduled programming soon (ouch)
« Last Edit: August 25, 2011, 12:08:54 am by Eagleon »
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

ottottott

  • Bay Watcher
    • View Profile
Re: Simulator/Generator/Something else Program
« Reply #24 on: August 25, 2011, 12:36:23 am »

Got a lot of replies. =D Let's start with the 1st one.
Out of curiosity, why are you abandoning Python? Not that you shouldn't learn C++, but there are a lot of uses for it where C++ is less forgiving. Since you can link one to the other, there's no reason you couldn't keep learning both if you like Python's structure/grammar.
I think Python doesn't allow me to do as many things as I'd want. Since I like making games or something of that sort, I'd need graphics, and since most people don't have Python, (And Python has 2 active versions, both are used about equally as far as I see.) they wouldn't be able to use anything I make, without getting it. I'm not going to bother explaining, why I wouldn't use 3rd party tools for having those 2 possibilities, that Python doesn't have. I do like Python's easy grammar/structure. Also, what's this about linking one to the other?
I admire your patience, but a 18-part else-if statement is usually a sign that you're doing something the hard way (and as a programmer you should usually shun the hard way ;) ). In this case you're associating the different parts of a body with a numeric value, which though very possible, could easily lead to bugs later on because you switched two numeric values in your mind or something. In this case I'd make a body part class that stores the name and status of every body part and store all those body parts in the player class (to which you can later add more auxiliary data if needed). for information on how to use classes in python, see this or consult your favorite source.
Err, I changed that 19 lines long body part name identification. It's now 1 long list of names. Also did the same with the other one in the status function. =) I'm OK with using those numbers, I don't remember what's what anyways. That's why I have a list like that, I previously talked about, to remind me. I'm really not afraid of a problem there. And yes, about classes, didn't quite learn them. I kinda' know how to use them, but at my current level of knowledge about them, it's easier to use a list. And unless someone can convince me, which is really difficult, I won't learn more Python.
stuff
Honestly, I'm not sure what you did there... <_< Go ahead and continue, I guess... >_>
« Last Edit: August 25, 2011, 12:44:46 am by ottottott »
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Simulator/Generator/Something else Program
« Reply #25 on: August 25, 2011, 04:15:53 am »

Got a lot of replies. =D Let's start with the 1st one.
Out of curiosity, why are you abandoning Python? Not that you shouldn't learn C++, but there are a lot of uses for it where C++ is less forgiving. Since you can link one to the other, there's no reason you couldn't keep learning both if you like Python's structure/grammar.
I think Python doesn't allow me to do as many things as I'd want. Since I like making games or something of that sort, I'd need graphics, and since most people don't have Python, (And Python has 2 active versions, both are used about equally as far as I see.) they wouldn't be able to use anything I make, without getting it. I'm not going to bother explaining, why I wouldn't use 3rd party tools for having those 2 possibilities, that Python doesn't have. I do like Python's easy grammar/structure. Also, what's this about linking one to the other?
http://docs.python.org/extending/embedding.html this can get you started with using Python functions within C++, when you learn the prerequisites. Basically, the python interface (Python.h in the sample code) enables you to load up a python file and run the interpreter from within your C++ program, passing along whatever information you need to a function. From that function you can do whatever you want - build a whole game, call C++ functions by doing the reverse, whatever - and the C++ code will resume when the first function you called exits (without getting into threads). A lot of games will use multiple languages (including python) to share the strengths of each, particularly if they're intended to be moddable.

I'd say that if you're going to be learning C++, you're going to get used to using external libraries ;) Unless you want to code everything yourself, which is an exercise in frustration at the level C++ operates, though it can be quite interesting if you have the right mindset. C++ by itself does not have the kind of graphics support that modern games require either - its strength is that you can make that support yourself, on any hardware, but you're probably going to be using something like Allegro or Crystal Space for sanity's sake. With that in mind, Python does have libraries/tools for both problems you have with it - PyGame and Py2Exe come to mind.

Honestly, I'm not sure what you did there... <_< Go ahead and continue, I guess... >_>
The meat of it is the use of the ternary operator - in python it would be Blood = 100 if "V" in String else 0. Essentially, they're reallly, really compact if-else statements, with the left-hand side (100) being outputted if the conditional is true (String.contains() in Java outputs a boolean if a given string has a substring), and the right-hand (0) if it's false. So Blood would be 100 if "V" were in the string, 0 if not. Of course you don't have to use the else portion - just do like Blood = 100 if "V" in String else Blood. In my original snippet, it trims
Code: [Select]
if (type.contains("V")) {
    Blood = (startpoint.Blood + endpoint.Blood)/2;
} else if (type.contains("D")) {
    Blood = 0;
}
down to
Code: [Select]
Blood = (type.contains("D") ? 0 : Blood);
Blood = (type.contains("V") ? ((startpoint.Blood + endpoint.Blood)/2) : 0);
Cute little ternary operator, asking type a question :3
« Last Edit: August 25, 2011, 04:20:22 am by Eagleon »
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

ottottott

  • Bay Watcher
    • View Profile
Re: Simulator/Generator/Something else Program
« Reply #26 on: August 25, 2011, 10:14:44 am »

Well, that sounds interesting, and possibly useful. I'll look into all that more, once I've learned enough C++.
About PyGame and Py2Exe, I've tried them. Been trying for 6 hours total, can't get either to work.
Logged
Pages: 1 [2]