The Big Programming Thread - Page 106
Forum Index > General Forum |
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. | ||
peacenl
550 Posts
| ||
fabiano
Brazil4644 Posts
I've used it to create a SC2 launcher that simulates iCCup ladder and it works perfectly (http://ladderlauncher.tk), but I found SC2 to be a really boring and uneventful disgusting game compared to BW so I put the project to rest. Was thinking about releasing it to TL users to use but it might contain ladder abusable holes so I decided to not do that. | ||
Kentor
![]()
United States5784 Posts
![]() https://github.com/kentor/euler_ruby oh and ruby > python | ||
shannn
Netherlands2891 Posts
My iOS game that I'm making right now with Cocos2D has a lot of code. There are a lot of improvements to be done and regarding one of these improvements I'm currently wondering how much does a statement cost in performance or how can I check the performance of my game other than looking at the FPS. E.g. There is a schedule method called update (how convenient ^^) is called every frame. My current capped framerate is at 30 fps. How big does it affect the game performance if I had like a couple of for leaps and other statements in this schedule method? At first I had a lot of code called in this schedule method and now reduced by 2/3rd compared to before. My FPS won't drop below 30 right now and when I set the fps cap at 60 it usually runs at 45-55ish fps and almost never at 60. Does anyone know or know how I can check for these performances? I've searched on the cocos2d forums and other community sites but the threads are old and I don't understand them very well yet ![]() ![]() | ||
peacenl
550 Posts
![]() | ||
heishe
Germany2284 Posts
On January 09 2012 00:20 shannn wrote: A quick question to the more experienced game programmers or any other experienced programmer. My iOS game that I'm making right now with Cocos2D has a lot of code. There are a lot of improvements to be done and regarding one of these improvements I'm currently wondering how much does a statement cost in performance or how can I check the performance of my game other than looking at the FPS. E.g. There is a schedule method called update (how convenient ^^) is called every frame. My current capped framerate is at 30 fps. How big does it affect the game performance if I had like a couple of for leaps and other statements in this schedule method? At first I had a lot of code called in this schedule method and now reduced by 2/3rd compared to before. My FPS won't drop below 30 right now and when I set the fps cap at 60 it usually runs at 45-55ish fps and almost never at 60. Does anyone know or know how I can check for these performances? I've searched on the cocos2d forums and other community sites but the threads are old and I don't understand them very well yet ![]() ![]() We can't help you with this since we don't know your game. Also you're really vague. For loops and such things never matter, since you're not optimizing for a microcontroller (unless you want to make a game that looks really, really good. In which case microoptimizations like these are necessary. But even then you have to start at other points, like writing custom allocators etc.). 99.9% of your performance will be lost in macro-algorithms. Collision detection broad-phase, narrow phase, the way your entities interact, etc. This is really hard to say without seeing the game and the code. Generally when you want to check which parts of your code need the most time you use profilers... but I imagine this to be rather difficult since you have to test the game on the actual iOS platforms. A trivial way that I can think of now is to simply manually stop the time of different parts of your code, then sum all parts of the code together and see which part needs the biggest % of time, and start looking for possible optimizations there. | ||
shannn
Netherlands2891 Posts
On January 09 2012 00:55 heishe wrote: We can't help you with this since we don't know your game. Also you're really vague. For loops and such things never matter, since you're not optimizing for a microcontroller (unless you want to make a game that looks really, really good. In which case microoptimizations like these are necessary. But even then you have to start at other points, like writing custom allocators etc.). 99.9% of your performance will be lost in macro-algorithms. Collision detection broad-phase, narrow phase, the way your entities interact, etc. This is really hard to say without seeing the game and the code. Generally when you want to check which parts of your code need the most time you use profilers... but I imagine this to be rather difficult since you have to test the game on the actual iOS platforms. A trivial way that I can think of now is to simply manually stop the time of different parts of your code, then sum all parts of the code together and see which part needs the biggest % of time, and start looking for possible optimizations there. Actually that edited idea of yours is not bad. Don't know why I didn't come up with it ![]() ![]() And I was talking generally so I couldn't really say it in a specific detail as it was a general question :D your post has helped so thanks :D | ||
tec27
United States3690 Posts
On January 08 2012 22:24 peacenl wrote: I was wondering if anyone managed to read out sc2replay files in this thread, basically so far I came accross alot of posts explaning how to unpack the binary code or the bitstream. But when trying this myself I notice that the first part of the replay file is not bit stream at all! I'm working on a project to do just that atm (posted about it a little while back, but I guess you didn't see that ![]() Replays are MPQ files, so you have to extract them first (my project uses MPYQ to do that). Then you're left with a collection of files that each serve a different purpose (replay.message.events for chat, replay.game.events for game actions, etc.). Each of those files is formatted differently though, so you have to take that into account. This wiki has good documentation on the different files, although its wrong in a couple places: https://github.com/GraylinKim/sc2reader/wiki | ||
Jaso
United States2147 Posts
I'm currently learning C using Harvard's cs50.net course; it's extremely helpful. However, as a sophomore in high school right now, I'm also hoping to take the AP Computer Science test before I apply for college which gives me about a year and some to teach myself AP-level Java. Unfortunately, my school does not offer APCS because it is small ![]() Does anyone have any recommendations? Should I get a strong foundation before moving to Java (even though I know it's more like obj-c), should I just buy an APCS book and jump in, or something else..? Thanks! | ||
tec27
United States3690 Posts
On January 09 2012 05:16 Jaso wrote: Question: I'm currently learning C using Harvard's cs50.net course; it's extremely helpful. However, as a sophomore in high school right now, I'm also hoping to take the AP Computer Science test before I apply for college which gives me about a year and some to teach myself AP-level Java. Unfortunately, my school does not offer APCS because it is small ![]() Does anyone have any recommendations? Should I get a strong foundation before moving to Java (even though I know it's more like obj-c), should I just buy an APCS book and jump in, or something else..? Thanks! I'd say just continue what you're doing and maybe a bit before the test, or whenever you feel comfortable with C, start learning Java. APCS is honestly a really easy test imo, just working on a bunch of your own projects and increasing your skill level that way should prepare you for it fine. | ||
aksfjh
United States4853 Posts
| ||
![]()
tofucake
Hyrule18974 Posts
| ||
nakam
Sweden245 Posts
On January 09 2012 23:58 tofucake wrote: I had to use LabVIEW in college and it was the devil. That's my only experience with it though. Were you looking for help or something? Haha, this exactly is my experience of LabVIEW! | ||
aksfjh
United States4853 Posts
| ||
tec27
United States3690 Posts
Its fine if you're not that great at actual programming, but if you already know a lot when you start using it it tends to devolve into "I know how to do this programming-wise, I just can't find the way to do it in LabVIEW goddamnit". At least thats how it was for me. | ||
aksfjh
United States4853 Posts
The one thing it really helps with for me is the ability to organize the code in an incredibly easy way. I don't have to create and continually reference diagrams in regards to program structure and flow, since I essentially program and organize simultaneously. The only thing that's hard to do is find ways to comment, but a lot of comments can be eliminated with visual layout. Then again, maybe I don't know what I'm doing at all and that's why I find it easier to work with. Almost all my programming experience before this comes from stupid assignments at uni. =P | ||
alwinuz
Netherlands77 Posts
On January 09 2012 01:04 shannn wrote: Actually that edited idea of yours is not bad. Don't know why I didn't come up with it ![]() ![]() And I was talking generally so I couldn't really say it in a specific detail as it was a general question :D your post has helped so thanks :D To optimize, first you need to measure what to optimize. Then you need to measure if your optimization is really an improvement. For example: you can measure the average time that is spent in your update method (1) before, (2) after you changed the code. Then you have measured what your changes did to the performance. That's what a profiler is for. I cannot get more specific because I don't know anything about Cocos2D. But when I google for cocos2d profiling I get lots of hits (protip: in the left bar you can tell google to only show recent result, for example written less than a year ago). | ||
billy5000
United States865 Posts
so in java i figured out how to make a simple program that finds the distance between two points on a regular x y plane. however, the first time i tried it, the answer didn't come out right but when i just tweaked the formula, it's right. 1st method whose answer is off: double x = Double.parseDouble(args[0]); double y = Double.parseDouble(args[1]); double a = Double.parseDouble(args[2]); double b = Double.parseDouble(args[3]); double Dformula = Math.sqrt(Math.pow((b-y), 2) + Math.pow((a-x), 2)); 2nd method whose answer is correct: double x = Double.parseDouble(args[0]); double y = Double.parseDouble(args[1]); double a = Double.parseDouble(args[2]); double b = Double.parseDouble(args[3]); double Dformula = Math.sqrt((b-y)*(b-y) + (a-x)*(a-x)); Why does the second method work, but the first one doesn't? I just remembered, I have a 2nd question..why does System.out.print('b' + 'c'); produce a number? | ||
billy5000
United States865 Posts
trying to make a program that verifies cos squared + sin squared = 1 double a = Double.parseDouble(args[0]); double b = Double.parseDouble(args[1]); double cos = Math.cos(a); double sin = Math.sin(b); double formula = Math.pow(cos, 2) + Math.pow(sin, 2); System.out.print(formula); Why isn't the answer exactly 1? this exercise even asks you why it isn't exactly 1. Also, how would you do this to make it always equal to 1? | ||
Phunkapotamus
United States496 Posts
On January 09 2012 00:55 heishe wrote: We can't help you with this since we don't know your game. Also you're really vague. For loops and such things never matter, since you're not optimizing for a microcontroller (unless you want to make a game that looks really, really good. In which case microoptimizations like these are necessary. But even then you have to start at other points, like writing custom allocators etc.). 99.9% of your performance will be lost in macro-algorithms. Collision detection broad-phase, narrow phase, the way your entities interact, etc. This is really hard to say without seeing the game and the code. Generally when you want to check which parts of your code need the most time you use profilers... but I imagine this to be rather difficult since you have to test the game on the actual iOS platforms. A trivial way that I can think of now is to simply manually stop the time of different parts of your code, then sum all parts of the code together and see which part needs the biggest % of time, and start looking for possible optimizations there. I agree with this heishe's reply. You can't really optimize without knowing what you're optimizing for. Pre-optimization is a waste of time if you're going out of your standard coding style to do it. However, it is never a waste of time to change your style to utilize more efficient practices. With that in mind, know that it is also a waste of time to continually refactor your code to utilize these new practices. You will always be in a perpetual state of factorization because there will always be ways to improve. You will need to profile and quantify your performance. Without this you will not know where your issues lie. It isn't particularly difficult to write your own runtime profiler, and you may find it fun. There is an example of a decent runtime profiler in a Game Programming Gems book (I forget the version). I have seen profiler implementations similar to the Gems example in a few commercial game engines. It isn't perfect, but it gets the job done by drawing attention to potential problem areas. There are also fun third party tools you can use depending on your developing environment. I dont' have any personal experience with iOS platforms, but I'm assuming your game also runs on PC for testing. You may still get some decent information by profiling on PC. | ||
| ||