Tales from the front line S01E04

The only place you'll ever hear the truth
nea
level0
Posts: 3
Joined: Wed Mar 05, 2008 7:35 pm
Location: Germany

Postby nea » Fri Jul 18, 2008 3:32 pm

elDiablo wrote:
nea wrote:Uhhh... you could at least indent the further ternaries...


Now THAT would look nasty. You'd have a massive tail going across your screen, stretching your document out :(


And THATs a reason I don't like them ^^' You have to understand recursion to understand recursion! The same reason I prefer relaxng cs instead of XSD as I simply cannot get why to define xml by xml so that I have to created immense tails for just small grammar decisions.

Ah, programmers preferences are always good topics to talk about ^^'
brog
level1
level1
Posts: 22
Joined: Fri Jun 22, 2007 10:11 am

Postby brog » Fri Jul 18, 2008 3:50 pm

elDiablo wrote:

Code: Select all

switch (currentWeaponType)
{
    case (item0.type):
        currentWeaponType = item1.researchLevel > 0 ? item1.type :
                            item2.researchLevel > 0 ? item2.type :
                            item3.researchLevel > 0 ? item3.type :
                            item4.researchLevel > 0 ? item4.type :
                            item0.type;
        break;

    ...

}


This is not ugly, certainly not diabolic. If you wanted to make it a bit confusing you could spice it up by having nesting on both sides of the colons. You know, a ? b ? c : d : e ? f : g sort of thing.

However.. I don't really like the assumption that there are only four item types. Why not have a general data structure of possible item types which you just iterate across to find the first researched one?
User avatar
Phelanpt
level5
level5
Posts: 1837
Joined: Thu Aug 10, 2006 4:20 am
Location: Portugal

Postby Phelanpt » Fri Jul 18, 2008 4:58 pm

Heh, awesome posts, Byron! :D

I rarely use the ternary operator, and it's mostly for yes/no (singular/plural, etc.) output.
User avatar
prophile
level5
level5
Posts: 1541
Joined: Fri Feb 18, 2005 4:17 pm
Location: Southampton, UK
Contact:

Postby prophile » Fri Jul 18, 2008 4:59 pm

Shouldn't this be looked up from some kind of table? Don't hard code stuff, man. Bad Byron! Bad elDiablo!
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Fri Jul 18, 2008 5:21 pm

prophile wrote:Shouldn't this be looked up from some kind of table? Don't hard code stuff, man. Bad Byron! Bad elDiablo!


oh thanks - what did I do?

Right, that's it - sulking now.

*sulk*

Okay, sulking over. :)

Ah, the old data driven versus hard-coded argument eh? I am in favour of both.
Last edited by Byron on Fri Jul 18, 2008 5:43 pm, edited 1 time in total.
User avatar
ynbniar
level5
level5
Posts: 2028
Joined: Wed Nov 08, 2006 10:36 pm
Location: Home again...

Postby ynbniar » Fri Jul 18, 2008 5:35 pm

Crumbs...somebody get the coders back in their cubicles before some trout get smashed :!:
User avatar
Pox
level5
level5
Posts: 1786
Joined: Sat Mar 03, 2007 11:23 am
Location: Melbourne

Postby Pox » Sat Jul 19, 2008 2:34 am

Ah, is that was does the smashing, Byron putting trout in the server?
User avatar
NeoThermic
Introversion Staff
Introversion Staff
Posts: 6256
Joined: Sat Mar 02, 2002 10:55 am
Location: ::1
Contact:

Postby NeoThermic » Sat Jul 19, 2008 2:34 am

prophile wrote:Shouldn't this be looked up from some kind of table? Don't hard code stuff, man. Bad Byron! Bad elDiablo!


If things were not hardcoded, most of IVs games would break! :)

Also, we need more mind-popping-ness. I suggest we obfuscate the given example to be far more complicated than it looks :)

NeoThermic
Mas Tnega
level5
level5
Posts: 7898
Joined: Sat Mar 02, 2002 11:54 pm
Location: Edinburgh
Contact:

Postby Mas Tnega » Sat Jul 19, 2008 2:45 am

Time to bring out the brainfuck interpreters?
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Sat Jul 19, 2008 10:54 am

Mas Tnega wrote:Time to bring out the brainfuck interpreters?


I have been tempted. John's very much into alternative languages so it would appeal to him. Perhaps you could persuade chris to make that the official scripting language of Subversion?
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Sat Jul 19, 2008 11:05 am

Forget Brainfuck, use Piet programs for in-game content or little Easter eggs!
Uplink help: Check out the Guide or FAQ.
Latest Uplink patch is v1.55.
User avatar
NeoThermic
Introversion Staff
Introversion Staff
Posts: 6256
Joined: Sat Mar 02, 2002 10:55 am
Location: ::1
Contact:

Postby NeoThermic » Sat Jul 19, 2008 12:51 pm

Malbolge is my fave esoteric programming language. I mean, the first program was computer generated in 2 years using a beam search. That's one heck of a difficult language.

NeoThermic
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Sat Jul 19, 2008 1:02 pm

Anyone played Core Wars? I've read into much of the history and detailed breakdowns of some of the generic warriors. Pretty fascinating stuff. Been wanting to give it a whirl myself.
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Sat Jul 19, 2008 1:33 pm

I played core wars for a while ages ago, it was the first programming code I used - makes for a nice and easy introduction into the world of programming ;)

Introversion Core Wars hill anyone? ;)
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
Mas Tnega
level5
level5
Posts: 7898
Joined: Sat Mar 02, 2002 11:54 pm
Location: Edinburgh
Contact:

Postby Mas Tnega » Sat Jul 19, 2008 6:23 pm

Sure, why not? Why not complicate it and say the king has to play a year on a Dwarf Fortress succession. Set a goal for the Fortress, and then at least running the Fortress will get rather... strategic.

*switches brain off*

Return to “Introversion Blog”

Who is online

Users browsing this forum: No registered users and 6 guests