• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 10:57
CET 16:57
KST 00:57
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Winners11Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation6Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
[TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t Weekly Cups (Nov 3-9): Clem Conquers in Canada Craziest Micro Moments Of All Time? SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
Master Swan Open (Global Bronze-Master 2) Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
BW General Discussion FlaSh on: Biggest Problem With SnOw's Playstyle Terran 1:35 12 Gas Optimization BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
EVE Corporation Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Games Industry And ATVI
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1237 users

The Big Programming Thread - Page 11

Forum Index > General Forum
Post a Reply
Prev 1 9 10 11 12 13 1032 Next
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.
catamorphist
Profile Joined May 2010
United States297 Posts
Last Edited: 2010-07-13 05:09:30
July 13 2010 04:54 GMT
#201
I'm not sure -- I just don't think that you can look at a class and treat it as a method list and nothing else. To start with, those methods all have names; surely you agree that the names are important? Suppose Array.BinarySearch always returned the right result, but it only did it in linear time; wouldn't you be surprised and irritated that it wasn't logarithmic?

How do you know whether a piece of data ought to be exposed as a property or a method call in C#? Usually, the convention is that if it could take a non-negligible amount of time to get the result, it ought to be a method call (barring some lazy initialization sort of hijinx.) So here is already an example where C# suggests different best practices based on the performance of your implementation.

Most C# programmers who are collaborating with other people are vaguely familiar with most of the framework classes that implement IList and ISet, so it's not a matter of looking at all the concrete classes; you've already seen them. I think that real efficiency is being able to quickly gauge a big piece of code based on the shared experience and conventions between you and the writer, maximizing the amount of information you're communicating with your choices of design, variable names, and types. I don't see any reason that performance characteristics shouldn't be part of that information.
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
Craton
Profile Blog Joined December 2009
United States17264 Posts
July 13 2010 05:57 GMT
#202
On July 13 2010 00:51 Adeny wrote:
See how confusing that is? Think I got it though, checking out LINQ and it's some really funky stuff.
var lowNums =
from n in numbers
where n < 5
select n;

SQL-syntax for C#...


LINQ is a pretty damn nifty feature. There's a nice blog article pertaining to the cartesian product you're essentially after, but I'll have to get you the link tomorrow at work. It's a bit more than what you need, but it was an interesting read. The jist of it, iirc, was how to go about performing the cartesian linq when you don't know how many sets you have.
twitch.tv/cratonz
Tyraz
Profile Blog Joined September 2008
New Zealand310 Posts
Last Edited: 2010-07-13 06:25:49
July 13 2010 06:12 GMT
#203
Edit: seeing what is there and what is actually there is probably the worst part of debugging, to be honest.
100% Pure.
Craton
Profile Blog Joined December 2009
United States17264 Posts
July 13 2010 06:17 GMT
#204
Presumably because he doesn't want to return false and instead keep looping.
twitch.tv/cratonz
cowsrule
Profile Joined February 2010
United States80 Posts
July 13 2010 09:23 GMT
#205
On July 13 2010 15:12 Tyraz wrote:
Edit: seeing what is there and what is actually there is probably the worst part of debugging, to be honest.


What do you mean? Are you debugging with optimizations on or not using a modern debugger?
lastkarrde
Profile Joined December 2009
New Zealand66 Posts
July 13 2010 09:59 GMT
#206
I'm looking to get into parsing binary information such as SC replays and maps. I've read through the source of some parsing projects and to me it seems as if they are looking for specific codes (memory codes?) in the file which map to an event/action in plain english. Could someone explain this to me?

I also don't know what words to search for when trying to find more information on this subject. I have tried binary file parsing to no avail. Any ideas or links to docs/tutorials?

Thanks in advance for any help.
TTD
uNiGNoRe
Profile Blog Joined June 2007
Germany1115 Posts
July 13 2010 10:42 GMT
#207
Just a small note: The link to w3schools in the OP is wrong. I guess it should be .com instead of .org.
RoTaNiMoD
Profile Blog Joined January 2004
United States558 Posts
Last Edited: 2010-07-13 11:31:48
July 13 2010 11:31 GMT
#208
Adeny:

You piqued my interest sufficiently in Project Euler that I finally went for it. I did project #23 and enjoyed both the process and the afterstudy. Looking at other's code for the same problem is a telling experience -- sometimes things look so similar it's absurd, and likewise, sometimes so different it's equally absurd. Throw in people with different language preferences and the variety can be astonishing. I had a reasonably fast method but no matter how clever you think you are there's always someone who optimized it in ways you never considered. Mine ran in maybe half a second after I finished optimizing.

Key points for speed: 1) improve your abundant-number check by iterating only to square root of n, and whenever you find a match, count it for both values of the divisor-pair. 2) Use a system other than foreach to loop through the array, since that will compare every value in the array to every other value twice. This could also improve your early-exit condition by testing for if( i + ii > counter ) instead of each one individually.



All: pretty awesome that this thread has come about. Coders from all types frequent here, seeming to almost come out of the woodwork at times. I've browsed TL for a long time and have always noted that there are some serious developers around. More and more people are getting into it though which is rather nice. When I manage to get my thoughts in order, I plan to start up some discussion regarding three areas: DLL injection and other stealth techniques, dynamic web scraping, and OCR/screenscraping. I'll be able to offer a degree of insight into such things and then hope to take full advantage of those who know more than I do, perhaps ultimately being able to glean some advice or get some questions answered.
gatts
Profile Joined September 2009
1 Post
Last Edited: 2010-07-13 11:54:11
July 13 2010 11:49 GMT
#209
What about some reading tips? i.e.

Design patterns:
GoF

or

Head first

Personally im quite fond of the head first series of books. (havent really read the GoF one, but from what ive heard its alot denser so probably better as a reference)

Also in general:
Pragmatic Programmer

and Code complete

(havent read code complete yet, but it seems to be on alot of recommended reading lists)

Sorry if linking to the amazon store for the books is inapropriate in some way.

edit: Probably a better source of book recomendations: http://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read
RoTaNiMoD
Profile Blog Joined January 2004
United States558 Posts
Last Edited: 2010-07-13 12:11:08
July 13 2010 12:09 GMT
#210
On July 13 2010 18:59 lastkarrde wrote:
I'm looking to get into parsing binary information such as SC replays and maps. I've read through the source of some parsing projects and to me it seems as if they are looking for specific codes (memory codes?) in the file which map to an event/action in plain english. Could someone explain this to me?

I also don't know what words to search for when trying to find more information on this subject. I have tried binary file parsing to no avail. Any ideas or links to docs/tutorials?

Thanks in advance for any help.


lastkarrde:

Ahh, data file parsing. The beauty, as a developer, of making your own data file formats for your programs is that you can create them however you see fit. This same beauty can prove very, very ugly for those of us trying to interpret it without the documentation of what anything means. For example, let's look at a Move command in a Starcraft replay. The important parts of the Move command are the command title, MOVE, the unit(s) to move (probably represented by an ID number), and a destination (in x-y coordinates, perhaps normalized such that 0,0 is one corner and 65536, 65536 is the other). In English, then, this command could be represented by:

Move Marine (UnitID:62) to location 2640, 13280.

This however, is a lot of text. What if instead of writing Move, we just have a symbol that means move. Say, the characters MV. And instead of listing the extra stuff for the unit, we just list the ID (since there is only one Unit#62). And let's take out the words 'to location' as well. The computer doesn't need that, it's assumed from a move command. We are left with:

MV 62 2640 13280

Now, that's close to how data is actually stored. However, instead of using nice things like MV for move, or actual numbers, pretty much everything is converted to Hex. Actions are probably represented something like this

+ Show Spoiler +

00 - Stop
01 - Attack
02 - Psi storm
03 - Hallucinate
...
09 - Switch to Unseige mode
0A - Switch to Seige mode
0B - Lay spider mine
..
0F - Parasite
10 - Ensnare
11 - Disruption Web
...
9F - Gather
A0 - repair
A1 - lift off
A2 - archon meld
A3 - move
A4 - build interceptor
...
etc


Perhaps that's overkill, but it helps give you the idea. It might even be possible that there's so many commands (more than 256), that they are all represented by a 4-digit hex string. Anyway, in this example, move is A3. The Unit ID (#) in hex would be 3E. The location x,y would be 0A50, 33E0. Now, also, everything is padded with zeroes to be fixed length, so no punctuation is needed. So here's our new funky command:

A33E0A5033E0

There's a lot of other stuff that could be going on, such as variable length commands (if there are multiple units moving somewhere, for example), 'punctuation' codes (maybe all commands end with 0F0F or something). This should give you a taste though.

To write a program that reads these files, you need to basically reverse-figure-out how the developer decided to write everything. It can be anything from a minor hassle to an enormous undertaking. I'd imagine with replay/map files it's somewhere in the middle -- but a bit closer to an enormous undertaking than a minor hassle.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
Last Edited: 2010-07-13 17:20:06
July 13 2010 17:18 GMT
#211
Spoiler: Project Euler 89 solution
+ Show Spoiler +
http://pastie.org/1042721


To whoever was interested in text parsing, take a look at this. It's a very basic text parsing program. It's also somewhat efficient, runs in 15ms. I see quite a bit of room for optimization but oh wells.

Edit: Forgot to add it's in C#, which I have only been messing with for about a day now so don't expect much.
catamorphist
Profile Joined May 2010
United States297 Posts
Last Edited: 2010-07-13 17:46:20
July 13 2010 17:41 GMT
#212
On July 14 2010 02:18 Adeny wrote:
Spoiler: Project Euler 89 solution
+ Show Spoiler +
http://pastie.org/1042721


To whoever was interested in text parsing, take a look at this. It's a very basic text parsing program. It's also somewhat efficient, runs in 15ms. I see quite a bit of room for optimization but oh wells.

Edit: Forgot to add it's in C#, which I have only been messing with for about a day now so don't expect much.


A couple quick tips to let you know about C#-specific stuff that you might not realize:

* You can index into a string to get an individual character, just as if it were already an array of characters. So you don't need to copy it into a buffer to look at it.

* If you're using .NET 4.0, your file reading code could look more pleasant, like this:

foreach (string line in File.ReadLines(path))
sum += /* ... */


If you're on 3.5 or earlier, you can use File.ReadAllLines to do the exact same thing, but ReadAllLines reads the whole file into memory at once so it may not be so hot for a big file.
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
darmousseh
Profile Blog Joined May 2010
United States3437 Posts
July 13 2010 17:54 GMT
#213
I'm about to redesign an entire system for the company i work for (a small warehouse company) and am interested to know if anyone uses .NET MVC 2 and how it stacks up against other web frameworks like ruby on rails or Zend.

Developer for http://mtgfiddle.com
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 13 2010 18:42 GMT
#214
On July 14 2010 02:41 catamorphist wrote:
Show nested quote +
On July 14 2010 02:18 Adeny wrote:
Spoiler: Project Euler 89 solution
+ Show Spoiler +
http://pastie.org/1042721


To whoever was interested in text parsing, take a look at this. It's a very basic text parsing program. It's also somewhat efficient, runs in 15ms. I see quite a bit of room for optimization but oh wells.

Edit: Forgot to add it's in C#, which I have only been messing with for about a day now so don't expect much.


A couple quick tips to let you know about C#-specific stuff that you might not realize:

* You can index into a string to get an individual character, just as if it were already an array of characters. So you don't need to copy it into a buffer to look at it.

* If you're using .NET 4.0, your file reading code could look more pleasant, like this:

foreach (string line in File.ReadLines(path))
sum += /* ... */


If you're on 3.5 or earlier, you can use File.ReadAllLines to do the exact same thing, but ReadAllLines reads the whole file into memory at once so it may not be so hot for a big file.


How do I go about indexing into a string? I know strings are essentially char arrays, but szHi[5] doesn't work at all. I tried foreaching through a string, but I don't think this would work;

foreach (char c in szMyString)
{
if (c+1 == 'M')
}


Because from what I can gather char c wouldn't be an index, but rather the value of the char. The foreach for reading the file looks a bit better though, don't know if it's different performance wise.
catamorphist
Profile Joined May 2010
United States297 Posts
July 13 2010 18:48 GMT
#215
I don't know quite what you're observing, this should work:

string s = "fatso"; char ch = s[2]; // ch is 't'


See http://msdn.microsoft.com/en-us/library/362314fe(VS.71).aspx for details.

You're right that foreach iterates over values and doesn't let you get at the index, so that wouldn't work out. You would be best off with a for loop just as you have it.

File.ReadLines uses a StreamReader internally in a loop, just like you've written it, so there shouldn't be any noticable performance differential at all.
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
July 13 2010 18:51 GMT
#216
Sorry you're right, I don't know how I got the string stuff mixed, maybe I thinking C/++ for a minute there.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
July 13 2010 19:02 GMT
#217
On July 14 2010 03:51 Adeny wrote:
Sorry you're right, I don't know how I got the string stuff mixed, maybe I thinking C/++ for a minute there.

C++ strings allow access via operator[] too, and foreach in C++ is a template that basically takes a container class and a functor. You should not confuse for(int i = first ; i != last ; ++i) with a foreach loop. You can only use it to emulate one, but it is something different.
If you have a good reason to disagree with the above, please tell me. Thank you.
dimfish
Profile Blog Joined February 2010
United States663 Posts
July 13 2010 19:03 GMT
#218
On July 13 2010 18:59 lastkarrde wrote:
I'm looking to get into parsing binary information such as SC replays and maps. I've read through the source of some parsing projects and to me it seems as if they are looking for specific codes (memory codes?) in the file which map to an event/action in plain english. Could someone explain this to me?

I also don't know what words to search for when trying to find more information on this subject. I have tried binary file parsing to no avail. Any ideas or links to docs/tutorials?

Thanks in advance for any help.


RoTaNiMoD already posted a great explanation of the way to approach data file formats, but I was curious if you meant SC as in original or maybe SC2. I wrote the sc2 map analyzer which has a lot of data file parsing to do, and if that's where you at then you should definitely check out all the information the dudes at SC2Mapster.com figured out about the internal map formats. They have a section for replays but it looks like nobody has started pulling those apart over there yet. In that case you might want to PM Dakota_Fanning here at TL who wrote the sc2gears tool to rip open replays.

It's fun stuff, and I hope you get your project going.
Adeny
Profile Blog Joined January 2009
Norway1233 Posts
Last Edited: 2010-07-13 19:40:07
July 13 2010 19:28 GMT
#219
On July 14 2010 04:02 spinesheath wrote:
Show nested quote +
On July 14 2010 03:51 Adeny wrote:
Sorry you're right, I don't know how I got the string stuff mixed, maybe I thinking C/++ for a minute there.

C++ strings allow access via operator[] too.


*Mind blown*. I have been wrong all my life... How did I miss this?

THE HOOPS I HAVE HAD TO JUMP. THE ARRAYS I HAVE HAD TO CAST. Etc.
Epsilon8
Profile Blog Joined May 2010
Canada173 Posts
July 13 2010 20:06 GMT
#220
I think it would be cool if we had a poll on the first post in the thread that allowed you to vote for your favourite language. I would be really interested in that.
If you wish to travel far and fast, travel light. Take off all your envies, jealousies, unforgiveness, selfishness, and fears.
Prev 1 9 10 11 12 13 1032 Next
Please log in or register to reply.
Live Events Refresh
OSC
11:30
Mid Season Playoffs
Krystianer vs PercivalLIVE!
WardiTV1125
TKL 235
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 235
SteadfastSC 94
Rex 85
StarCraft: Brood War
Calm 3285
Rain 2279
Bisu 1720
Hyuk 1637
Horang2 920
Soma 531
Stork 334
Rush 299
Shuttle 188
Backho 101
[ Show more ]
Soulkey 79
Barracks 53
sas.Sziky 50
hero 39
Rock 35
zelot 23
sSak 23
Aegong 19
Killer 16
Terrorterran 13
Dota 2
Gorgc3723
qojqva1869
Dendi1212
BananaSlamJamma154
XcaliburYe101
Super Smash Bros
Mew2King91
Other Games
DeMusliM413
Sick378
hiko364
Hui .308
Fuzer 217
QueenE52
ceh949
Trikslyr13
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 11
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• poizon28 19
• 3DClanTV 1
• LaughNgamezSOOP
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• HerbMon 12
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 3210
• WagamamaTV437
League of Legends
• Nemesis4286
• TFBlade1021
Upcoming Events
Tenacious Turtle Tussle
7h 3m
The PondCast
18h 3m
RSL Revival
18h 3m
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
20h 3m
WardiTV Korean Royale
20h 3m
PiGosaur Monday
1d 9h
RSL Revival
1d 18h
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
1d 20h
CranKy Ducklings
2 days
RSL Revival
2 days
herO vs Gerald
ByuN vs SHIN
[ Show More ]
Kung Fu Cup
2 days
IPSL
3 days
ZZZero vs rasowy
Napoleon vs KameZerg
BSL 21
3 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
3 days
RSL Revival
3 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
3 days
WardiTV Korean Royale
3 days
BSL 21
4 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
4 days
Dewalt vs WolFix
eOnzErG vs Bonyth
Wardi Open
4 days
Monday Night Weeklies
5 days
WardiTV Korean Royale
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-11-07
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.