|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On December 27 2011 23:48 kaihangkk wrote: i know nth about programming....which language would be the best one to start with? really hard to say, but i'd go with python
|
On December 27 2011 23:48 kaihangkk wrote: i know nth about programming....which language would be the best one to start with? Start with Java and be sure you understand what are you doing. Try to find some basic course on it.
|
On December 27 2011 23:19 ArcticVanguard wrote: Does anyone have any suggestions for a tutorial for learning GUI programming for Windows? Language is C++. I'm looking at Qt but I'm having trouble following some of them out there. The thing I've seen is that GUI programming on any platform is a nightmare, but surely there are SOME out there that I can use.
Idk if it's graphically powerful enough for your needs (there's a bit of overhead with buttons, etc) but you could look at WPF in VS2010 for any of the .Net languages. (Csharp, VB.net, etc)
I've been using it for a little while now, and I rather like it. The xaml visual editor is 50/50, but great for starting out and learning.
|
On December 27 2011 23:19 ArcticVanguard wrote: Does anyone have any suggestions for a tutorial for learning GUI programming for Windows? Language is C++. I'm looking at Qt but I'm having trouble following some of them out there. The thing I've seen is that GUI programming on any platform is a nightmare, but surely there are SOME out there that I can use.
I think everyone above me has suggested this in some shape or form.
Easiest way to build Windows applications is via the .NET framework (Windows.Forms) in VB,C# C++/CLI (Pick your poison).
wxWidgets, QT, MFC are all good frameworks (maybe not MFC....), but they all have a steeper learning curve initially.
I would recommend learning the base win32 API in the future (once you've mastered .NET and one of the other frameworks) so you understand what is happening underneath the above frameworks.
|
Learning C++ after Java: What happens when an element of a dynamically allocated array is released/deleted in C++? Does that mean all of the remaining elements of the array are shifted down or does that have to be done manually?
i.e. if we had a five element array of integers theArray[5] such as... 34 42 57 64 89
and executed "delete theArray[1]"
does it become
34
42 57 64 89
or
34 57 64 89
|
On December 31 2011 11:18 Loser777 wrote: Learning C++ after Java: What happens when an element of a dynamically allocated array is released/deleted in C++? Does that mean all of the remaining elements of the array are shifted down or does that have to be done manually?
i.e. if we had a five element array of integers theArray[5] such as... 34 42 57 64 89
and executed "delete theArray[1]"
does it become
34
42 57 64 89
or
34 57 64 89
The former. You have to do this manually. Also, if you manually move the things down, the array will still keep its maximum size, there will just be leftover elements at the end (probably old values since moving things down usually means copying).
|
On December 30 2011 04:31 Shruikan998 wrote: If I am looking to get into web design, and aim primarily to be self taught... What is the best language for me to learn to do this with?
I think the obvious choice (if you have absolutely zero experience with programming/coding) would be HTML and CSS. Once you're comfortable with those you can move onto a scripting language like JavaScript. If you want to transition to server-side programming then you can't go wrong with PHP & MySQL.
|
On December 30 2011 03:16 enigmaticcam wrote:Anyone here familiar with the Knapsack problem? http://en.wikipedia.org/wiki/Knapsack_problemI'm playing this PvP game that's very similar. You have a battleship with x number of weapon slots, limited capacity, and a large assortment of different types of weapons to fill those slots with, all with varying stats (including weight). I'm trying to write a program that will take your captain's stats, the number of weapon slots you have available, the max capacity your ship can hold, and all the possible weapons you can equip, and find the combination of weapons with the highest damage output. You can't just equip the highest damage possible for your level, because you will use up all your weight capacity before you use up all your weapon slots. Of the solutions to the knapsack problem, the 0-1 solution is the closest to what I need. The problem is I have an additional constraint of limited number of weapons I can use (as many as weapon slots I have), plus I'm having a hard time interpreting the formula and understanding exactly what it's doing. Anyone have any experience with this kind of dynamic programming who might be able to help me out? I just need a better explanation of the formula so I can know how to implement it in my code. Thanks! Edit: I think I understand the logic of the formula, but I can't quite get when it actually returns a value. Based strictly on what is written there, it seems to me like it will never actually produce a value until it gets down to the first item, in which case it would just produce 0. At some point you've gotta say, "ok, we don't need to go any further, just return this item's damage value", but I don't see when that would happen. Don't use a program for this.
If you've ever played an Elder Scrolls game, you've dealt with similar problems when looting dungeons. What you do is, you divide the item's value by its weight, and that tells you how valuable it is to steal. The higher the ratio, the better the item is to steal.
Do the same thing with your game. Divide damage by weight, for each weapon, and take them in order, so you take the ones with the highest ratio first.
|
On December 31 2011 11:36 heishe wrote:Show nested quote +On December 31 2011 11:18 Loser777 wrote: Learning C++ after Java: What happens when an element of a dynamically allocated array is released/deleted in C++? Does that mean all of the remaining elements of the array are shifted down or does that have to be done manually?
i.e. if we had a five element array of integers theArray[5] such as... 34 42 57 64 89
and executed "delete theArray[1]"
does it become
34
42 57 64 89
or
34 57 64 89 The former. You have to do this manually. Also, if you manually move the things down, the array will still keep its maximum size, there will just be leftover elements at the end (probably old values since moving things down usually means copying). Thanks... you helped me realize that the array wasn't even dynamically allocated, only the objects in the array of pointers were... took me about 3 hours to figure out while delete [] theArray; was causing everything to explode.
|
On December 31 2011 16:42 Loser777 wrote:Show nested quote +On December 31 2011 11:36 heishe wrote:On December 31 2011 11:18 Loser777 wrote: Learning C++ after Java: What happens when an element of a dynamically allocated array is released/deleted in C++? Does that mean all of the remaining elements of the array are shifted down or does that have to be done manually?
i.e. if we had a five element array of integers theArray[5] such as... 34 42 57 64 89
and executed "delete theArray[1]"
does it become
34
42 57 64 89
or
34 57 64 89 The former. You have to do this manually. Also, if you manually move the things down, the array will still keep its maximum size, there will just be leftover elements at the end (probably old values since moving things down usually means copying). Thanks... you helped me realize that the array wasn't even dynamically allocated, only the objects in the array of pointers were... took me about 3 hours to figure out while delete [] theArray; was causing everything to explode.
Just as a note: int* theArray = new int[10] would create a dynamically allocated array of 10 ints (i.e., a pointer to an array of 10 ints). int* theArray[10] would create an array of 10 pointers to ints. The former requires the use of "delete[]" in order to free the memory allocated by the entire array. The latter requires "delete theArray[n]" in order to free the memory of a specific element. If you try using "delete[]" on the latter, problems will happen
|
On December 31 2011 14:06 Millitron wrote:Show nested quote +On December 30 2011 03:16 enigmaticcam wrote:Anyone here familiar with the Knapsack problem? http://en.wikipedia.org/wiki/Knapsack_problemI'm playing this PvP game that's very similar. You have a battleship with x number of weapon slots, limited capacity, and a large assortment of different types of weapons to fill those slots with, all with varying stats (including weight). I'm trying to write a program that will take your captain's stats, the number of weapon slots you have available, the max capacity your ship can hold, and all the possible weapons you can equip, and find the combination of weapons with the highest damage output. You can't just equip the highest damage possible for your level, because you will use up all your weight capacity before you use up all your weapon slots. Of the solutions to the knapsack problem, the 0-1 solution is the closest to what I need. The problem is I have an additional constraint of limited number of weapons I can use (as many as weapon slots I have), plus I'm having a hard time interpreting the formula and understanding exactly what it's doing. Anyone have any experience with this kind of dynamic programming who might be able to help me out? I just need a better explanation of the formula so I can know how to implement it in my code. Thanks! Edit: I think I understand the logic of the formula, but I can't quite get when it actually returns a value. Based strictly on what is written there, it seems to me like it will never actually produce a value until it gets down to the first item, in which case it would just produce 0. At some point you've gotta say, "ok, we don't need to go any further, just return this item's damage value", but I don't see when that would happen. Don't use a program for this. If you've ever played an Elder Scrolls game, you've dealt with similar problems when looting dungeons. What you do is, you divide the item's value by its weight, and that tells you how valuable it is to steal. The higher the ratio, the better the item is to steal. Do the same thing with your game. Divide damage by weight, for each weapon, and take them in order, so you take the ones with the highest ratio first.
This method doesn't nearly produce optimal results though. If it were that simple, the "knapsack problem" wouldn't exist.
|
On December 30 2011 03:16 enigmaticcam wrote:Anyone here familiar with the Knapsack problem? http://en.wikipedia.org/wiki/Knapsack_problemI'm playing this PvP game that's very similar. You have a battleship with x number of weapon slots, limited capacity, and a large assortment of different types of weapons to fill those slots with, all with varying stats (including weight). I'm trying to write a program that will take your captain's stats, the number of weapon slots you have available, the max capacity your ship can hold, and all the possible weapons you can equip, and find the combination of weapons with the highest damage output. You can't just equip the highest damage possible for your level, because you will use up all your weight capacity before you use up all your weapon slots. Of the solutions to the knapsack problem, the 0-1 solution is the closest to what I need. The problem is I have an additional constraint of limited number of weapons I can use (as many as weapon slots I have), plus I'm having a hard time interpreting the formula and understanding exactly what it's doing. Anyone have any experience with this kind of dynamic programming who might be able to help me out? I just need a better explanation of the formula so I can know how to implement it in my code. Thanks! Edit: I think I understand the logic of the formula, but I can't quite get when it actually returns a value. Based strictly on what is written there, it seems to me like it will never actually produce a value until it gets down to the first item, in which case it would just produce 0. At some point you've gotta say, "ok, we don't need to go any further, just return this item's damage value", but I don't see when that would happen.
It seems that since you're limited by number of slots AND weight, this is more complex than the simplified knapsack problem.
http://en.wikipedia.org/wiki/List_of_knapsack_problems#Multiple_constraints
There is no poly-time solution, or even a poly-time approximation. You're going to have to bruteforce this one. Depending on the number of weapons you have potentially per slot, this could get really slow really fast.
Quote: "The 0-1 variant (for any fixed ) was shown to be NP-complete around 1980 and more strongly, has no FPTAS unless P=NP"
If there was a way you could use #slots OR weight as a constraint, I could help you out with pseudocode.
Edit: By bruteforce, I mean if you have N slots available and W different weapons that fit that type, you could find every combination of the W weapons where order doesn't matter. This would end up being: N nCr W different combinations. (nCr is calculator symbol for statistical 'choose')
10 weapons, 4 slots, 210 combinations (10 choose 4)
Then, sum the weight of each and remove combinations that break the weight capacity. Then your highest damage sum should be your optimal solution for that weapon type.
You can also optimize by removing weapons that are absolutely inferior. In database this is called the 'skyline query' (I believe its a similar concept at least). It will take O(n^2), but it would make your weapon algorithm run much faster. If any weapon is inferior both in damage (has <= damage) AND weight (has >= weight) to any other weapon, this weapon can be completely removed from the equation. If they are both equal, the weapon is a duplicate and one of them can be removed anyway.
All of this is still assuming your 0-1 condition, i.e. no duplicate weapons.
|
I'm trying to make a simple webpage that will automatically resize the embedded Own3D stream when the browser is resized. I basically reused what Own3D itself does (as well as trying what TL and CLGaming use for embedding), but none of the variants actually result in a stream being loaded. I can access the SWF in my browser (the one linked through SRC), but it just doesn't seem to want to load on the page. The entire browser page does seem to contain a flash object, just an empty one. I've been testing it by running the page locally. The jquery link is valid and script identical to the one used by Own3D's working implementation.
Any ideas what I'm doing wrong?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'> <head> <title>Craton's Own3D Alarm Clock</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> </head> <body style="margin:0px; padding:0px;"> <object width="768" height="432" id="object"> <param name="movie" value="http://www.own3d.tv/livestream/6416" /> <param name="allowscriptaccess" value="always" /> <param name="allowfullscreen" value="true" /> <param name="wmode" value="transparent" /> <embed id="embed" src="http://www.own3d.tv/livestream/6416" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="768" height="432" wmode="transparent"></embed> </object> <script> $(window).resize(function() { $('#object').attr("width",$(window).width()); $('#object').attr("height",$(window).height()); $('#embed').attr("width",$(window).width()); $('#embed').attr("height",$(window).height()); }); </script> </body> </html>
|
Hi guys I'm in an introductory java class (AP Computer Science A) and need some help. I was working on a program that imported information from a text file about hurricane data, applied it to arrays, and used the arrays to categorize the information and calculate some averages and such. At the end I had to write the statistics to an output file.
Well in BlueJ I got the right output whenever I compile the program, but when I write it to a file by replacing all the System.out.print w/ outFile.print I check the text file and the output is ALL messed up in note pad. Literally nothing is neatly organized and overall it looks like a clusterfuck! I have absolutely no idea what to do at this point. I have a feeling it might have something to do with my printf methods, but I don't understand why it would look normal when I compile it in BlueJ but look awful in notepad. I'll post any parts of program if needed.
|
On January 02 2012 12:14 CAPSLOCKLOL wrote: Hi guys I'm in an introductory java class (AP Computer Science A) and need some help. I was working on a program that imported information from a text file about hurricane data, applied it to arrays, and used the arrays to categorize the information and calculate some averages and such. At the end I had to write the statistics to an output file.
Well in BlueJ I got the right output whenever I compile the program, but when I write it to a file by replacing all the System.out.print w/ outFile.print I check the text file and the output is ALL messed up in note pad. Literally nothing is neatly organized and overall it looks like a clusterfuck! I have absolutely no idea what to do at this point. I have a feeling it might have something to do with my printf methods, but I don't understand why it would look normal when I compile it in BlueJ but look awful in notepad. I'll post any parts of program if needed. try opening it with a different editor. If your program writes unix line breaks (\n), the windows editor screws up because it doens't display those. The windows editor only displays windows style line breaks (\r\n).
|
On January 02 2012 12:17 MisterD wrote:Show nested quote +On January 02 2012 12:14 CAPSLOCKLOL wrote: Hi guys I'm in an introductory java class (AP Computer Science A) and need some help. I was working on a program that imported information from a text file about hurricane data, applied it to arrays, and used the arrays to categorize the information and calculate some averages and such. At the end I had to write the statistics to an output file.
Well in BlueJ I got the right output whenever I compile the program, but when I write it to a file by replacing all the System.out.print w/ outFile.print I check the text file and the output is ALL messed up in note pad. Literally nothing is neatly organized and overall it looks like a clusterfuck! I have absolutely no idea what to do at this point. I have a feeling it might have something to do with my printf methods, but I don't understand why it would look normal when I compile it in BlueJ but look awful in notepad. I'll post any parts of program if needed. try opening it with a different editor. If your program writes unix line breaks (\n), the windows editor screws up because it doens't display those. The windows editor only displays windows style line breaks (\r\n). Oh ok that's it then. I use a lot of \n in my code. Good to know what the issue is! Thanks for the quick reply! :D I find it odd my class would encourage the use of \n and not mention that issue when outputting data. Does windows editor accept System.out.println(); as it seems my only option is to go back and change all the \n to println();
EDIT: Decided to just go with \r\n and it worked beautifully. If my teacher gives me crap about not yet learning anything about \r I'll just go back and fix it whatever way she wants. Once again thanks for the help! 
|
Hello everyone, thanks again for that help on the picturebox problem I was having, I'm now done that project ^_^
Anyway, I want to start learning python, getting pygame and really focusing on that language and eventually getting in to ludum dare in April, and since I'm leaving the visual studio editor, I'm at a crossroads.
On one hand, I have Vim (I've found tutorials I understand more so than Emacs which is why I'm choosing this one), which is a lot more efficient and sort of a "for the long-term" kind of editor, where it will take me a while to get used to it, but once I do I'll be a lot more efficient. The only problem that comes up when I think of this is that I don't want to juggle learning a new fairly complex editor at the same time as learning a brand new language.
On the other hand, we have Eclipse with Pydev. This is basically the opposite, being that it'll be an editor that's fairly good for what it does, but lacks the complexity of Vim. This, balanced with that it would be far easier to learn than Vim, and it would be less juggling to do.
Any advice?
|
On January 02 2012 13:00 GiygaS wrote: On the other hand, we have Eclipse with Pydev. This is basically the opposite, being that it'll be an editor that's fairly good for what it does, but lacks the complexity of Vim. Sorry, did you just say that Eclipse isn't complex enough for you? It's one of the most feature-rich, confusing, and poorly documented IDEs ever made. If there's something you can't do in Eclipse it's because the functionality has been hidden somewhere in a menu maze.
|
On January 02 2012 13:15 lolmlg wrote:Show nested quote +On January 02 2012 13:00 GiygaS wrote: On the other hand, we have Eclipse with Pydev. This is basically the opposite, being that it'll be an editor that's fairly good for what it does, but lacks the complexity of Vim. Sorry, did you just say that Eclipse isn't complex enough for you? It's one of the most feature-rich, confusing, and poorly documented IDEs ever made. If there's something you can't do in Eclipse it's because the functionality has been hidden somewhere in a menu maze. Sorry, I should have replaced that with efficiency. I watched a video on Vim and it seems incredibly efficient, compared to something where everything is menu-driven like Eclipse. Eclipse would be a program that you COULD just start up with near minimal interaction with the complexities of it, just learn how to do certain hings (compile and run), and it's a go. Whereas with Vim I would almost feel obligated to learn intricacies of the editor.
|
For everyone doing GUI stuff:
I haven't worked with it much, but Python has bindings to c++'s wxWidgets called wxPython. It has a pretty good abstraction and runs at about the speed of the c++ equivalent. Anyway, it is a just something I'm aware of that some of you may want to look into, especially if you love python, like I do.
GiygaS, Emacs is better.
Just kidding, I don't want to start one of those arguments. I simply tried each briefly and started to learn emacs and I love it, more than any IDE I have come across so far.
Edit: With respect to learning multiple things at once, I learned a new language and the Dvorak keyboard layout at the same time. It took some time but I can touch type now, and that is cool! So if you are up for the challenge of learning two different things at once, go for it.
|
|
|
|