Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 197 198 [199] 200 201 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 887325 times)

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2970 on: September 27, 2012, 06:17:01 pm »

And you can't see other people's solutions for a problem there, until you answer it correctly.  The reduce(lcm, xrange(2, 21)) solution is just so much better than mine that I wish I'd thought of it.

I think its still in the spirit of things if you've already come up with your own solution.  As long as you understand why the other version works.
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2971 on: September 27, 2012, 08:14:45 pm »

Does anyone know any good guides for either Java, C++, or Robot C? 
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #2972 on: September 27, 2012, 08:26:03 pm »

Java and C++ both have decent web tutorials and resources online...
Not sure about books, though. :3

On the topic of Euler: has anyone solved the last few pages? A single problem? xD I bet the forums over there are pretty quiet...

I think I'll try my hand at the easier ones, though it's hard to think of any method other than brute-force... for the first one, I have an idea that might be faster than brute-force.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2973 on: September 27, 2012, 08:37:30 pm »

Almost nine months ago, I helped spawn this thread by fumbling around with C# on a whim.  I had gone to an incredibly depressing New Years party and decided I really needed a fucking hobby, and I fell in love with C# when I saw it.  Some stuff happened over the next couple weeks that convinced me to go to a job recruiter, and when they asked me about any skills or hobbies I mentioned that I was teaching myself computer programming.  They hooked me up with this schmuck who'd previously gone to them, and after a few weeks of interning with him, he hired me full time as the first employee of a new branch company.

The code that I had taken up as a hobby and really enjoyed suddenly became a forty hour a week chore.  It became physically impossible to even look at code when off the clock.  After six months, I think I've finally crossed over the hump, and my job coding has become routine enough that I have the willpower to work for myself at home.  And with an old friend of mine having a similar experience with 3D modeling, well lets just say the garage band is finally coming together.

In the meantime, I'm finally working on a roguelike again.  Big ideas are not a new thing, but the familiarity to see how all the parts are going to fit together sure is.  On that subject, what's the craziest sort of enumerated listing you've abused in your code?  I'm currently working with a Dictionary<string, Dictionary<string, Dictionary<int, int>>> and it's not putting up a fight yet.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2974 on: September 27, 2012, 08:51:20 pm »

Java and C++ both have decent web tutorials and resources online...
Not sure about books, though. :3
All programming books are lacking 2 very important features:
1. google indexing
2. ctrl f

Stick to web resources; there are plenty. Even when doing pretty advanced stuff, there are almost always better or easier to use resources online; be they Rastertek for graphics programming tutorials or vterrain for procedural world generation. They often also have either full source or download links right on the page; whereas with a book you will often find dead web pages accompanying them.
Logged

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2975 on: September 27, 2012, 08:52:19 pm »

On that subject, what's the craziest sort of enumerated listing you've abused in your code?  I'm currently working with a Dictionary<string, Dictionary<string, Dictionary<int, int>>> and it's not putting up a fight yet.

The most abuse I've ever put it through is List<List<List<Tile>>> where "Tile" is pretty much what it looks like. I should try some whackier things though, it sounds fun...
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2976 on: September 27, 2012, 09:05:11 pm »

On that subject, what's the craziest sort of enumerated listing you've abused in your code?  I'm currently working with a Dictionary<string, Dictionary<string, Dictionary<int, int>>> and it's not putting up a fight yet.

The most abuse I've ever put it through is List<List<List<Tile>>> where "Tile" is pretty much what it looks like. I should try some whackier things though, it sounds fun...

That's kinda what I'm doing.  The triple dictionary was my original idea, I've scaled it back to a double dictionary in a containerizing object.  The idea with the Dictionary<string, Dictionary<string, Dictionary<int, int>>> was that the outermost dictionary would be the type of tile (door, horizontal wall, etc), the second dictionary was the style (room, cave, whatever), and the innermost was the important one, as the Key int would be the ASCII mapping code and the value would be the probability.  To generate a map, the correct type and style would be handed to a function that randomly picks a mapping code based on the probabilities.  The same thing would be done with colors.

I decided that instead of one whopping great static dictionary to contain all that crap, I'd make a VisualStyle container to cut out the middle dictionary, and keep tilesets and colors together.  I'm not totally pleased with any one design, just because there's so many arbitrary tasks in a videogame, but I think I'm reaching a good balance between explicit and flexible.

The text paging function I whipped up a couple weekends ago still impresses me, I'll have to find a place for it in a roguelike.  And man, the activity controller is going to be beautiful.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2977 on: September 28, 2012, 12:04:03 am »

Does anyone know any good guides for either Java, C++, or Robot C?

I'm familiar with all 3. I taught myself C++ 3 years ago (and have been writing a tutorial here; see the OP), I learned Java last year and programmed competitively with it (Stargrasper has been writing a tutorial here; see the OP), and I was the lead programmer for Robotics at my high school last year. I used RobotC exclusively.

I consider this to be a good C++ tutorial. Also, this site has good reference material for C++. I'm not sure about a Java guide, as I learned it in a classroom setting, with a textbook. C++ and C are very similar, and C and RobotC are also very similar, so learning C++ should give you a good feel for RobotC. If you have any questions about any of those 3, feel free to ask here.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #2978 on: September 28, 2012, 12:42:43 am »

I worked hard on my intelligent method for Euler Problem One, and it's slower than the brute force method of trial division. :<

I was bored, so I made this:


The Euler problems are pretty close to logarithmic distribution, judging by the near linear log scale graph. I wonder why question 209 has a sudden spike in correct replies, along with question 205.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2979 on: September 28, 2012, 01:08:28 am »

205 and 209 are fairly easily solved by brute-force, which is a rarity in the higher-numbered problems.

EDIT: That is, if you have the proper tools. I wrote Python code to brute force 205, only to discover that I have Python 2.6, and one of the functions I am trying to use (itertools.combinations_with_replacement) is only available in 2.7 and onwards. Compiling time!
« Last Edit: September 28, 2012, 01:42:01 am by Mego »
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2980 on: September 28, 2012, 06:39:23 am »

When you say you brute-forced 205, what exactly do you mean by that? Also Skyrunner, what exactly was your alternate method for problem 1?
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2981 on: September 28, 2012, 04:58:52 pm »

I've done problems 1 - 15 of projecteuler,  but haven't done one in a while.

and, C++ question,
ok, so before now I've never done projects with multi file source code,  I'm sure my book covers it, but it's probably like 200+ pages later, so I was wondering if I could get a quick rundown on using them.

ok, so there are .h and .cpp files, yeah?
.h are for objects and .cpp are for object functons? and you just #include the files together?
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #2982 on: September 28, 2012, 05:10:24 pm »

A header file is for declaration of publicly accessible functions. It essentially provides the interface for your class so that you could distribute it as a binary object and people could still build code that references its methods.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2983 on: September 28, 2012, 05:17:33 pm »

I've done problems 1 - 15 of projecteuler,  but haven't done one in a while.

and, C++ question,
ok, so before now I've never done projects with multi file source code,  I'm sure my book covers it, but it's probably like 200+ pages later, so I was wondering if I could get a quick rundown on using them.

ok, so there are .h and .cpp files, yeah?
.h are for objects and .cpp are for object functons? and you just #include the files together?

Well, sort of. Typical project design puts class definitions (with function prototypes, not definitions) in header files, and then a source file #include's the header file and defines the member functions. Like so:

Spoiler: foo.h (click to show/hide)
Spoiler: foo.cpp (click to show/hide)

That's not the only purpose of headers, though. I have been ninja'd by Nadaka. Headers are used to write code that will be used in multiple places, potentially across multiple files. They're like utilities that the source files can access to do what they need to do.

Spoiler: Secrets about headers (click to show/hide)

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2984 on: September 28, 2012, 05:18:03 pm »

A header file is for declaration of publicly accessible functions. It essentially provides the interface for your class so that you could distribute it as a binary object and people could still build code that references its methods.

so, if the header file is ONLY for publicly accessible functions, I can't put private class variables in it?  :confused:



Ohh, thank you Mego
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.
Pages: 1 ... 197 198 [199] 200 201 ... 796