[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Terraria source code

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 163
Thread images: 17

File: terraria1.png (107KB, 960x520px) Image search: [Google]
terraria1.png
107KB, 960x520px
>>
File: terraria2.png (51KB, 960x520px) Image search: [Google]
terraria2.png
51KB, 960x520px
>>
why
>>
what should be in a database is instead hardcoded. that's just terrible.
>>
>>378850227
>nested else if
Why not use switchcases?
>>
otherworld when
>>
>>378850227
Most programmers are shit.
Nothing new.
>>
>>378850227
I looked at this years ago.
It actually gave me confidence as a games programmer to not get carried away with over engineering and to keep focus on the game itelf.
>>
>>378850227
someone shoop the cs grad meme on this
>>
Can they not use elif? Why use so many nested ifs?
>>
>>378850667
never
>>
>shit loot treadmill simulator has shit code

What a surprise
Won't stop /v/ from wanking this mess off
>>
>>378850825
it was his like fourth full sized project ever.

If you think it's bad now, you should have seen the source that was leaked around the beta.
>>
>>378850227
didn't chucklefuck show off Starbound's code once during a stream and it looked like a absolute fucking clusterfuck
>>
>>378850743

Become a engine programmer, then

>>378850752
So much this, first make it work, then optimize if it is needed. If you're working on your own, you can do as many hackjobs as you want, but don't forget that tech debt is real
>>
now minecraft's
>>
>>378850809
>>378850825
>>378850937
You guys are total faggots. The only thing that matters in programing is that the program works. This is why your all failures. You guys are the kind of cucks who go to a job interview, tell them that you know how to do the job better than them, don't get a call back, then shitpost on the chins saying "too smart for X"
>>
>>378850937
yes, it was about 40 times more complicated than terraria's in it's "pre-alpha" stage.
>>
File: how do I code.png (55KB, 534x344px) Image search: [Google]
how do I code.png
55KB, 534x344px
>>378851168
shut up Brianna
>>
>>378850227
>>378850284
it works and he made a lot of money off it

that's all that really matters when it comes to indie games
>>
>>378851168
That's nonsense anon.
>>
>>378850227
I still have the files stored on my google drive lmao that shit is old.
>>
>>378851168
>The only thing that matters in programing is that the program works.
yes because no one will ever have to maintain that code
>>
and here we go again, can't wait for new wave of terraria clones
>>
still looks better than the source code for starcraft
>>
>>378851168
Nigga, optimised code is essential shit. You could have a monstrous PC and if there's a ton of unnecessary bullshit in a game's code, even that monolithic machine wouldn't be able to run it smoothly.

Optimisation is extremely important so that the game can run as smoothly as possible.
>>
Users aren't reading your code they're using your program.
How many times while playing terraria have you ever stopped and said "THIS WOULD BE GREAT BUT ALL THESE FUCKING NESTED IFS ARE RUINING IT"?

It is silly but if it works nobody really cares or even knows.
>>
>>378851168
Yeah because preformance doesnt matter...
>>
>>378851168
>The only thing that matters in programing is that the program works.
WRONG
>>
>>378851642
just because he's not at the peak of optimization doesn't mean it's nonfunctional. terraria works on the absolute bare minimum of machines.
>>
>>378851265
>Tries to write C++
>Can't do simple comparisons
No wonder her game was shit
>>
>>378851704
It matters when it comes down to implementing new features and content, or having a program run bug free.

Ideally, code doesn't matter tO the user. But if adding a new item involves changing 50 nested loops in 50 places without any sorts of slippup, it can have dramatic effects.
>>
>>378851704
>DON'T TALK ABOUT THINGS THAT I DON'T CARE ABOUT REEEEEEEEEEEEEE
>>
>>378851642
>>378851737
Find 10000 people that have had performance problems with Terraria on modern PCs
>>
>>378851781
>her
>>
>>378851268
This. Expecting game programmers to code like software engineers is stupid. The fact of the matter is anyone could write this code, but they didn't
>>
>>378851780
>>378851846
In Terraria's case, the engine's simple enough for it to not cause any problems. If you were working on a significantly bigger project, however, it's going to impact performance a lot.

See >>378850937. Terraria ran just fine on my old PC, but Starbound's coding was unoptimised garbage and it barely ran on it at all.
>>
>>378851525
>maintain the code
Doesn't really matter. He sold a program as is, and you purchase it as is. He doesn't need to update it at all, outside of a few big fixes.

>>378851642
>unironically believing that most programs would need to be optimizing
Probably 99.99% of all programs don't need any optimization. A program is intended to execute a set of functions. If your program runs 10 seconds quicker than mine because of optimization, but mine costs $75 when yours costs $100, since you had to spend more time optimizing, no one is going to buy your shit, plain and simple
>>
>group project for programming class
>some faggot left so we had to pick up his code
>14 layers of nested IFs with the same 10 lines of copy-pasted code with minor tweaks in each one
Fuck me.
>>
>nested if statements
This isn't the actual source code, is it? You've just ran it through a decompiler, haven't you?
>>
>>378852032
yeah you're a dipshit

gb2/g/ with the other cargo cult programmers
>>
>>378851265
C+= would be much more her style
>>
>>378852302
>letting your superiority complex hold you down your entire life
Seek help at >>>/adv/
>>
>>378850227
This just proves that literally anyone can make a videogame.
Why aren't you making a game right now?
>>
I love how braindead everyone in this thread is
https://github.com/csnxs/terraria
This is decompiled code, of course it's going to look dumb you fucking mongoloids.
>>
>>378851642
>>378851737
>>378851738
Does Terraria perform badly? No. So does it matter that the code is bad? No. Terraria is one of the better examples of a good game and it proves that you can achieve that even with shitty code. I am not pro shitty code but Terraria is not a good example where code is shitty and game's shitty.
>>
>>378852785
I bought an onahole and the novelty hasn't weared off yet
>>
>>378850530
>break
>>
>>378852032

What a shit example, games are soft real time applications, of course performance matters. Not that a game like Terraria should have any problems with modern machines unless the dev really fucked something up, I haven't played it.
>>
>>378851905
No wonder its game was shit
>>
>decompiled
>>
>>378854119
>of course game performance matters
>but not for terraria (a video game)
I'm going to guess if your this good at mental gymnastics that you voted for Hillary
>>
>>378854309
what about this good at mental gymnastics?
>>
>>378854309

Try using your brain.
>>
>>378854489
>Says something matters and doesn't matter in the same sentence
And people wonder why /v/ is sub 100 IQ
>>
Hardcoded variables make me hard
AS
FUCK
>>
>>378851704
We're not criticizing the game, we're criticizing the code, doofus.
>>
>>378855051

Slow frame/state updates would hurt Terraria as much as any other game, but due to its comparatively simple nature this is unlikely to happen. I would think this to be implied in the post, but apparently you are eithet retarded or baiting.
>>
>>378850529
how are you getting any of that from what's posted?

Tbh it looks minified.
>>
>>378855051
You're an idiot. He's saying indie pixel shit games that can run 1000 fps on your mother's laptop. shouldn't have any issues. I can't believe I have to spoonfeed this to you, you don't even have the ability to read properly.
>>
>>378851265
Im not a coder (yet)
is it because he wrote "end" too early?
>>
Do they have the game running inside a single update function?
>>
>>378852303
Severely underrated
>>
>>378855979
>he
>>
>>378855769
>>378855902
What I'm complaining about is that people are knocking his code, when for the purposes of that game optimization clearly isn't necessary and shouldn't waste the coders time. /v/ on the other hand, has to make up for their lack of achievement or accomplishment in their lives by stating "well I'm superior since I could have written his code better". Well guess what, his game has generated over $30,000,000 in revenue while yours has not. He was smart by not pointlessly wasting his time optimemezing his game, considering the simple nature of it. I bet your parents are proud
>>
>>378855979
1. he assigns tweeter to gamergater instead of comparing it which was definitely his intention, he does the same thing on the fourth line
2. his indentation is nonsense and his second if is randomly on the next line
3. both lines would do the same thing so it could have just been an or statement
4. all this does is write "block" to stdout, youd ideally want to actually block them instead of say "block" to the console for no reason, so something like this.Block(Tweeter)
5. Tweet is probably a property of Tweeter, so Tweeter.Tweet, unless you're doing something weird but it's unclear here
6. even if the first line was a comparison, you're comparing an object against a constant value which is always going to be wrong
7. everything is capitalized, im sure theres no coding convention where this is the case
8. the second cout doesn't have a period at the end of it, this isn't actually wrong but its inconsistent

really the longer you look at it the more problems you can find
>>
>>378856473
Doesn't Terraria get updates? Bet that would have been a million times easier and saved a shit ton of time if the code was well written.
>>
>its a /v/ pretends to be an expert on a subject they have 0 knolwedg of episode
>>
>>378856732
>>378855979
>he assigns tweeter to gamergater
i meant the reverse, but you get the idea
>>
>>378856769
He already cleared a few million in revenue at that point. Just easier to hire some code monkeys for $35k salary to make the updates so that he can clear a few more million
>>
>>378856473

Not really disagreeing on that, but you were seemingly talking about the general case. Performance is as important as it has always been, whether its because of real time concerns for intense applications or limited platforms, scalability for serverside calculations, or stuff extreme enough that execution time could decrease productivity (large compiles, hardware synthesis, physics simulations etc). And users always like a snappy response no matter the context.
>>
>>378856360
>Doesn’t know Wu is trans
>>
>>378856884
BTW, since it's an assignment it's always true (assuming the Gamergater variable is not 0 or null or whatever), so what he accomplishes is blocking everyone tweeting to him. The else-block will in theory never run.
>>
>>378851168
you know how much time you have to waste to add new features when a program is such a mess?
>>
>>378857293
Not necessarily.It's false if it is assigned something that can be type converted into bool and give false, like 0.
>>
Keek is that java
>>
>>378856959
Code monkeys that would introduce a lot of new bugs because the source code is incomprehensible. Look, the point is that going the extra mile to make your code easier to maintain saves time and effort in the future, which often translates to earning more cash. But if the Terraria guy doesn't have any problems then that's cool, I'm not familiar with the games development history so I can only speculate and argue for the general case.
>>
>>378856732
thanks.
I learning the very basics of programming in September

wish me luck
>>
File: 1476846379600.png (31KB, 212x204px) Image search: [Google]
1476846379600.png
31KB, 212x204px
>people complaining about terraria's code
>they're just talking about the decompiled code
https://github.com/csnxs/Terraria
>>
File: 1474558171751.png (506KB, 851x810px) Image search: [Google]
1474558171751.png
506KB, 851x810px
You have to be retarded to think that this is production code and not decompiled. num13? num? num5? pre? Have you faggots never seen decompiled code before?
>>
>>378850227
This is a decompiled version of the sc, not the original one you idiot.
>>
>>378851780
False, it barely run in my computer. You are forgetting 75% of users when you don't take into consideration optimizations.

The first versions of Terraria used to run in my computer tho.
>>
>>378858014
The basics are fun. You will enjoy it.
Learning to code well is shit.
It's like the difference between throwing darts at balloons full of paint, and spending 12 hours in photoshop making the perfect glow effect.
>>
>>378859480
>This is what noskill-fags tell to themselves.

You will wonder then why every single indie game is a retro-clone and yet it runs like shit. It is like you guys don't want to dig into a gold mine because you found 10$.
>>
>>378851168
>buy programming suite
>or anything used in the company
Those job stealer can just bitch the fuck out I'm not sharing my "knowledge" LOL
>>
>>378859827
>your entire post

What? I'm not saying learning to code well is a bad thing. It's just boring as shit and becomes a chore rather than something I enjoy.
>>
>>378850227
This looks like reverse engineered code, so it's not a shock that it's shit
>>
File: no.png (30KB, 215x608px) Image search: [Google]
no.png
30KB, 215x608px
>>378860158
>reverse engineered
this board is full of clueless faggots
>>
>>378851168
I agree code doesn't necessarily have to adhere to any arbitrary standards, but it is important it runs EFFICIENTLY.
That might mean programming it differently than even the "approved methodology", but keeping it clean will help you in this task and if anyone else looks at it it's a complete necessity for easily understanding it. Of course, using lots of comments can mitigate this to some extent.
>>
/v/ doesn't even play games, let alone know how to even program them.

why is it pretending to know how to code games now?
>>
>>378860239
I'm pretty sure the database was stolen too, while we're at it.
>>
>>378860474
I don't know.
The code seems fine to me actually. Like other people said, it looks decompiled. But nothing about it suggests inefficient use of resources which is the actual thing that matters at the end of the clock cycle.

that one sicko creepy stalker panty game though looked like it had pretty bad code though.
>>
File: 1495616680958.jpg (61KB, 500x573px) Image search: [Google]
1495616680958.jpg
61KB, 500x573px
>>378856360
>she
el oh el
>>
>>378850529
>>378860653
Explain to me the benefits of using a database over constants in this situation.

This is a video game. If you have a remote database, you're adding an unnecessary dependence on an internet connection and a remote server.

If you have a local database, you still have to do a full release when you want to modify something. Not only that, if you modify the structure, depending on what kind of database you're using, that could force you to have to drop all saved data. With constants, all you need to do is update a dll. With a database, you have to potentially rebuild the entire thing with 1 release.

Stop being a retard
>>
>>378856732
plus he presumably uses namespace std; which is just triggering on its own
>>
>>378850227
This actually makes me want to make a game now.
What do I need to make a simple 2D game? I know Java and some C++.
>>
>>378861093
I think he means ini file that you read with values in it that you can easily modify.
>>
>>378858675
That doesn't change the fact that the item variables are hardcoded and aren't stored in a table. What do you think is better, scrolling through ten thousand lines of code to change the stats on a single item, or just editing it in a spreadsheet?
>>
File: 1337473826818.png (139KB, 761x494px) Image search: [Google]
1337473826818.png
139KB, 761x494px
>>378861356
Seriously, you need to shut the fuck up if you don't know what you're talking about. You have no idea if anything is hardcoded in the game, because guess what, that's what code will look like when it's compiled.

Write some C++ or C# or whatever the fuck you use. Compile it and decompile it. Look at it and then maybe you will realize how retarded you look at this moment.
>>
>>378861352
That's not a database then, and he sounds as retarded as whoever he's critiquing. Also, assuming this is decompiled code, we have no way of determining whether those were constants in some file or not because your compiler doesn't keep that information
>>
>>378861764
Is this thread archived anywhere?

>>138476624
>>
File: 1468311704928.jpg (78KB, 429x904px) Image search: [Google]
1468311704928.jpg
78KB, 429x904px
>>378861764
Did you actually look at the code you mongoloid? All the items are like this, which means they are hardcoded in a switch instead of a database.

If it were in a database, you would find that database in the source. So find that database and prove me wrong. Protip: You can't.
>>
File: 1315448395036.gif (46KB, 491x324px) Image search: [Google]
1315448395036.gif
46KB, 491x324px
>>378862342
You are a fucking imbecile. I hope you don't work for any company, and if you do, I feel sorry for them.
>>
>>378862342
Tell me why he should use a database.

While this code looks more human readable and is probably not decompiled, you have yet to demonstrate why a database is preferable to compiled constants
>>
>>378850227
sure is dumb thread in here
mods should delet
>>
File: 1486043741997.jpg (135KB, 1280x720px) Image search: [Google]
1486043741997.jpg
135KB, 1280x720px
>>378862482
>Can't find the database, thus losing the argument
>Resorts to namecalling

As expected
>>
>>378861352
Also, are you talking about an ini file that anyone could edit? Why on earth would you put game logic constants in that? That is just asking to have your game broken by anyone who opens it up
>>
>>378862547
Are you just going to repeat "database, database" like a fucking parrot?

Who gives a fuck about a database? These conditionals might as well check against enum values. You don't know, and neither do I, because we don't look at actual human written code.

Now fuck off, nodev.
>>
>>378862501
Because switching through thousands of values is much less efficient than using a set, map, table, etc... Switch isn't meant to be used for extremely large datasets and you won't find any professional recommending switch be used that way.
>>
>>378862342
>Guys, he's not using a REST call to google to do his math for him
>Guys he's not even using JSON for his objects, there's not even any deserializer in this code
>Guys he's not using algorithms that take in a string and produce a unique id based off that string for his constants

What other rube goldberg shit is he not using?
>>
>>378862582
yea, well I thought he was talking about items which would make sense in context of items because then it'd be easy to just add shit for him and other people.

I personally know that that part of the game does actually function correctly and the part of the game that's obviously broken on some innate level is actually the wiring system.
the rest seems to actually run completely fine, the wiring system just isn't capable of some things because it starts exploding for no reason.
>>
File: 1469110286242.jpg (27KB, 399x385px) Image search: [Google]
1469110286242.jpg
27KB, 399x385px
>>378862964
>Using strawmen to defend a ten thousand line switch statement
Stay classy, anon
>>
>>378862809
Constants in a single application are not "Extremely large datasets" you fucking mongoloid.

Yes, constants in database have their uses, especially for enterprise software and data that spans across multiple applications, but this is a fucking single application that does not require the use of an internet.

Explain to me why either A. Adding an unnecessary network dependency or B. Adding unnecessary complication to his releases is more preferable than enums or a file for constants.
>>
>>378863083
I'm not defending his code, I'm calling you as retarded as him.

You probably learned what a database was last week and have no idea where they're useful and where they're not.
>>
>not using 100% hand written machine language code
>>
>>378862809
Don't most compilers optimize Switches into if/elses anyway?
>>
>>378861269
Honestly, just use Game Maker. The language it uses is easy as hell and well documented.
>>
>>378863174
>I'm not defending his code, I'm calling you as retarded as him.
Why? A database is an obvious alternative to his extremely poor implementation.
Since you view yourself as intelligent enough to qualify someone as a "retard", enlighten us plebians on how to store values for 10k items.
>>
File: 1494911274745.jpg (506KB, 1428x781px) Image search: [Google]
1494911274745.jpg
506KB, 1428x781px
Now I don't feel so bad about my programming.
>>
>>378863249
A little bit of research revealed to me that switches usually turn into jump tables in machine code. If/else conditions can turn into jump tables as well, but it depends on the compiler.
>>
>>378863720
I mixed that up, then.
>>
>>378863249
That's exactly what happened >>378862342

But having to go through potentially 10k conditionals to get a single item's values is horrible. Does it work? Yes. But this situation is common and programming languages offer alternatives made specifically for this situation that are more efficient and cleaner.
>>
>>378863534
Do you think there are 10k constants in terraria? Talk about strawmen. Either way these are game logic variables that are created by hand and used by hand. Enums are better here because they're compiled, you don't have to read some file or go across the network to grab them. They're just as organizable and viewable as a database, you have intellisense so you don't have to manually type the entire constant name every time you need to use it. If you need to add an enum or modify one for every reason, there's no complicated release process, all you do is edit the source file and you're done.


Databases are used for storing large amounts of variable data. Constants are typically only put in databases when they're shared constants or might be shared in the future. I've been working in software for 4 years and built numerous applications. The only time we put constants in databases is when we need to reference it somewhere else. If it's a constant that's used only for one specific app, we put it in config files, or if it's logic related (Like this code is), we use enums.
>>
>>378850530
Yeah because nested switch case is so much better
Holy shit is /v/ is tech illiterate. I hate this word but, CRINGE
>>
>>378863998
>Do you think there are 10k constants in terraria?
Yes. See for yourself:
https://github.com/csnxs/Terraria/blob/master/Terraria/Item.cs

You have to view the raw because it's so big that github can't handle it.
Really... makes... you... think... doesn't.... it...?
>>
>>378864337
I'm glad that's what you got out of my post.

Keep building rocket ships to get to the grocery store anon, your managers will love that.
>>
>>378854162
>its
*it's
>>
>>378864420
Literally none of what your saying makes sense.
Code maintenance is kind of a big deal.
This spaghetti code is awful.
>>
>>378864691
Yes, code maintenance is an incredibly big deal, which is why you'd use enums instead of database values or hard coded numbers.
>>
>>378864679
>No wonder it is game was shit

Really makes you think
>>
>>378864798
Thats right.
>>
>>378852032

What a fucking moron. The worst thing is this moron genuinely think he knows what he's talking about.
>>
File: 1493891453965.jpg (111KB, 1280x720px) Image search: [Google]
1493891453965.jpg
111KB, 1280x720px
>>378864420
>Still defending a 10k switch
>It's okay because it's compiled!
>He doesn't mention a hashset or even an array which is also compiled and would be 100x faster.
Keep digging I'm enjoying this.
>>
>People complaining about the code of a very successful and actually great game despite them not being able to be even .1% as successful as RED

Really piques my pistachios
>>
File: aroldis meme man.jpg (11KB, 266x190px) Image search: [Google]
aroldis meme man.jpg
11KB, 266x190px
>>378864991
>I'm defending hardcoded numbers
>100 times faster
>Arrays are somehow faster than constants, even though arrays are pointers and constants are compiled out to be the actual number so no space in memory is even needed
>Arrays eliminate the issue of hard coded numbers, because instead of just a hardcoded value, you have a number associated to that hardcoded value
>Hashset
>More maintainable than an array, but still slower than a constant because it's a pointer and you need to go into memory to grab that value instead of having it right there in the instructions

I'm fucking sick of you retards.
>>
>>378864991
Is that really, honest to god, a 10k entries long switch? That somebody would write that boggles the mind. Like, at some point around case 4000 or so, a normal person would probably think "Maybe I should do something about this"
What even in the fuck is being compared here? What the fuck are there ten thousand different possibilities of?
>>
>>378864991
>Still thinks there are 10k constants
>Provides a memory inefficient, complicated, unreadble solution to a non-issue
>Basically dick waving

No one cares
>>
>>378862046
Technically it is a database. But yeah I get what you're criticizing.
>>
>>378861764
Are you dumb? C++ is an unmanaged language, it's completely different than c#
They don't decompile even slightly similarly
C#'s IL is easily reversalble into quite close to source, whereas c++ isn't going to be anywhere near it
>>
Who cares. It doesn't look too pretty but its not like doing a massive if statement tanks your program efficiency.
>>
>>378865362
>Hashset
>Slower than a switch
Aaaand we are done. I'm clearly arguing with someone who doesn't understand the basics.

>>378865413
>What even in the fuck is being compared here?
thousands of in-game items with different values.
>a normal person would probably think "Maybe I should do something about this"
I agree. The only excuse is ignorance. The problem of "I have thousands of unique identifiers with associated data that I need to store and access" has been tackled many times in much better ways.
>>
>>378850227
>>378850284
If it works who cares, you're making an indie game that any toaster can run, not a super calculator of some equation that can take a O(n^n) time if you code it wrongly.

First and foremost you need to focus on making the code work, then if you're unsatisfied with the result you start optimizing it. But then again this is a crappy light indie game that works decently already, not some company calculator.
>>
File: IMG_2151.jpg (112KB, 640x885px) Image search: [Google]
IMG_2151.jpg
112KB, 640x885px
ITT: No name programmers complain about a code that made millions
>>
>>378865801
>>Hashset
>>Slower than a switch

You replied to my post. I never mentioned the switch statement. I was talking about using constants and enums instead of a database to store your constants. Even in my post calling you retarded, I never mentioned switches, I was still talking about data structures for logic constants. Not logic itself.

I can't sit here and argue all day with you fucking idiots, especially when none of you bother to fucking read.
>>
>>378865801
I'm a beginner at coding, and even I think something like a lookup table would be more efficient. Hell, back in the NES days they used lookup tables, and it was all in Assembly!
>>
>>378865801
Also, switch statements and hashsets are both n(1), however with a hashset you have a to worry about memory implications, especially with large datasets, where as a switch statement, you don't need to worry about that because it's instruction based, not memory based.

I'm not saying one is cleaner than the other, because that depends on the application, but saying that a switch statement is 100x slower than a hashset is fucking ignorant as fuck.
>>
>>378865992
>I was talking about using constants and enums
Look at the item code again. There are (hopefully) enums representing the itemtypes, and the item-specific constants are being accessed by switching the enum. This is NOT more efficient than a set and I hope for your employer's sake you are competent enough to understand this.
>>
you cs101 dropouts need to get off of this board
>>
If you went to take classes instead of being self-studying neckbeards you'd hear from any professor that the first thing you need to do is to make the program work, only then you can go full autism about efficency if you have to, and spoiler alert, in most cases you don't.
>>
>>378866232
>n(1)
I meant O(1).

>>378866478
If both operations take a nanosecond to run, how is having a giant block of memory used by a hash set more efficient than having nothing in memory for that same logic?

Readability and maintainability is one thing, but efficiency is another. You need to go to an algorithms/datascructures class.
>>
>>378866665
You are certainly using more memory for a hashset, but you are trading memory for performance. The benefit is when you open a shop, the game thread doesn't hang because you are greeted with a hundred unique items that need to be looked up.
>>
>>378866590
The one I learned from had so many fucking formatting rules. Absolutely infuriating losing marks for silly shit that had nothing to do with the program itself.
>>
>>378855824
this
people are retarded
>>
>>378855824
>Minified
This isn't JavaScript
>>
>>378867471
I think you have a misunderstanding of how a switch statement gets compiled down. It is an instant operation, it is significantly more than a simpler way to write an if/else statement. Your compiler creates a jump statement based on the constants in the switch statement and the variable passed in. If you have 5000 cases in a switch statement, you do not have 5000 comparisons in assembly, you have 1 jump statement.

Please please please look at what your compiler does before talking about efficiencies of algorithms
>>
>>378853135
>This is decompiled code
should've known, thanks anon
OP is a faggot
>>
You stupid fucks

All this garbage you are seeing is decompiled code, which is almost completely different from the original code.
You see tons of else ifs because that's what the compiler does when compiling to IL, try decompiling anything professional and you'll see the same stuff going on.
>>
>>378866558
Not a dropout, quite a bit further ahead than CS101
>>
File: 1493840410038.jpg (342KB, 1510x1148px) Image search: [Google]
1493840410038.jpg
342KB, 1510x1148px
>this fucking thread
>>
>>378856473
You've obviously never had to debug someone else's shitty code if you think this has everything to do about achievement
>>
>>378868283
Thank you for describing literally how every compiler acts.

Too bad not every compiler acts the same. Some compilers will run a case statement just like an if/then/else unless there are 10+ cases. Some compilers build it exactly the same.

Good compilers only run a single comparison, but that's not the rule.
>>
>what is a compiler optimization
>what is obfuscation
>>
>>378861093
>Explain to me the benefits of using a database over constants in this situation.
Adding/altering items doesn't force you to recompile the binaries.
Thread posts: 163
Thread images: 17


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.