FRDB Archives

Freethought & Rationalism Archive

The archives are read only.


Go Back   FRDB Archives > Archives > IIDB ARCHIVE: 200X-2003, PD 2007 > IIDB Philosophical Forums (PRIOR TO JUN-2003)
Welcome, Peter Kirby.
You last visited: Today at 05:55 AM

 
 
Thread Tools Search this Thread
Old 07-14-2003, 08:18 AM   #111
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default after teh concession

DNAunion, seeing that I have conceded the point, I can now speak a little more cleverly.

Let us describe the images by I1..In and for the code you saw n=2. Let us now dscribe the dancing moves by a..n, and for the code you saw only a existed.

The logical relationship is as follows
I1 is related to a or symbolically I1Ra.
I2 is relatd to a or symbolically I2Ra.
If there were 6 images where
(I1,I2,I3)Ra and (I4,I5,I6)Rb, then the variable which represents a complete animation sequence, TOTALdancingIMAGES would be 3, and the IMAGESmax would be 6.

It so happens in this case, the case you have seen, the animation sequence of two images is equal to the total images which is 2.

As I said I concede the point as shown by the code. The future use of the code is simply geared to perform.
sophie is offline  
Old 07-14-2003, 10:45 AM   #112
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: after teh concession

DNAunion: Well, I guess it's my turn now :-)

While I do think you overstated the difficulties involved in combining the two arrays into one, I must admit that I understated it (guess that's human nature in a debate). Here's how I see it.

It's kind of like factoring in math. Each of the pairs of statements needed to add a new image (in the combined array scenario) contains the same "factor", the someArray[x] = new image(); statement (how about N for "New"). The more images there are, the greater the statement redundancy and the greater the "need" to factor out the common element.

N(A) + N(B) + N(C) + N(D) + N(E) + ... N(ZZ)

is better written as:

N(A + B + C+ D + E + ... ZZ)

In the first sequence, the common factor N appears once for each term (each image): in the second, it appears only once.

The difference is that while in math there are never too few terms to factor out what they have in common (2 terms works just fine), in the program, factoring out the common element too soon leads to slightly decreased clarity and slightly increased memory and CPU usage.

With just 2 images, the program would be better with the two arrays combined into one. With 1,000 images, it's better with the two separate arrays. And at some point in between those two there is a sort of break even point (I am not sure exactly where that point would be, but I would guess it would be hit before reaching 25).

So I concede this point to you. I looked at the code as it existed: static, with just 2 images. You coded it according to how you expected it to develop: dynamic, with much more than 2 images. If you planned to add even one or two dozen images the method that uses the extra array is the better solution. So there is no fault in your "array code" and it is actually preferable.
DNAunion is offline  
Old 07-14-2003, 11:30 AM   #113
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default if you were boss

DNAunion , but if you were paying the bill, and vehemently decided you wanted only one array, here is what i would have had to do :

Code:
for (var eye = 0; eye < IMAGESmax; eye++)
{
    var TEMPimageNAME = DANCINGimages[eye] ;
    DANCINGimages[eye] = new Image() ;
    DANCINGimages[eye].src = TEMPimageNAME ;
}
and make the appropriate name changers further in the coding for the image array reference.

On another note, the algorithm is incomplete, because each dance sequence may not possibly have a uniform number of steps. I intend to convey, from the n images, the animation sequences may span 2 images, 3 images, 5 images, 1 image, 2 images, such that : 2+3+5+1+2 = n. This necessitates another array, say ANIMATIONsequenceJ, from which TOTALdancingIMAGES should be compared in order to animate the sequence at the rate for the number of repetitons.

With this I can achieve say the following moves on a new animation sequence.
Assume normal ATeasePOSITION.
A : right hand up, right hand out, right hand ATeasePOSITION.
B : left foot up, left foot ATeasePOSITION.
C : move ass to the left, move ass to the right, ass ATeasePOSITION.
D : bend, ATeasePOSITION.

Now I can shake at different rates for different number of repetitions. DANCINGspeed and REPEATdanceMOVE have an onto relationship, where DANCINGspeed represents the rate at which I may shake that ass, and REPEATdanceMOVE tells the model how many times the shaking should occur.

ALL this is not evident from the code, that is why at times heavy documentation and for the more advanced stuff, even a programming manual is necessary. I made that mistake once in life, I wrote a 4gl to perform voice-telephony applications with embedded database as a prototype for a big company in Canada, but the power of the app was lost without the full programming guide.

I swore I'd never make the same mistake again. YEP, but I did, I now write applications where I insist the users learn by intuition. (what a nut).
sophie is offline  
Old 07-15-2003, 05:36 AM   #114
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: if you were boss

Quote:
sophie: DNAunion , but if you were paying the bill, and vehemently decided you wanted only one array, here is what i would have had to do :

Code:
for (var eye = 0; eye < IMAGESmax; eye++)
{
    var TEMPimageNAME = DANCINGimages[eye] ;
    DANCINGimages[eye] = new Image() ;
    DANCINGimages[eye].src = TEMPimageNAME ;
}
and make the appropriate name changers further in the coding for the image array reference.
DNAUunion: I disagree, and need to retract my concession. I don't have time right now to explain (I'm getting ready for work), but I should find time later today.
DNAunion is offline  
Old 07-15-2003, 05:47 AM   #115
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: Re: if you were boss

DNAunion: Well, I whipped this up in a hurry before leaving for work.

Taking your code as it exists, my inquired about combining of two arrays into one was the better solution. Looking at it some more, my inquired about combining of two arrays into one appears to be the better solution no matter how many images this scales up to.

Here’s the original code (with comments added and irrelevant statements omitted).

Code:
// Create first array to hold image names
var DANCINGimages = new Array() ;

// Manually add each image name to array
DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;
DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
DANCINGimages[2] = 'http://www.notrich.org/ANIMATION/PLAN3.jpg' ;
DANCINGimages[3] = 'http://www.notrich.org/ANIMATION/PLAN4.jpg' ;
...
DANCINGimages[999] = 'http://www.notrich.org/ANIMATION/PLAN999.jpg' ;

// Obtain number of image names for upcoming loop
var IMAGESmax = DANCINGimages.length ;

// Create second array to hold preloaded images
var IMAGESpreLoad = new Array() ;

// Create blank images
// Assign image names from first array to this array’s elements
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
    IMAGESpreLoad[eye].src = DANCINGimages[eye] ;
}

DNAunion: Here’s how it could be recoded (unless there’s some “JavaScript peculiarity” that prevents this from working).

Code:
// Create array to hold preloaded images
var IMAGESpreLoad = new Array() ;

// Set number of images for upcoming loop
var IMAGESmax = 1000;

// Create blank images
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
}

// Manually add each image name to array
DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;
DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
DANCINGimages[2] = 'http://www.notrich.org/ANIMATION/PLAN3.jpg' ;
DANCINGimages[3] = 'http://www.notrich.org/ANIMATION/PLAN4.jpg' ;
...
DANCINGimages[999] = 'http://www.notrich.org/ANIMATION/PLAN999.jpg' ;

DNAUnion: The two-array method:

(1) has an extra, unneeded array
(2) actually has more lines of code
(3) suffers from decreased clarity due to splitting of logic
(4) executes slightly slower due to having to handle each image name/reference twice
(5) uses more memory due to having to store each image names/references twice

Gotta run.
DNAunion is offline  
Old 07-15-2003, 06:09 AM   #116
Veteran Member
 
Join Date: Mar 2002
Location: anywhere
Posts: 1,976
Default

Code:
// Create array to hold preloaded images
var IMAGESpreLoad = new Array() ;

// Set number of images for upcoming loop
var IMAGESmax = 1000;

// Create blank images
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
}

// Manually add each image name to array
DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;
DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
DANCINGimages[2] = 'http://www.notrich.org/ANIMATION/PLAN3.jpg' ;
DANCINGimages[3] = 'http://www.notrich.org/ANIMATION/PLAN4.jpg' ;
...
DANCINGimages[999] = 'http://www.notrich.org/ANIMATION/PLAN999.jpg' ;
Nope, this code definitely won't work. And it's easy to see why by inspection. There are two reasons. Can DNAunion find them?
Principia is offline  
Old 07-15-2003, 06:14 AM   #117
Veteran Member
 
Join Date: Mar 2002
Location: anywhere
Posts: 1,976
Default

Oh wait, I guess DNAunion put up his standard disclaimer that he was in a rush and put up sloppy code, and so we ought to therefore excuse his mistakes. So let's spare him, shall we?

1) DANCINGimages was never declared in his "fix" -- it should have been IMAGESpreLoad[eye].src -- But oh wait, for a novice programmer like DNAunion who still cuts and pastes code without thinking about the side effects, I guess tis forgiveable offense...

2) Manually, the items were added from indices 0 to 999. But Plan ranges from 1 to 999. Gee, DNAunion, where did you learn to count? But, oh wait, a novice programmer like DNAunion still having 0-1 index problems, who would have thought...

EDIT: So here's more hypocrisy:
Quote:
DNAunion:

(1) has an extra, unneeded array
(2) actually has more lines of code
(3) suffers from decreased clarity due to splitting of logic
(4) executes slightly slower due to having to handle each image name/reference twice
(5) uses more memory due to having to store each image names/references twice
Yet, when I pointed out similar mistakes to DNAunion, above:
Quote:
DNAUnion's code:
Code:
	// Pull a single tile out of the urn
	nFoundOne = 0;
	while (nFoundOne == 0)
	{
		nIndex = (int) GetRandomNumber(0, nLetteredTiles - 1);
		if (nDiscardTilesOnceChosen == 0)
		{
			// Doesn't matter if the tile has been 
			// chosen previously because selected
			// tiles are placed back into the urn.
			nFoundOne = 1;
		}
		else if (cUrn[nIndex][2] == 'T')
		{
			// This tile has already been chosen and
			// discarded: it can't be selected again.
			nFoundOne = 0;
		}
		else if (cUrn[nIndex][2] == 'F')
		{
			// This tile has not been chosen previously.
			nFoundOne = 1;
		}
	}
Let me point out that here, the test (nDiscardTilesOnceChosen == 0) is always satisfied, so the then block is never reached. Let me also point out that the 1st elseif is irrelevant, since its action to set nFoundOne to 0 is redundant (i.e. nFoundOne would have to be 0 to get there anyways).
here's what DNAunion had to say:
Quote:
As far as compactness:

1) It’s a only 14 characters and took me only about 2 seconds to type (and as the programmer, I get to decide whether to sacrifice clarity to save 2 seconds worth of typing)

2) The code does not become “fatware” simply because I added something like 14 bytes to it

3) The time it takes an average computer to execute that one command is negligible; even running 1,000,000 iterations it would probably add only a small fraction of a second to the total execution time.
1) So negligible runtime is an excuse for DNAunion, but not for sophie.

2) Extra code is a forgiveable offense for DNAunion, but not for sophie.

3) Extra typing is OK when DNAunion does it, but not for sophie.

See the pattern?
Principia is offline  
Old 07-15-2003, 06:17 AM   #118
Veteran Member
 
Join Date: Mar 2002
Location: anywhere
Posts: 1,976
Default

Quote:
Originally posted by Tom Ames
I'd just like to know what DNAUnion thinks he's accomplishing here. If he's posting here in order to learn something, then he's not listening to the responses. If he's trying to demonstrate that he's a competent programmer, he's failing at that too.

JMO.
I completely agree. If you're reading this, sophie, you've engaged yourself in an exercise in futility. Do Not Feed The Troll (DNAunion). There is a long history behind this guy and his baiting techniques, and if you're at all interested, you can request a PM from me.

Sophie, there's absolutely no doubt in anybody's view who the better programmer here is, and it's certainly not DNAunion. I mean, come on, you're dueling with a programmer that generates random numbers by iterating through and throwing away samples???
Code:
long GetRandomNumber(int nMin, int nMax)
{
	long lRandomNumber;

	lRandomNumber = rand();
	while (lRandomNumber < nMin || lRandomNumber > nMax)
	{
		lRandomNumber = rand();
	}
	return lRandomNumber;
}
My advice is to drop the matter and let this thread die. You're simply giving it une raison d'etre.

EDIT: Pardon my French!
Principia is offline  
Old 07-15-2003, 10:06 AM   #119
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: Re: Re: if you were boss

DNAunion: As soon as I left I realized I simply copied and pasted the statements from one to the other, which led to me using a non-existent array name in the single-array code and not adding the .src part. Here's an updated version.


***************************************


DNAunion: Well, I whipped this up in a hurry before leaving for work.

Taking your code as it exists, my inquired about combining of two arrays into one was the better solution. Looking at it some more, my inquired about combining of two arrays into one appears to be the better solution no matter how many images this scales up to.

Here’s the original code (with comments added and irrelevant statements omitted).



Code:
// Create first array to hold image names
var DANCINGimages = new Array() ;

// Manually add each image name to array
DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;
DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
DANCINGimages[2] = 'http://www.notrich.org/ANIMATION/PLAN3.jpg' ;
DANCINGimages[3] = 'http://www.notrich.org/ANIMATION/PLAN4.jpg' ;
...
DANCINGimages[999] = 'http://www.notrich.org/ANIMATION/PLAN999.jpg' ;

// Obtain number of image names for upcoming loop
var IMAGESmax = DANCINGimages.length ;

// Create second array to hold preloaded images
var IMAGESpreLoad = new Array() ;

// Create blank images
// Assign image names from first array to this array’s elements
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
    IMAGESpreLoad[eye].src = DANCINGimages[eye] ;
}

DNAunion: Here’s how it could be recoded (unless there’s some “JavaScript peculiarity” that prevents this from working).


Code:
// Create array to hold preloaded images
var IMAGESpreLoad = new Array() ;

// Set number of images for upcoming loop
var IMAGESmax = 1000;

// Create blank images
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
}

// Manually add each image name to array
IMAGESpreLoad[0].src = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;
IMAGESpreLoad[1].src = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
IMAGESpreLoad[2].src = 'http://www.notrich.org/ANIMATION/PLAN3.jpg' ;
IMAGESpreLoad[3].src = 'http://www.notrich.org/ANIMATION/PLAN4.jpg' ;
...
IMAGESpreLoad[999].src = 'http://www.notrich.org/ANIMATION/PLAN999.jpg' ;

DNAUnion: The two-array method:

(1) has an extra, unneeded array
(2) actually has more lines of code
(3) suffers from decreased clarity due to splitting of logic
(4) executes slightly slower due to having to handle each image name/reference twice
(5) uses more memory due to having to store each image names/references twice

Gotta run.


**********************************
DNAunion: Came back to add...

After posting, I noticed that whatever programmer Principia has helping him understand code also noticed my oversights. No biggie, I expicilty stated or otherwise noted three times - once before that post, and twice in that post itself - that I quickly threw it together because I had to leave for work and didn't have much time. In fact, in the post before the one of interest, I actually stated that I didn't even have enough time to reply...but I did so anyone, very quickly throwing something together.


*********************************
DNAunion: Came back to add one more thing. Note that I've edited my post 4 hours in the future!!! That is, the posted time shows 2:17 pm, and I edited the post only a few minutes later, but the "last edited by" shows after 6:48 pm. I didn't know I could time travel 4 and a half hours into the future!

I guess they use two different "clocks" here.
DNAunion is offline  
Old 07-15-2003, 06:45 PM   #120
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: Re: Re: Re: if you were boss

Quote:
Principia: 2) Manually, the items were added from indices 0 to 999. But Plan ranges from 1 to 999. Gee, DNAunion, where did you learn to count?
DNAunion: Uhm, from the code Sophie posted that I referenced. Here is part of her actual code. Note that the arrays are 0-based.


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>GREETINGs by Sophie </title>
<link type="text/css" rel="stylesheet" href="http://www.notrich.org/GREETING/greeting.css">


<script language="JavaScript1.2">

var DANCINGimages = new Array() ;
DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;

var RETURNcode ;
var IMAGESindex = 0 ;
var IMAGESmax = DANCINGimages.length ;

var IMAGESpreLoad = new Array() ;
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
    IMAGESpreLoad[eye].src = DANCINGimages[eye] ;
}

var DANCINGspeed = new Array() ;
DANCINGspeed[0] = 300 ; DANCINGspeed[1] = 240 ; DANCINGspeed[2] = 180 ;
DANCINGspeed[3] = 140 ; DANCINGspeed[4] = 50 ; DANCINGspeed[5] = 130 ;
DANCINGspeed[6] = 183 ; DANCINGspeed[7] = 130 ; DANCINGspeed[8] = 50 ;
DANCINGspeed[9] = 321 ; DANCINGspeed[10] = 440 ; DANCINGspeed[11] = 500 ;

var REPEATdanceMOVE = new Array() ;
REPEATdanceMOVE[0] = 6 ; REPEATdanceMOVE[1] = 3 ; REPEATdanceMOVE[2] = 5 ;
REPEATdanceMOVE[3] = 1 ; REPEATdanceMOVE[4] = 8 ; REPEATdanceMOVE[5] = 2 ;
REPEATdanceMOVE[6] = 7 ; REPEATdanceMOVE[7] = 2 ; REPEATdanceMOVE[8] = 11 ;
REPEATdanceMOVE[9] = 2 ; REPEATdanceMOVE[10] = 4 ; REPEATdanceMOVE[11] = 4 ;
DNAunion: Another of Principia’s “gotcha's” crushed.
DNAunion is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -8. The time now is 07:54 PM.

Top

This custom BB emulates vBulletin® Version 3.8.2
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.