Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Poll

What programming topic would you want the next challenge to be about?  (It might be a good opportunity to focus on a subject you're not familiar with or to reinforce knowledge on one that you already know)

Control Flow
- 2 (2.2%)
Arrays, Strings, Pointers, and References
- 8 (9%)
Functions
- 4 (4.5%)
Basic object-oriented programming
- 30 (33.7%)
A bit more advanced OOP (Composition, Operator overloading, Inheritance, Virtual Functions)
- 18 (20.2%)
Templates
- 8 (9%)
Other (Explain)
- 4 (4.5%)
Working with files?  (Streams)
- 15 (16.9%)

Total Members Voted: 89


Pages: 1 ... 49 50 [51] 52 53 ... 78

Author Topic: Programming Challenges & Resources (#bay12prog) Initiative  (Read 95918 times)

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #750 on: January 03, 2011, 01:35:38 pm »

Looks nice. I just have one question:
Spoiler (click to show/hide)
« Last Edit: January 03, 2011, 04:17:21 pm by Virex »
Logged

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #751 on: January 03, 2011, 01:46:29 pm »

Looks nice. I just have one question:
Spoiler (click to show/hide)

Broken.

Why don't you try to compile it?

What it does is output the title "Robot Rainbow Ostrich Attack" thrice and the prompt once, then wait for input. It then removes end puncuation like periods and the pronoun "I" and places it into an output phrase. It's not that complex.

Just hard to read, I guess. :P
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #752 on: January 03, 2011, 04:18:03 pm »

I gathered as much. I assume you tried to obfuscate it intentionally? Else I should probably slap you for your coding style...
Logged

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #753 on: January 03, 2011, 04:19:58 pm »

I don't normally code like that, no. If I did I'd have to slap myself.

I ignored spacing and stuff just to shrink it, and proceeded to obfuscate it just for kicks. I can probs do better but there you go.
Logged

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #754 on: January 09, 2011, 06:42:44 am »

Sorry for the doublepost & mininecro, but would this work?

Code: (C++) [Select]
enum Status
{
UNSCATHED,
SUPERFICIAL,
MINOR_DAMAGE,
MODERATE_DAMAGE,
HEAVY_DAMAGE,
FUNCTION_LOSS,
DEVASTATING,
MISSING
};

enum SpecProperties
{
BLANK,
BRAIN,
BREATHING,
LOADBEARING,
SEEING
};

class BodyPart
{
public:
int nSize; //Use heads as a metric. NOT THE SAME AS CREATURE SIZE
int nToughness;
int nHealth;
int nPainDelta; //How much "Pain" added per stage
int nBloodDelta; //How much blood is lost per turn per stage
int nOxygenDelta; //How much oxygen is lost per turn per stage
bool bEssential; //Essential to life, really.
Status eStatus;
SpecProperties eProperty;
BodyPart(int Size = 1, int Toughness = 1,
int Health = 100, bool Essential = false, SpecProperties Property = BLANK, int PainDelta = 25, int BloodDelta = 25, int OxygenDelta = 0)
{
nSize = Size;
nToughness = Toughness;
nHealth = Health;
bEssential = Essential;
eStatus = UNSCATHED;
eProperty = Property;
nPainDelta = PainDelta;
nBloodDelta = BloodDelta;
nOxygenDelta = OxygenDelta;
};
private:
}

class Humanoid
{
public:
bool bIsAlive;

int nCurrentBlood;

const int nCurrentBlood = 5000;

BodyPart Head(int Size = 1, int Toughness = 10,
int Health = 100, bool Essential = true);

BodyPart Torso(int Size = 6, int Toughness = 60,
int Health = 600, bool Essential = false);

BodyPart UpperlegL(int Size = 2, int Toughness = 20,
int Health = 200, bool Essential = false);
BodyPart UpperlegR(int Size = 2, int Toughness = 20,
int Health = 200, bool Essential = false);

BodyPart LowerlegL(int Size = 2, int Toughness = 20,
int Health = 200, bool Essential = false);
BodyPart LowerlegR(int Size = 2, int Toughness = 20,
int Health = 200, bool Essential = false);

BodyPart FootL(int Size = 1, int Toughness = 10,
int Health = 100, bool Essential = false);
BodyPart FootR(int Size = 1, int Toughness = 10,
int Health = 100, bool Essential = false);

BodyPart HandL(int Size = 1, int Toughness = 10,
int Health = 100, bool Essential = false);
BodyPart HandR(int Size = 1, int Toughness = 10,
int Health = 100, bool Essential = false);

BodyPart UpperarmL(int Size = 2, int Toughness = 20,
int Health = 200, bool Essential = false);
BodyPart UpperarmR(int Size = 2, int Toughness = 20,
int Health = 200, bool Essential = false);

BodyPart LowerarmL(int Size = 1, int Toughness = 10,
int Health = 100, bool Essential = false);
BodyPart LowerarmR(int Size = 1, int Toughness = 10,
int Health = 100, bool Essential = false);

BodyPart Brain(int Size = 1, int Toughness = 0,
int Health = 30, bool Essential = true);
BodyPart Guts(int Size = 4, int Toughness = 20,
int Health = 300, bool Essential = false);
}

Or should I just make a constructor for that?
Logged

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #755 on: January 09, 2011, 11:56:49 pm »

Question:
I've got some programming experience (Java, bash, some perl), and I'm trying to getting into C/C++ (again). So far I've done a little toying with SDL in (I assume pure) C. Should I focus on C, or jump straight into C++? As I understand, C++ is mostly a superset of C.

Contribution:
 - A decent SDL tutorial: http://lazyfoo.net/SDL_tutorials/index.php

So far, I've created this:
The main thing that's new for me here is building my own event loop.

(I'm working on Arch Linux mostly, using GCC 4.5.2.)

EDIT: discussion's moved waaay on, so I'm not posting an actual follow-up, but I've decided to focus on C for now.
« Last Edit: January 14, 2011, 02:55:57 pm by SolarShado »
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #756 on: January 10, 2011, 02:04:24 am »

Different people will give different answers for "C or C++". Mainly whether C++ adds great new features, or unnessecary bloats (different names and opinions on the same features).

In my opinion, I feel that it falls more into the bloats category (with exceptions and operator overloading, code suddenly jumping elsewhere without informing the reader is just too easy, or worse, the reccomended thing to do), butit should be up to the individual to decide their opinion, and thus if they use one or the other.
Logged
Eh?
Eh!

Shades

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #757 on: January 10, 2011, 03:25:10 am »

I would recommend C++ over C for pretty much the same reasons as qwertyuiopas doesn't like it (exceptions and overloading. code jumps that aren't exception states are a bad idea, of course you can do that in c as well)

I'd also say the more languages you know the better so there is no reason not to learn C++
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Blank Expression

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #758 on: January 10, 2011, 02:25:43 pm »

In my opinion, I feel that it falls more into the bloats category (with exceptions and operator overloading, code suddenly jumping elsewhere without informing the reader is just too easy, or worse, the reccomended thing to do), butit should be up to the individual to decide their opinion, and thus if they use one or the other.
Your standard library already includes functions that "jump elsewhere" when invoking operators. Allowing a developer to overload it for the purpose of adding together vectors, for example, in a completely and utterly straightforward manner that is completely in line with standard mathematics, increases readability and understanding of code flow.

C++ includes exceptions because exceptional conditions exist. Error codes are a poor substitute and most uneducated and unskilled programmers--i.e., the majority of people reading this thread--will not religiously check them. It is the height of irresponsibility to advocate that people make choices that result in less safe code.

This may be your "opinion," but opinions can be judged on merit, and this one lacks merit. If overloaded operators and exceptions result in you being confused by your own code flow, you should not be writing code.




It's clearly evident that the overwhelming majority of people posting in this thread should be using neither C nor C++ to begin with, but something considerably less unsafe. (The person--Supermikhail, I think it was--saying that they use int16 instead of int32 because of "my OCD" is a perfect example of this, as allocating an int16 in modern desktop C/C++ actually allocates 4 bytes; the request to memory returns those 4 bytes and the top bits are masked away. Your tools have been developed over decades by people who are in all likelihood smarter than you and are vastly better programmers than you. Understand their decisions before you do things that intentionally act contrary to established wisdom.)
« Last Edit: January 10, 2011, 02:33:02 pm by Blank Expression »
Logged

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #759 on: January 10, 2011, 02:33:02 pm »

I assume you are a professional/experienced programmer then, or at least knowledgeable enough to talk about this?

And if you consider C/C++ too unsafe, what would you recommend, then?

Oh, and welcome to Bay12, Blank Expression.
Logged

Blank Expression

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #760 on: January 10, 2011, 02:39:27 pm »

I assume you are a professional/experienced programmer then, or at least knowledgeable enough to talk about this?
I have just under eight years of professional experience. I have been programming as a hobbyist for fifteen years.

Quote
And if you consider c/C++ too unsafe, what would you recommend, then?
The short answer is "nearly anything else." Python, C#, Java, whatever. The problem lies in the thin abstraction layer of C/C++; C++ attempts to rectify this by including some aspects of more modern programming languages (exceptions, for example). The Boost library attempts to go further (see Boost::Bind, and some of the Boost stuff pulled into TR1). But it is a poor facsimile.

I recommend C# and Java because I find a purely object-oriented approach to be more pedagogically sound than something like Python, where it is bolted on in, my opinion, a bit sloppily, but for a novice, Python is leaps and bounds both safer and saner than C or C++. The folks at GDNet tend to espouse a similar viewpoint, for similar reasons.

Oh, and welcome to Bay12, Blank Expression.
Thank you. :)
« Last Edit: January 10, 2011, 02:41:37 pm by Blank Expression »
Logged

Shades

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #761 on: January 10, 2011, 02:54:46 pm »

I have just under eight years of professional experience. I have been programming as a hobbyist for fifteen years.

A better look at your experience would probably be how many languages you know well enough to consider yourself competent in. I know enough developers with X years of experience who have just being doing the same thing over and over so could also have been classed as X months of experience. Not saying you are just that I've never found time to be a good indicator among co-workers.

That fact your a hobbyist as well is probably more important from an has actually bothered to learn stuff point of view of course. There appear to be a large number of developers on this forum, must be something about DF that attracts them ;)
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Blank Expression

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #762 on: January 10, 2011, 03:09:31 pm »

A better look at your experience would probably be how many languages you know well enough to consider yourself competent in. I know enough developers with X years of experience who have just being doing the same thing over and over so could also have been classed as X months of experience. Not saying you are just that I've never found time to be a good indicator among co-workers.
My experience should be self-evident from that I am demonstrating a knowledge of what I'm actually talking about, but sure. I can write production-quality code in C, C++, C#, Java, Scala, Groovy, Scheme, Lisp, Visual Basic 4/5/6, VB.net, PHP, Python, Ruby, tcsh, bash, and I have a decent grasp of SQL.

I have worked in a contractor role for Google, have successfully run a consulting business, my name is in the commit logs of a few well-known open source projects, and I currently work for a company whose web application is in the top 300 Alexa rankings worldwide.


This has nothing to do with my point that C and C++ are thin abstractions that are poor starting places for people to learn how to write code, but if the argument from authority is what you want...
Logged

Shades

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #763 on: January 10, 2011, 03:21:48 pm »

This has nothing to do with my point that C and C++ are thin abstractions that are poor starting places for people to learn how to write code, but if the argument from authority is what you want...

It's not what I want but I was querying your initial assertion, and I'd disagree that c++ is any poorer a starting place from c#, probably both python and java and cleaner models for learning though.
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Blank Expression

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #764 on: January 10, 2011, 03:24:48 pm »

This has nothing to do with my point that C and C++ are thin abstractions that are poor starting places for people to learn how to write code, but if the argument from authority is what you want...

It's not what I want but I was querying your initial assertion, and I'd disagree that c++ is any poorer a starting place from c#, probably both python and java and cleaner models for learning though.
You will be very hard pressed to substantiate this. C++ has an antiquated memory model, requires the use of brutal hacks like the *_ptr classes from Boost, and nearly demands leaky abstraction via friend, MI, and other methods of tangling the class hierarchy. Languages on the .NET framework, by and large, lack these problems. As well, I find it very interesting that you make the curiously irrational claim that C# is not a cleaner model, but Java is. You are aware, I hope, of the similarities between the two (damned near identical in most aspects that matter to a novice)?

In addition, regardless of what C++ toolchain you deal with, you'll encounter similarly user-hostile software. The same can't be said of Visual Studio--whatever your personal preference in the IDE holy war, it's incredibly difficult to assert that it isn't both fantastic and very, very popular.
« Last Edit: January 10, 2011, 03:32:03 pm by Blank Expression »
Logged
Pages: 1 ... 49 50 [51] 52 53 ... 78