Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 384 385 [386] 387 388 ... 796

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

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #5775 on: April 29, 2014, 07:01:53 pm »

Well for C++, the IDEs aren't that great. You can achieve most of what an IDE will give through hooking vim or emacs to clang for auto-complete. Some of the latest C++11 IDEs (VS 2013 and Jetbrains) can also provide some decent type deduction for when you use auto (i.e Hold CTRL and hover over the variable name for the full type to be presented). The refactoring support is still fairly crude, only Jetbrains really have anything decent and that's still in a very early access program. For compiling I still do all the C++ stuff by cmd/shell.

Though for C#, Java, Scala etc. Can't work without an IDE. The IDEs are much easier to use and the refactoring support is too great :P
« Last Edit: April 29, 2014, 07:03:57 pm by MorleyDev »
Logged

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5776 on: April 29, 2014, 07:38:47 pm »

For my English project on Hamlet I am making a game where you are presented with some story information and then make a choice.  Instead of putting everything into the code itself I decided to have it read from a text file.  My problem is that I am currently getting a NullPointerException.  Normally I would try to fix this myself, but I'm getting it in the part of the code that my Comp Sci teacher gave us specifically to allow us to do stuff without learning IO, even thou he did encourage us to try. 
Spoiler: my code (click to show/hide)
Spoiler: IO stuff I was given (click to show/hide)
The place where I am getting the error is Line 52 in the IO code, where it says "try{return in.nextLine();}"
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.

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5777 on: April 29, 2014, 10:41:31 pm »

For my English project on Hamlet I am making a game where you are presented with some story information and then make a choice.  Instead of putting everything into the code itself I decided to have it read from a text file.  My problem is that I am currently getting a NullPointerException.  Normally I would try to fix this myself, but I'm getting it in the part of the code that my Comp Sci teacher gave us specifically to allow us to do stuff without learning IO, even thou he did encourage us to try. 
--- snip ---
The place where I am getting the error is Line 52 in the IO code, where it says "try{return in.nextLine();}"

That IO code is terrible...

The problem is a cascade of your file path not being valid: "Libraries\Documents\info" is interpreted as relative path; you probably need the absolute path (which should start with "C:\").

The NPE is because of this
Code: (from the provided IO code) [Select]
  try{in = new Scanner(new FileInputStream(name));}
  catch(java.io.FileNotFoundException e){}

That silently swallows the vastly more informative FileNotFoundException and leaves in unassigned (and therefore null).

I'm guessing you haven't gotten to exception handling yet either, or that constructor should have throws FileNotFoundException on it so your code can catch the exception.

Also, style tip/nitpick: class names should start with a capital letter.

EDIT: i fail bbcode...
« Last Edit: April 29, 2014, 11:17:53 pm by SolarShado »
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #5778 on: April 29, 2014, 10:46:07 pm »

I am going to embark on programming a text adventure with nothing but a TI-89 Titanium calculator. I will post the results later.
Heh, I got my start in programming on a TI-86. Not fun on a tiny LED screen, but it's better than math class.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5779 on: April 30, 2014, 05:56:52 am »

That was the problem.  I know know why I didn't spot that myself sooner.  Now time to get to regular unwanted feature removal. 
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.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5780 on: April 30, 2014, 06:05:16 am »

I am going to embark on programming a text adventure with nothing but a TI-89 Titanium calculator. I will post the results later.
Heh, I got my start in programming on a TI-86. Not fun on a tiny LED screen, but it's better than math class.
I wrote a few TI-84 programs myself :v
Not that I have the patience to write anything more complex than CALCULATOR Q on that teeny tiny screenlet.
Well, maybe it's motivation because I actually have TokensIDE on this computer so I could just use that if I wanted to.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5781 on: April 30, 2014, 07:34:27 am »

Ah, the TI-8X series was my first stab at programming too.  I remember there was a racing game of some sort on one where it simulated the road as columns of '|' characters and used 'O' as the car, and you played it by using the arrows to move left and right while the car automatically went forward.  It was amazingly simple, but still a time killer when I got done with work in my high school calculus class.  One day the teacher wiped all of the games off of the calculators, but I was bored so I started poking through the built in command list, created a new program and got to work.

Two days later, my teacher walked by and we had an exchange along these lines:

"Huh, I thought I deleted all of those."

"Yeah, I just tried creating a new one."

She gave me a surprised look.  "Oh, okay then."  She never said anything about it after that.  :)

One thing I do remember about the TI-86 at least is that programs that looped infinitely would continue to slow down as the program ran.  So pretty much any game would eventually fall prey to it and become unplayable.  The original game didn't have that problem though, which perplexed me for a long time.  Apparently the TI-86 and similar calculators had two ways they could be programmed: using TI BASIC or some prebuilt binary transferred from a computer, which I'm guessing was compiled from C or a similar language to its native machine code.  Those programs didn't have the problem, so it was something about the TI BASIC interpreter.  I feel like I did somehow get around the slowdown problem using the interpreter, but I have no idea how.
Logged
Through pain, I find wisdom.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5782 on: April 30, 2014, 08:01:03 am »

Yeah, the TI-8X series is built on one type of CPU: the z80. A lot of games for that series are made in z80 assembly.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5783 on: April 30, 2014, 08:06:55 am »

So much TI-83 nostalgia. I was that kid in the corner who played with his calculator instead of doing the classwork. I made (naive) planetary gravity simulations. Random stuff that used the draw functions to make random lines or spirals all over the screen. I remember attempting to play around with cellular automation and accidentally creating a Sierpinski Triangle.

I tried making a tank artillery game where you select an angle and shot power and try to hit the other tank, but the TI BASIC programming interface was beyond abysmal. My program became like over 10 screens long, and navigating the cursor to where I wanted to go was painful. You only had 26 variables, one for each letter of the alphabet, and keeping track of which variable was which and not running out of variables was a nightmare. Maybe that's why I prefer overly long variable names today.

Coincidentally, I still keep next to me the same calculator I used back then, with all the programs I made still on it. Let me see here...

Code: [Select]
If T+Y*A-O<T+.4 and T+Y*A-O>T-.4 and S+X*A<I+.55 and S+X*A>I-.55
then
Disp "Hit"
0->Q
Stop
Else
If (T+Y*(A-1)-J)<-10.25
then
Disp "Miss"
1->Q
Stop
Else

Oh gods, it gets worse. The next if statement takes up the entire 16x7 character display. It's a programmer's worst nightmare.
Logged

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5784 on: April 30, 2014, 08:29:36 am »

2nd lock + arrow keys allows you to navigate quickly.

I actually have all of my little programlets on this computer, had to evacuate them here because our calculators get wiped before exams...
(Well, it's just three of them :v, and they're pretty simple. Not larger than 450 bytes)


E: Alright, here they are. Exported to my PC via TI-Connect and then text-ified by TokensIDE.

This is the most complex one, and I'm a little bit proud of it.
Spoiler: MOVE aka Calculator Q (click to show/hide)

« Last Edit: April 30, 2014, 08:35:33 am by miauw62 »
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5785 on: April 30, 2014, 09:28:24 am »

Link to web app thing I made. Javascript needed.
It's a site that visualizes how many times people replied to other people for any specified subreddit, reading the last 100 top posts. It also stores the posts for future reference.

Using it is not too difficult--input the subreddit name, set a threshold comment limit, and then submit. If the subreddit chosen has not been requested by anyone else for 24 hours, it'll take around 5 minutes to update the archive. If the number of comments shown on the [log page](http://i.imgur.com/yaO9Ua4.png) reaches 100 but nothing happens, just refresh the page and chances are the graph will appear. This is a minor bug that I haven't had time to fix. Another possible bug is the message "The subreddit X does not exist," when it does. The answer to fixing it is refreshing repeatedly until it works :P


Here's an example of a graph. Scrolling and panning is possible. The top row of buttons are actually menus, and clicking them will change the context bar to the right. Right clicking a circle will temporarily remove it from the graph, allowing a user to declutter. They may be restored through the ``Hidden nodes`` menu. The text may be toggled off, through the ``Controls-Hide Labels`` menu. Left-clicking on a node or name will show details, mainly consisting of the comments that person has left or have been replied on. Clicking the links will expand them into a pseudo-Reddit comment tree, allowing the user to get the gist of the conversation. Another minor bug is that comment trees consisting of A-B-A-B will appear each time, say, A replied, assuming the current clicked node is for A. Example.


So far, I've served only 435 graphs, with 29 unique views. :< I have no idea how to advertise this--I'd like more users to see if it scales well and stuff.
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

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

tahujdt

  • Bay Watcher
  • The token conservative
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5787 on: April 30, 2014, 01:43:34 pm »

Not necessarily programming based, but web design based: In web design class, instead of a final, we have a final project in which we build a website. Now, for context: I built my first website when I was seven. Seeing as it  took me two days of half-goofing-off to get half-way done, I need help: what are some cool CSS or Javascipt tricks I can spruce it up a bit.
Logged
DFBT the Dwarf: The only community podcast for Dwarf Fortress!
Tahu-R-TOA-1, Troubleshooter
Quote
I suggest that we add a clause permitting the keelhauling of anyone who suggests a plan involving "zombify the crew".
Quote from: MNII
Friend Computer, can you repair the known universe, please?

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5788 on: April 30, 2014, 07:10:55 pm »

I hate coming again so soon after my previous problem with the same program, but I've spent almost my entire day after getting home trying to fix this with no success.  The problem is that when I'm creating a list of dec classes, the arraylist ids and deci are not being created with anything in them.  The output I get is just the very first info "You are to report to Claudius in the throne room.  What do you do?" 
Spoiler: reader (click to show/hide)
Spoiler: dec (click to show/hide)
Spoiler: game (click to show/hide)
The only thing my main does is create a game object. 
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.

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5789 on: April 30, 2014, 11:07:44 pm »

I hate coming again so soon after my previous problem with the same program, but I've spent almost my entire day after getting home trying to fix this with no success.  The problem is that when I'm creating a list of dec classes, the arraylist ids and deci are not being created with anything in them.  The output I get is just the very first info "You are to report to Claudius in the throne room.  What do you do?" 
-- snip --
The only thing my main does is create a game object.

I'm looking at things now. Still working on figuring out how it's supposed to work. Why, oh why, are all of the variables in reader declared at the class level?

I could go on and on with style tips/code review stuff if you're interested.

Will hopefully post again soon with assistance.

EDIT instead of double-post:

In reader's constructor, you're re-using the same ArrayLists over and over. Think about that for a moment before you open the spoiler.

Spoiler: Why is that bad? (click to show/hide)

Spoiler: How to fix? (click to show/hide)
« Last Edit: April 30, 2014, 11:23:48 pm by SolarShado »
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch
Pages: 1 ... 384 385 [386] 387 388 ... 796