Carlin Auditorium Contents: Cobra WiP(#126vIq) Maniatis Final Test Section Obvious exits: Out Mark_Farrell smiles. There is some ''interesting' stuff on #126 you might want to browse through. Cobra says "the last log i have is from 24/11 - 95" Cobra says "about the progress on the game" Mark_Farrell chuckles. "Well, I've given 8 lectures/talks so far. The first few were more lecture like - the last number have been workshops more than lectures. You say "We can certainly go back to the poker game, if you want." Cobra says "i have all of them so .." Cobra says "no that's not nessessery .." Cobra says "I'm working on a alloc computer myself .. got some help from lister and recoded it .. i saved some 40 regs due to that recode ." Mark_Farrell hums. "Okay. I'm not sure that to talk about. I can cover some of the ways that I use the 'u()' function to reduce the amount of duplication in my code, but I covered most of that before. Mark_Farrell smiles. Cobra says "but is still have some 2k+ things that i have to split up .." You say "As if flying a ship wasn't easy enough already :-)" Mark_Farrell nods. You say "We can work on them now, if you'd like." Cobra says "well i'm trying to get the stress into a function now .. put in reactor stress and stress level , out time to critical stress or to no stress" Mark_Farrell smiles. You say "Right. I can help with the coding, but I don't have the actual formulas :-)" Cobra says "well the problem i have with to big codes are that i want to type in : check preflight and get out all the commandos needed for all consoles to get the alloc set on the shipo" Mark_Farrell nods. Cobra says "ei esr X ; ea X X X ; ha X X ; qa X X .. for a CA" EDITOR: X = actual numbers used. This log may go outside the Federation. You say "Get out is 'emit' I presume?" Cobra says "no a "pe" Mark_Farrell was using emit in a general sense. Cobra says "ok :-)" Cobra says "shall i get it down here or ?" Cobra says "the objekt that is" You say "you can do :-)" *Mark_Farrell* TIME:Tue Feb 13 15:52:05 1996. STARDATE: 96117.6 Cobra says "brb" Cobra goes home. Cobra has left. Cobra has arrived. Cobra enters from the Quad. Cobra dropped CEDS. Cobra says "warning for the W regs a to m or n" Mark_Farrell will not bother to ex the whole lot. You say "Lets take the code apart under your guidance." Cobra says "ok" You say "Pick somewhere to start...." Cobra says "start with xk" Xk:$Check *:[u(#8074/xb,v(0),17)];@pe v(#)=s(%%resr [v(wa)][v(wb)]%%r;@pe v(#)=s(ea [v(wc)] [v(wd)] [v(we)];@pe v(#)=s(%%rha [v(wf)] [v(wg)]%%r;@pe v(#)=s([ifelse(truth(member({bcloak offense open},u(#8074/xc,17))),v(wi),v(wh))];@pe v(#)=s(%%r[ifelse(truth(member({offense open Sstrafe},u(#8074/xc,17))),v(wk),v(wj))]%%r Mark_Farrell nods. Cobra says "the first part sets xa # 17 to the name you want to check preflight and so on .." Xb:@xa #8074=[replace(v(xa),v(1),v(2))] Mark_Farrell nods. Xa:XX XX XX XX XX XX XX XX XX XX XX XX XXX XX XX XX strafe preflight Cobra says "for some strage reason i get an 18 # on xa some way ." Cobra says "wa is the code for the reactor setting .. wb for battery .." Mark_Farrell nods. *CEDS(Cobra)* esr XX *CEDS(Cobra)* ea XX XX XX Cobra says "and the xk goes on until warp as been written out .." *CEDS(Cobra)* ha XX XX *CEDS(Cobra)* qa XX XX *CEDS(Cobra)* Cobra says "as you can see i have som problems with the nav commands they are the ones getting realy big" Wa:[ifelse(match(Dcruise,u(me/xc,17)),u(me/xc,11),ifelse(truth(member({Bolt Sstrafe Astrafe},u(me/xc,17))),u(me/xc,13),u(me/xc,12)))] You say "Okay. Lets go right from the top. You calculate all the numbers from the formulas you know about?" Cobra says "yes" You say "Ie, you just know the engineering power factor, EroC's and so on?" Mark_Farrell nods. Cobra says "type see asettings" Wb:[ifelse(match(ifelse(truth(member({IStrafe Bolt SpCruise Sstrafe Astrafe},u(me/xc,17))),u(me/xc,10),u(me/xc,9)),0),,{ b+ })] *CEDS(Cobra)* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ** Settings ** Max Phaser: XX Number of Phasers: XX Phaser EROC Total: XX (XX) Phaser Maintain Total: XX (XX) Photon EROC Total: XX (XX) Number of Photons: XX Shield: XX Energy 100: XX Normal Battery: XX Max Battery: XX Esr Destress: XX Esr Normal: XX Esr Max: XX Ophasers: XX Battery load: XX Raised shields: XX The values between the () is for one phaser/photon. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark_Farrell nods. Mark_Farrell looks firstly at wa and wb for printing your esr. You say "You basically need a simple switch between standard and max, yes?" Cobra says "yes standard max and destress" Mark_Farrell nods. Cobra says "i use ifelse" You say "Okay. Let me show you a novel use of 'lookin()'" Cobra nods. You say "Say you store the esr's as a consecutive list - ' ' in some register somewhere." Cobra says "check xa :-)" You say "Let us say further, that you have sorted the member(IStrafe Bolt SpCruise .....,selection)" You say "Stored, not sorted..." Cobra nods You say "Instead of the actual thing the user specified." You say "So, in effect, we have a number from 1 to max, or 0 if the selection was invalid." You say "Okay - so you follow the logic behind using a small number to match against, rather than long string?" Cobra says "as i have done it i have 3 settings for esr .. and the normal setting dubbels as the free setting for the open alloc command" Mark_Farrell nods. Cobra says "yes" You say "Okay. Let us then turn back the the means of turning this number into Max/STD/DST" Cobra nods You say "If we (for convenience) as we'll use this a lot, do, @somereg=_0, we have something starting with a _, that will not be easily confused in a lookin, with anything else." You say "Let us then use something like: lookin(_1 1 _2 1 _3 2 _4 3,v(somereg),1) to turn the selection into a number from 1 to 3" You say "Where: @somereg=_[member(alloc list,selection)]" You say "All you then need to do is a simple extract(v(xa),add(lookin(_1 1 _2 1 _3 2 _4 3,v(somereg),1),offset),1) to return the esr." Cobra nods. You say "Where offset could even be built into the lookin." You say "That saves you the need for the add()" Cobra says "and the setting of the number could be done by puting the namnes in a reg and do something like this extract(v(1),extract(v(xi),1,1),1)" You say "Because you are using a simple mapping list fior the lookin, it makes adjusting the code fairly easy, if you want to allocate a different esr for a particular setting." You say "Then, the code from wa and wb is short." Cobra says "we have to change it some .." Cobra says "my code that is .." You say "A little." Cobra says "the problem comes in wd and even worse in wh to wk ." Mark_Farrell looks at wd Wd:[ifelse(match(Preflight,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,12),u(ceds/xc,3),0,0),ifelse(match(Cannon,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,12),u(ceds/xc,3),u(ceds/xc,5),0),ifelse(match(Acloak,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,12),u(ceds/xc,4),div(u(ceds/xc,5),6),0),ifelse(match(Bcloak,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,12),u(ceds/xc,3),div(u(ceds/xc,5),6),0),ifelse(match(Offense,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,12),u(ceds/xc,3),div(u(ceds/xc,5),2),0),ifelse(match(Scruise,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,12),0,0,0),ifelse(truth(member({Cruise Strafe},u(ceds/xc,17))),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,12),u(ceds/xc,4),0,0),ifelse(truth(member({SStrafe AStrafe},u(ceds/xc,17))),u(ceds/xh,u(ceds/xc,10),u(ceds/xc,8),u(ceds/xc,13),u(ceds/xc,4),0,0),ifelse(match(Spcruise,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,10),u(ceds/xc,8),u(ceds/xc,12),0,0,0),ifelse(match(Dcruise,u(ceds/xc,17)),u(ceds/xh,u(ceds/xc,9),u(ceds/xc,8),u(ceds/xc,11),u(ceds/xc,4),0,0),ifelse(match(Bolt,u(me/xc,17)),u(me/xh,u(me/xc,10),u(me/xc,8),u(me/xc,13),0,0,0),ifelse(match(IStrafe,u(me/xc,17)),u(me/xh,u(me/xc,10),u(me/xc,8),u(me/xc,12),u(me/xc,4),0,0),if(match(open,u(me/xc,17)),u(me/xh,u(me/xc,9),u(me/xc,8),u(me/xc,12),mul(u(me/xc,14),u(me/xc,2)),u(me/xc,5),u(me/xc,15)))))))))))))))] Mark_Farrell takes a step back. Cobra says "xh is a reg that counts the power for the nav console" Mark_Farrell nods. "Lets stick with wd for now." Cobra says "u(ceds/xc,9) extracts #9 from the xa reg" Mark_Farrell nods. You say "Which setting does this one display?" Cobra says "its the power to nav in the ea command" Cobra says "or did you mean #9 ?" You say "wd as a whole." Cobra says "the power to nav .." You say "So - what it does is to basically look at the selection, and to return a number based on it." Cobra nods. You say "For a given setting, the mode is dependant on what is allocated to helm, more than anything else - yes?" You say "Generally, unless you are destress, no power if allocated to batteries." Mark_Farrell has been out of SF's loop for a long time - you'll have to forgive me being a little slow :-) Cobra says "yes it takes the esr setting the battery power if any and substracts the the power given to helm" Mark_Farrell nods. You say "All the other allocations are dependant on this total power available." Cobra says "have you tried check strafe for exampel ?" Cobra says "yes" You say "So - to save having to work it out every time we need it, what we can do is to use U() to just do it once." Mark_Farrell starts to draw a tree showing dependancies. Cobra says "nop .." You say "No?" Cobra says "you have to do it for every alloc that are diffrent" Mark_Farrell nods. "I meant within each particular alloc. All the settings for nav/helm/warp/shields/phasers/photons are all based on this total power, and then on the subdivision of this power? Yes? Cobra says "preflight , cannon as exampels has no powers from batts" Cobra says "ok" Cobra says "yes" Cobra says "but the values in are diffrent" You say "Okay. So, lets restructure the code a little bit." You say "I know." Cobra says "this are xh ( batteri max , 100 , reactor setting , open phaser , photons eroc , batteri laddning )" Mark_Farrell nods. Cobra says "fsub(fadd(v(1),fmul(v(2),fdiv(v(3),100))),add(v(4),add(v(5),v(6))))" RS(#7575I) created. Dropped. Locked. Flag set. You say "Looks at RS" Flag set. RS grows ears and can now hear. Flag set. Mark_Farrell finally gets va right: $rcheck *:@pe %#=[Ur(#7575/xa,lookin(Preflight _1 Strafe _2,v(0),1))] Huh? (Type "help" for help.) You say "So, as far as the code called by the Ur() is concerned, v(1) is _1, or _2, or nothing." You say "Then if you look at #7575/xa: DoESR: [Ur(#7575/xb,v(1),)]" You say "We use Ur() again, to pass the ESR we chose further down the 'tree' of nested U()'s." You say "So, as far as the code in XB is concerned, v(1) is _1 or _2, or whatever, and v(2) is the esr()." You say "The code in xb is : DoTOT: Esr is [v(2)]%%r%%r[.......]" You say "So, it puts Esr is followed by two linefeeds into the string returned to the @pemit, and then does the [...... - that would use the esr and the alloc to calculate the total power available." You say "That'd call xc, whioch would split the total between nav, helm, and batteries." You say "Then xc would call xd and xe for nav and helm allocations of their particular bit of the power." Mark_Farrell pauses for breath. Cobra says "ok timeout here" Cobra says "rcheck strafe would call _2 ?" You say "No. Let's look at va more closely." You say "1. Ur() is similar to U() but takes the 'rest()' of the thing you point at." You say "So, If called the code in #7575/xa" Cobra says "so it call 2" You say "> lookin(Preflight _1 Strafe _2,v(0),1)" Cobra nods. You say "If v(0) is 'Preflight' then it returns _1. That gives us Ur(#7575/xa,_1)" You say "The lookin() returns either a null string, if the allocation isn't found, or the thing after the name of the allocation." Cobra nods. You say "taking Ur(#7575/xa,_1), it means that for the code in #7575, v(1) is going to be _1" Cobra nods. You say "Okay. So, it means that as v(1) is now the result of that lookin, we never need to do it again for the code in xa, because it's already available." You say "We can apply a similar principle to save on the amount of work we do calculating energy totals." Cobra mods. Cobra says "how ?" You say "So - because we use the 'esr' a lot, xa calculates that, and passes: Ur(#7575/xb,v(1),the-esr) to xb. Now v(1) is still _1, or whatever, so we pass _1 and the esr to xb" You say "xb sees v(1) as _1, and v(2) as the esr." You say "Do you follow?" Cobra says "no" Cobra smiles alittle Mark_Farrell nods. "Okay." You say "Which bit don't you see?" Cobra says "v(0) in va == _1" Cobra says "v(1) in xa == _1" Mark_Farrell nods. Cobra says "code to calculate esr == extract right number" You say "Okay. That's because of U() and Ur() having special properties." Mark_Farrell nods,. Cobra says "put then i need a ifelse or something there the in the code ." Cobra says "put == but" You say "The definition of U() is such that U(object/register,,,.......,optarg9)" Cobra nods. You say "So, U(#7575/xa,A,B,C,D,E,F) puts A into v(1), B into v(2).....F into v(6)." Xa:DoESR: [Ur(#7575/xb,v(1),)] Cobra says "yes" Mark_Farrell plays with xa to show you more of what he means. Cobra says "i know u()" Cobra says "i haven't used ur() .." You say "Ur is the same, but you can put a word at the start of the register to describe the function." Cobra nods. You say "If you look at XA, you see the 'DoESR:' at the beginning." You say "The 'r' in Ur() means 'rest of'" Cobra nods. You say "I usually use Ur() and have something like: DoEsr:Alloc:" You say "To let me know that this Ur() takes an 'allocation' as it's first arguement." Cobra says "i code in a diffrent window and save that ..." Mark_Farrell could have something like: @reg obj=Dist3D:b1,e1,r1,b2,e2,r2: ....... Mark_Farrell nods. Cobra nods. You say "I prefer to have the stuff online. It helps if someone else tries to maintain/fix the code/." You say "Where online is usually an offline fget() type file." Mark_Farrell smiles. *Mark_Farrell* TIME:Tue Feb 13 17:05:28 1996. STARDATE: 96117.7 Cobra says "yes i haven't gotten then that far .." You say "Aye." You say "I tend to code directly into TF too, but keep rough notes of register use separately" Xa:DoESR: [Ur(#7575/xb,v(1),extract(v(wa),lookin(_1 5 _2 6 _3 6 _4 5 _5 5,v(1),1),1))] Va:$rcheck *:@pe %#=[Ur(#7575/xa,lookin(Preflight _1 Strafe _2,v(0),1))] Cobra says "me too ... it's easy to change .." You say "Do an 'rcheck preflight'" RS(#7575pDvI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: None(#-1) Type: Thing Flags: puppet dark visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Xb:DoTOT: Esr is [v(2)]%%r%%r[.......] Xa:DoESR: [Ur(#7575/xb,v(1),extract(v(wa),lookin(_1 5 _2 6 _3 6 _4 5 _5 5,v(1),1),1))] Wa:A B C D Norm-ESR Max-ESR Destress-ESR H I J K L M N Va:$rcheck *:@pe %#=%%rFor your selected allocation: %0%%r%%r[Ur(#7575/xa,lookin(Preflight _1 Strafe _2,v(0),1))] It:#11625 Home: Ready Room Location: Ready Room Cobra says "now to ea .." Mark_Farrell nods. We need to expand up xb a little bit first. Cobra nods. Mark_Farrell has jury rigged wa with some numbers. You say "What we need to supply as total available power is: ESR*FACTOR+OFFSET + 0 or batts max rate" You say "Yes?" Cobra says "(esr/100)*esr100output+battery" Mark_Farrell nods. Yeah - sorry. Getting a little muddled between power factors and warp stuff. Cobra says "i'm an engineer so :-)" Mark_Farrell nods. "I'm meant to be, but it's been an age since I worried about it, and it's getting late over here :) Mark_Farrell fixes xb to reflect the power from the engine. You say "Now, the power from the batts varies depending on allocation." Cobra is a swede :-) Mark_Farrell is a Brit :-) Cobra nods. Cobra says "you have one hour on me .." Mark_Farrell nods. Mark_Farrell has also been at work since 8 am this morning :-) You say "Take a look at xb...." Cobra says "i'm still at school .." Mark_Farrell nods. "We are mad/devoted/loony/sick/adicted/....." Cobra smiles and nods. Cobra says "v(1) is still _1" Mark_Farrell nods. Cobra says "v(2) ?" You say "Ah - v(2) is the ESR that we passed from xa." You say "xa has Ur(xb,v(1),), so xb sees v(1) as the v(1) that xa sees - ie the result of the lookin() we did in va. xb sees v(2) as the result of the code to calc ers." Cobra says "extract(v(wa),4,1) gives a D dosen't it ?" You say "When you start to use U(), you need to think in terms of sets of v(0) to v(9), and not just static values." You say "Yup." Mark_Farrell will put something sensible in there.... Cobra says "well i haven't worket with variables here before ,," Mark_Farrell doesn't know how sensible 1300 is, but as the object is visible, I don't want real numbers in there anyway. Cobra says "i have to set Ceds un vis i think .." Mark_Farrell nods. "Sure thing. It's just a case of getting used to them." Mark_Farrell nods. Cobra says "whats the ifelse ?" Cobra says "battery" You say "Okay - the ifelse is to either add 0 or the battery to the power." You say "You got it." Cobra smiles You say "Do another 'rcheck preflight'" Va:$rcheck *:@pe %#=%%rFor your selected allocation: %0%%r%%r[Ur(#7575/xa,lookin(Preflight _1 Strafe _2,v(0),1))] "For your selected allocation: preflight Esr is 95 Total Power available is 1235. ..........". You say "And an 'rcheck strafe'" "For your selected allocation: strafe Esr is 110 Total Power available is 1535. ..........". Cobra smiles. You say "So, we now know that the total power function is working okay. You are happy about modifying the lookin()'s to do what you want?" You say "Next we come to actually divvying up the energy for the 'ea'" Cobra says "if i did the helm value as the total is done now let the total be and did a battery after .." Mark_Farrell nods. Cobra says "ei v(2) == helm , v(3) == total and v(4) == battery then i could do ea v(2) v(3)-v(2)-v(4) v(4) then ?" Mark_Farrell nods. Xc:DoHNB:Alloc,TPow: Total Power available is %2.%r%r[.......... Cobra smiles. Cobra says "and then i do v(5) to shields and im set .." You say "The [........ is xc becomes something like Ur(#7575/xd,v(1),v(2),,,) then in xd, v(1) is the alloc, v(2) the total power, v(3) power to helm, v(4) power to nav, and v(5) would be power to batts - but power to batts can be calculated from v(2)-v(3)-v(4), so it doesn't have to be passed." Mark_Farrell nods. Mark_Farrell leaves that upto you. You say "I'm going to stop talking about this now, and let you work on it some :-). I'll leave #7575 visible for you to look at if you need to." Cobra says "i got the code you can do what you whant with it :-)" Mark_Farrell nods. You say "I hope that was useful for you, Cobra. I'll probably turn that into Lecture/Discussion number 9 for my coding series - so long as you don't mind. I won't show the specs or your code." Cobra says "i don't mind if someone can learn something .. the more the merrier :-)" You say "So, basically edited highlights of how to use nexted U() to save on work." Cobra nods. Cobra says "what do you think about the other stuff on it .. ?" Mark_Farrell didn't look :-) Mark_Farrell lags badly anyway, and exing a big object is a sure fire way to get booted. Cobra says "well take a look at the help texts and if you want to ex something just tell me" *********** Cobra Engineering Diagnostic System. *********** A little laptop that helps in the search for the allocations for a ship. View Present Settings - type See Asettings CEDS Setup Helm - type Asetup1 CEDS Setup Nav/Eng - type Asetup2 View Standard Allocations - type See Allocs There is also room to configure a custom allocation through the use of the Open Command - type Asetup3 If you have any comments, you miss a setting or an alloc just type 'Enter, '. For more commands type View Next You say "One thing though - you may not be aware that ifelse() actually does _both_ the 'if' bit, and the 'else' bit." You say "So, the huge nested ifelse() you have doesn't actually save any work, and the whole bally lot is evaluated." You say "The trick (there's nearly always a trick) is to use:" Saving TrekMUSE DataBase. Response will be slow for a few minutes. Cobra says "as bad as a "sw then .." You say "Nested ifelse's are a nightmare to debug and change though." *Mark_Farrell* s(ifelse(condition,{[true]},{[false]})) Cobra says "and s() makes it take the right one ?" Cobra says "ei do half the work ?" You say "The ifelse basically returns [true], or [false], so you then have s(option)" You say "Its the {}'s that really make this trick work well." You say "That's right, Cobra." You say "Or in the case of your nested ifelse's a mere fraction of the work." You say "nested...nested...nested. That's the second time I've typed nexted this evening." Cobra says "only the true/false that are used" You say "Well, true/false are the things you'd normally put in a plain ifelse - so, for instance:" *Mark_Farrell* @pe %#=[s(ifelse(gte(rank(me,9)),{[ifelse(eq(rank(me),17),{Oh my, a director now.},{Hi there, brassy.})]},{Hey - you lowlife})] You say "The second ifelse if only evaluated if the rank(me) is 9 or above." Mark_Farrell got the brackets a little wrong, but you get the idea. Cobra nods. *Mark_Farrell* [s(ifelse(cond,{..A..},{..B..}))] -> s(..A..) or s(..B..) Cobra smiles. *Mark_Farrell* [ifelse(cond,..A..,..B..)] -> ifelse(cond,result-of-A,result-of-B) -> result-A-or-B Cobra says "and if A was an ifelse then only the A or B in that one would be done ?" *Mark_Farrell* [s(ifelse(cond,{..A..},{..B..}))] -> s(..A..) or s(..B..) -> result-A or Result-B You say "..A.. could be an [s(ifelse(.......))]" Cobra nods. You say "Things get very messy though." Fed_Merchants says "ConsoleAccess:Zone,Obj: [s(ifelse(Ur(#518/wa,v(2),get(#16490/vd)),0,{[s(ifelse(Ur(#518/wa,v(2),s([get(#16490/ve)] [get(#16490/vf)])),1,{[s(ifelse(Ur(#518/wa,v(2),get(v(1),xx)),0,{[Ur(#518/wa,v(2),s([get(v(1),xy)] [get(v(1),xz)]))]}))]}))]}))]" Cobra says "ok you need a S() around every ifelse() .." Fed_Merchants nods. Fed_Merchants says "And the {}'s" Cobra nods. Fed_Merchants says "Not forgetting the []'s" Cobra says "don't bother :-)"