/**

____ _ __ ____ _

/ __ \____ ____ ____ _________ (_)___ / |/ (_)___ (_)___ ____ _

/ / / / __ \/ __ `/ _ \/ ___/ __ \/ / __ \ / /|_/ / / __ \/ / __ \/ __ `/

/ /_/ / /_/ / /_/ / __/ /__/ /_/ / / / / / / / / / / / / / / / / / /_/ /

/_____/\____/\__, /\___/\___/\____/_/_/ /_/ /_/ /_/_/_/ /_/_/_/ /_/\__, /

______ /____/ __ __ /____/

/ ____/___ _/ /______ __/ /___ _/ /_____ _____

/ / / __ `/ / ___/ / / / / __ `/ __/ __ \/ ___/

/ /___/ /_/ / / /__/ /_/ / / /_/ / /_/ /_/ / /

\____/\__,_/_/\___/\__,_/_/\__,_/\__/\____/_/

Returns a chart of 30 * "daysInc" rows containing the estimated difficulties, startBalance, value

of a doge miner

Provides better functionality than a standard mining calculator, because it includes compounding

difficulty and exchange rates, as well as working as an investment calculator.

Originally created by /u/hyperbolicparaboloid

Released under the MIT license

Donations : DRsCmdGJ99wfVjEUsK9XT26K6TidQtdB5u

**/

function miningCalculator ( diff , diffInc , startBalance , hashRate , excRate , excRateInc , daysInc , blockReward )

{

// diffInc and excRateInc should be interger % values

// daysInc should be an interger value of days

var now = new Date ( ) ;

var dummyTime = new Date ( ) ;

// Fill an array with incremented dates

var resultChart = new Array ( ) ;

for ( var i = 0 ; i < 30 ; i ++ )

{

resultChart [ i ] = new Array ( ) ;

resultChart [ i ] [ 0 ] = dummyTime. toDateString ( ) ;

dummyTime. setDate ( dummyTime. getDate ( ) + daysInc ) ;

}

// Fill an array with compounding difficulties

// Obviously this is an interesting behaviour to assume

for ( var i = 0 ; i < 30 ; i ++ )

{

if ( i != 0 )

{

var newDiff = ( 1 + Number ( diffInc ) / 100 ) * Number ( resultChart [ i - 1 ] [ 1 ] ) ;

resultChart [ i ] [ 1 ] = newDiff ;

}

else

{

resultChart [ i ] [ 1 ] = diff. toString ( ) ;

}

}

// Fill an array with estimated doge startBalance per day

for ( var i = 0 ; i < 30 ; i ++ )

{

// The magic formula:

var dogePerDay = 503 * blockReward * hashRate / resultChart [ i ] [ 1 ] / 25000 ;

if ( i != 0 )

{

resultChart [ i ] [ 2 ] = ( Number ( resultChart [ i - 1 ] [ 2 ] ) + daysInc * dogePerDay ) ;

}

else

{

resultChart [ i ] [ 2 ] = startBalance ;

}

}

// Fill an array with the estimated exchange rate per day

for ( var i = 0 ; i < 30 ; i ++ )

{

if ( i != 0 )

{

resultChart [ i ] [ 3 ] = ( 1 + Number ( excRateInc ) / 100.0 ) * Number ( resultChart [ i - 1 ] [ 3 ] ) ;

}

else

{

resultChart [ i ] [ 3 ] = excRate ;

}

}

// Fill an array with the estimated value each day

for ( var i = 0 ; i < 30 ; i ++ )

{

if ( i != 0 )

{

resultChart [ i ] [ 4 ] = Number ( resultChart [ i ] [ 3 ] ) * Number ( resultChart [ i ] [ 2 ] ) ;

}

else

{

resultChart [ i ] [ 4 ] = Number ( startBalance ) * Number ( excRate ) ;

}

}

return resultChart ;