79646962

Date: 2025-05-31 20:23:41
Score: 1
Natty:
Report link

Thank you again, @Solt, for your assistance in directing me to other techniques.

Here is the logic sequence that did finally work for me:

function firePattern_onTargRand( col, row ){
    var firePattern = 'Random About Target' ;
    var target = [] ;
    var targets = [] ;
    var munitionsCost = 10 ;
    var alreadyTargeted = false ;
    var enumerateTargets = "" ;

    for( i=1 ; i <= munitionsCost ; i++ ){
        do {
            target = [ 
                col + getRandomInteger( 0, 6 ) -3 ,
                row + getRandomInteger( 0, 6 ) -3
            ] ;
            alreadyTargetted = false ;
            for( let j = 0 ; j < targets.length ; j++ ){
                if(
                    targets[j][0] === target[0] &&
                    targets[j][1] === target[1]
                ) {
                    alreadyTargetted = true ;
                    console.log( "duplicate flagged at " + `${j}` + " vs " + `${i}` ) ;
                } ;
            } ; 
        } while( alreadyTargetted === true ) ;

        targets.push( target ) ;
        enumerateTargets = enumerateTargets + "\n[" + target + "]" ;
        } ;

    console.log( "Targetting Pattern:  " + `${firePattern}` + "\nGrid Coordinates:  [" + ` ${col} , ${row} ` + "]\nSalvo Coordinates:\n" + enumerateTargets ) ;
    return targets ;
} ;

And this is the console log generated:

console log of generated messages

One observation I can't avoid making is that there seems to be a high occurrence of duplicates being encountered from what is supposed to be a random generator function!!! Encountering one every now and then, I can understand. But as many as have been observed in a single run of only 10 (20) calls seems to be hard to accept! Is that indicative of an issue with the JavaScript built-in function? But that is for another discussion altogether. :-)

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @Solt
  • Self-answer (0.5):
Posted by: Eric Marceau