|
Paolomania posted:QED If i'm being a dick it's because I am channeling dijkstra :-)
|
# ? Apr 13, 2011 12:31 |
|
|
# ? May 9, 2024 07:08 |
|
The "dickish-to-people" group of people has a larger than normal overlap with the "interested-in-programming" group of people.
|
# ? Apr 13, 2011 17:17 |
|
welcome to something awful
|
# ? Apr 13, 2011 17:28 |
|
Writing a "database" join function in java. It will take in two ~ delimited files and join them on common columns. I created this where it could join on one column, now I am trying to expand it to be able to join on multiple columns. I am having trouble with the method that finds common columns and stores them. I created a class which has; value, locationA, locationB. However I am getting a null pointer. code:
code:
code:
|
# ? Apr 13, 2011 19:59 |
|
Just quickly looking over this I'd say it's because java arrays begin at 0 and your 'count' starts at 1. Go from there.
|
# ? Apr 13, 2011 20:45 |
|
Sereri posted:Just quickly looking over this I'd say it's because java arrays begin at 0 and your 'count' starts at 1. Go from there. same problem is encountered when count is initialized to 0;
|
# ? Apr 13, 2011 20:54 |
|
location[] tmpLoc = new location[tmpLocSize]; //next use: tmpLoc[count].setValue(d1[i]); tmpLoc has nothing in it. (Rather, it's an array of null location objects of size tmpLocSize) You have to do tmpLoc[count] = new Location(value, aLoc, bLoc); first. Also Location should be capitalized in its class name and constructor.
|
# ? Apr 13, 2011 21:04 |
|
Java newbie here! I'm stuck on implementing a KeyListener. I have a JButton that I want to be triggered whenever the user presses the enter key. It should trigger the button's ActionEvent no matter where the focus is though, unless it is on a specific JTextArea in my GUI. I've searched several tutorials, but I haven't managed to adapt them to my case. Can anyone help me with this?
|
# ? Apr 19, 2011 13:59 |
|
You probably want to use key bindings. Key listeners are for trapping key presses on a single component.
|
# ? Apr 19, 2011 17:46 |
|
Pretty new to Java and was wondering if anyone could advice on some 'best practice'. While learning I've written a small servlet/package that sends xml to a web service and returns the response and since i'm just taking the xml and sticking it in the body of an http POST request I've dealt with the actual xml entirely as a String so far. For I want to store the request body as an xml object rather than a string and do a bit of manipulation on it and i'm having trouble from google on determining which is the most typical way of doing this as every example seems to use different parsers/readers etc. If anyone could give me a pointer on the 'best' or 'most common' way of parsing a String to xml then manipulating the values of particular attributes etc. that'd be appreciated. (I'd also love it if there was something as straight forward as jQuery's xml manipulation for Java even if not typical). Thanks
|
# ? Apr 20, 2011 02:53 |
|
TheFatController posted:For I want to store the request body as an xml object Grab jdom and jaxen, put them on the classpath, and go to town. code:
pre:<root>here's some text</root> epswing fucked around with this message at 03:45 on Apr 20, 2011 |
# ? Apr 20, 2011 03:41 |
|
Been working my way slowly through the thread as I've recently been thrown face first into the world of Java. To get myself into it, when I'm not learning it at work, I'm programming an RPG at home (surprise!). I want to throw out the general flow I'm using so far and get some feedback on my overall design strategy, at least for creature entities right now. I have a class Creature, looks like this (will implement a levelup and useAbility method later, still prototyping it out): code:
I've been mulling over the has-a vs is-a relationship for the last couple days, so I'm sorry if the post meanders a bit. It just seems like a very pertinent thing to consider, especially in something like an RPG. I can see defining a creature both as "it has a race (human) and a profession (fighter)" or "it is a human (race) fighter (profession)".
|
# ? Apr 21, 2011 03:26 |
|
TaintedBalance posted:Been working my way slowly through the thread as I've recently been thrown face first into the world of Java. To get myself into it, when I'm not learning it at work, I'm programming an RPG at home (surprise!). I want to throw out the general flow I'm using so far and get some feedback on my overall design strategy, at least for creature entities right now. It sounds like interfaces would be a better option for this. This way you could implement multiple professions. If you went with inheritance (extending classes) you would have to work with HumanFighter, HumanPriest, HumanBlahBlah objects versus "is it a human? Is it a fighter? Yes to both? Average Attack Power go!"
|
# ? Apr 21, 2011 17:15 |
|
TaintedBalance posted:
Can you explain what you're trying to do here?
|
# ? Apr 21, 2011 17:21 |
|
something terrifying Also, never assign class/instance variables to their default value. Numbers all default to 0, boolean defaults to false, and objects default to null.
|
# ? Apr 21, 2011 17:23 |
|
Clearly it's still a work in progress, but overall I'm not sure "this" means what you think it means.
|
# ? Apr 21, 2011 20:22 |
|
TaintedBalance posted:
It's a bit late in here but this has infinite loop written all over it. Edit : that was kind of a jerk answer, but do you want your Creature class to instanciate what I'd call a creature type, ie a race/profession couple, or do you want it to instanciate an individual creature ? right now it looks like your class tries to be both at the same time but it looks a bit off. Red Lives fucked around with this message at 22:07 on Apr 21, 2011 |
# ? Apr 21, 2011 20:32 |
|
Red Lives posted:It's a bit late in here but this has infinite loop written all over it. If the is Java (and I am in the Java thread) I can guarantee it won't be an infinite loop. A stack overflow however...
|
# ? Apr 21, 2011 23:50 |
|
HFX posted:If the is Java (and I am in the Java thread) I can guarantee it won't be an infinite loop. A stack overflow however... Can anyone help me redirecting the stack to say... the swap partition? I want to recurse at a depth of several billion.
|
# ? Apr 21, 2011 23:55 |
|
epswing posted:Can you explain what you're trying to do here? Playing with casting/objects and how you can call them/get at their methods and variables. Overall, the idea behind it was to keep a reference to what the class/profession are so that I can add a levelUp method to the Creature class that would be something like: code:
Aleksei Vasiliev posted:Also, never assign class/instance variables to their default value. Numbers all default to 0, boolean defaults to false, and objects default to null. Done and done! Thanks for the advice. Red Lives posted:It's a bit late in here but this has infinite loop written all over it. I should have left that out, I just threw in the whole code. That was part of me playing around with objects/methods and seeing how exactly I could use them. I am not attached to that code in anyway, just seeing how I get information back and how I can manipulate it. "Spraynard Kruger" posted:Clearly it's still a work in progress, but overall I'm not sure "this" means what you think it means. My current understanding is that it is a reference to the object you are currently within. Is this incorrect? And thanks God of Mischief, I took it a step further and made a Template interface that Race and Profession both extend so that if I get a wild hair to add another template type (is zombie a race, or a template? Thinking D&D 3rd ed here), I can easily add it in. And thank you everyone for the replies, I'm getting a lot of practice and teaching in Java, but its informally structured and as such, there are some obvious gaps going on.
|
# ? Apr 22, 2011 04:35 |
|
TaintedBalance posted:My current understanding is that it is a reference to the object you are currently within. Is this incorrect? That is correct, so that implies that your Race class has a method defined as addRace(Creature c). What would this do? Why would a Race use a Creature object to add... a Race? Also the use of "this" in your stack overflow causing functions, as already pointed out.
|
# ? Apr 22, 2011 18:08 |
|
I'm fairly new to Java and I'm tired, but this doesn't feel right to me. In Python I'd just used named groups to get what I need:code:
What's the right way to do this? edit: Or the meta-question is, "what's the best way to convert txt to total seconds?" Thermopyle fucked around with this message at 00:24 on Apr 23, 2011 |
# ? Apr 23, 2011 00:16 |
|
Spraynard Kruger posted:That is correct, so that implies that your Race class has a method defined as addRace(Creature c). What would this do? Why would a Race use a Creature object to add... a Race? Ah, that is likely a bad naming convention. I've converted all of the race/professions into a template interface so that anything can be applied, but, to be more specific, the addTemplate method adds the base values of the Template to the class. code:
And as for the stack overflow issue, ya, after some sleep and looking at it again I hate myself for writing that. It has been completely culled.
|
# ? Apr 23, 2011 00:55 |
|
Thermopyle posted:edit: Or the meta-question is, "what's the best way to convert txt to total seconds?" Would something like Joda-Time[1] fit your needs? 1. http://joda-time.sourceforge.net/
|
# ? Apr 23, 2011 04:27 |
|
TaintedBalance posted:Ah, that is likely a bad naming convention. I've converted all of the race/professions into a template interface so that anything can be applied, but, to be more specific, the addTemplate method adds the base values of the Template to the class. Don't worry about. It was just some ribbing. Every programmer has done it at least once. Some of us more times then we care to admit too. If they ever get around adding tail recursive calls to the VM, then you can watch your stack overflows become infinite loops.
|
# ? Apr 23, 2011 09:16 |
|
It seems like you can only have one "template" in a particular category at a time. That being the case, I honestly don't think lumping them all together is actually a good idea. It smacks of over-engineering. Both processor threads and pigeons can die, but that doesn't mean they need a common base class.
|
# ? Apr 23, 2011 11:28 |
|
Jabor posted:It seems like you can only have one "template" in a particular category at a time. That being the case, I honestly don't think lumping them all together is actually a good idea. It smacks of over-engineering. You can have as many templates as you want. I've tested out giving something two classes for example, or two races. I'll think about making it smarter on that front though.
|
# ? Apr 23, 2011 20:35 |
|
Does anybody have an idea on how I can do better image recognition? I'm writing bots for Bejeweled games, so I need to be able to recognize the gems in a screenshot. Right now I'm averaging the colors of the inside of the gems and using that to guess which gem is contained in that location. This is great for speed, but not so much for accuracy. It can't reliably recognize two gems of different shape but similar color, which leads to a bunch of issues. Including getting stuck forever unless I manually pause it and make some moves. The bot obviously still works, but improving this would make it work a lot better. I just wrote a bot using Neuroph's image recognition, which kind of works. The upside is that it's pretty drat accurate. The downsides are that I need to collect and train it on a giant dataset, and it's really slow. As in "takes one second to recognize 64 gems" slow. If it was, say, an order of magnitude or more faster, I'd probably use this. Anyone have any ideas?
|
# ? Apr 24, 2011 02:36 |
|
Aleksei Vasiliev posted:I just wrote a bot using Neuroph's image recognition, which kind of works. The upside is that it's pretty drat accurate. The downsides are that I need to collect and train it on a giant dataset, and it's really slow. As in "takes one second to recognize 64 gems" slow. If it was, say, an order of magnitude or more faster, I'd probably use this. This method is pretty well known for face detection and is very fast (the wiki page is not too good but the first reference to the CVPR paper is what you want). This may be more general than you need though. From your video it looks like you have a small finite set of things you need to recognize in known locations. Something simple like making a template for each gem type and computing the normalized cross correlation between each template and each gem location would probably work better than color averaging and is really easy.
|
# ? Apr 24, 2011 03:27 |
|
Aleksei Vasiliev posted:Does anybody have an idea on how I can do better image recognition? I'm writing bots for Bejeweled games, so I need to be able to recognize the gems in a screenshot. That sounds like a fun project! I may try that myself...
|
# ? Apr 24, 2011 05:46 |
|
Aleksei Vasiliev posted:Does anybody have an idea on how I can do better image recognition? I'm writing bots for Bejeweled games, so I need to be able to recognize the gems in a screenshot.
|
# ? Apr 26, 2011 08:40 |
|
I think part of the issue is you're looking at hue. Don't. It's irrelevant. Distinguishing shape is much faster and easier, and gives you all the information you need. Greyscale, threshold, perhaps some denoising, and then it's trivial for any image classification algorithm.
|
# ? Apr 26, 2011 13:28 |
|
I'm having trouble executing a terminal command from java in Ubuntu.code:
I tried replacing the command with garbage ("BLAHHHH") and did get an exception. I also tried replacing it with "mkdir test" and it did create a new directory. My guess is there's something getting messed up by the fact that I'm piping between processes. Any suggestions?
|
# ? Apr 27, 2011 02:40 |
Eggnogium posted:My guess is there's something getting messed up by the fact that I'm piping between processes. Any suggestions? Some googling led me to: http://www.velocityreviews.com/forums/t362758-facing-problem-while-using-pipe-in-runtime-exec.html quote:Redirection operators like pipes are a shell feature, but the command
|
|
# ? Apr 27, 2011 02:45 |
|
Eggnogium posted:I'm having trouble executing a terminal command from java in Ubuntu. you're not running a shell to parse the pipes or redirection, try one of the array-based Runtime#exec calls and e.g. {/bin/sh, -c, ./f21p, ... }.
|
# ? Apr 27, 2011 02:48 |
|
I need help guys. Currently I am doing some GUI java programming using netbeans , and i was wondering how to display the contents of a jcombobox based on a list from a text file that looks like : a b c d e
|
# ? Apr 27, 2011 04:45 |
|
ZeroConnection posted:I need help guys. First you read the file into a data structure like a Vector. Then you give the Vector to the JComboBox's constructor and add your JComboBox to a JFrame set to display at the right size.
|
# ? Apr 27, 2011 13:25 |
|
In my data structures class, we're learning about BST's, and I'm having a problem with a project.code:
|
# ? Apr 28, 2011 02:47 |
|
Puppet Pal Claudius posted:I looked at it in debug mode and it looks like for whatever reason my program thinks that 2^(depth+1)-1 = 0 when depth = 2, when it should clearly be 7. Is there something I'm doing wrong with my equation? I don't think ^ does what you think it does. ^ is xor, not exponentiation.
|
# ? Apr 28, 2011 03:05 |
|
|
# ? May 9, 2024 07:08 |
|
Nippashish posted:I don't think ^ does what you think it does. ^ is xor, not exponentiation. Oh god you're right. It completely slipped my mind that it's Math.pow(). Thanks!
|
# ? Apr 28, 2011 03:13 |