function Tipbox(tips) {
    this.tipCount = parseInt(tips);
    this.getRow = function(n) {
        return (n-1) % 8 + 1;
    }
    this.getColumn = function(n) {
        return ((n-1) - (n-1) % 8) / 8 + 1;
    }
    this.hasTip = function() {
        return this.tipCount > 0;
    }
    this.isEmpty = function() {
        return this.tipCount < 1;
    }
    // Methods takeTip and putTip returns the next position and increments if
    // "successful":
    this.takeTip = function() {
        var tip = new Array(2);
        // Find the "last" tip:
        tip[0] = this.getRow(this.tipCount);
        tip[1] = this.getColumn(this.tipCount);
        if(tip[0] > 0 && tip[1] > 0) {
            this.tipCount--;
        } else {
            tip = undefined;
        }
        return tip;
    }
    this.putTip = function() {
        var temp = this.tipCount + 1;
        var tip = new Array(2);
        // Find the "last" empty position:
        tip[0] = this.getRow(temp);
        tip[1] = this.getColumn(temp);
        if(tip[1] < 13 && tip[0] > 0 && tip[1] > 0) {
            this.tipCount++;
        } else {
            tip = undefined;
        }
        return tip;
    }
    // The following methods allow retrieval of coords without incrementation:
    this.getNextTipPosition =  function() {
        var tip = new Array(2);
        // Find the "last" tip:
        tip[0] = this.getRow(this.tipCount);
        tip[1] = this.getColumn(this.tipCount);
        if(tip[0] < 1 || tip[1] < 1) {
            tip = undefined;
        }
        return tip;
    }
    this.getNextEmptyPosition = function() {
        var temp = this.tipCount + 1;
        var tip = new Array(2);
        // Find the "last" empty position:
        tip[0] = this.getRow(temp);
        tip[1] = this.getColumn(temp);
        if(tip[1] > 12 || tip[0] < 1 || tip[1] < 1) {
            tip = undefined;
        }
        return tip;
    }
    this.increment = function() {
        this.tipCount++;
    }
    this.decrement = function() {
        this.tipCount--;
    }
}
/*
Tip box class to handle single-tip processes filling tips columns-wise
from up/left to down/right, i.e. A1, B1...H1, A2...
*/
Tip box class to handle single-tip processes filling tips columns-wise
from up/left to down/right, i.e.
Tip box class to handle single - tip processes filling tips columns - wise from up / left to down / right i . e .
function Tipbox(tips) {
    this.tipCount = parseInt(tips);
    this.getRow = function(n) {
        return (n-1) % 8 + 1;
    }
    this.getColumn = function(n) {
        return ((n-1) - (n-1) % 8) / 8 + 1;
    }
    this.hasTip = function() {
        return this.tipCount > 0;
    }
    this.isEmpty = function() {
        return this.tipCount < 1;
    }
    this.takeTip = function() {
        var tip = new Array(2);
        tip[0] = this.getRow(this.tipCount);
        tip[1] = this.getColumn(this.tipCount);
        if(tip[0] > 0 && tip[1] > 0) {
            this.tipCount--;
        } else {
            tip = undefined;
        }
        return tip;
    }
    this.putTip = function() {
        var temp = this.tipCount + 1;
        var tip = new Array(2);
        tip[0] = this.getRow(temp);
        tip[1] = this.getColumn(temp);
        if(tip[1] < 13 && tip[0] > 0 && tip[1] > 0) {
            this.tipCount++;
        } else {
            tip = undefined;
        }
        return tip;
    }
    this.getNextTipPosition =  function() {
        var tip = new Array(2);
        tip[0] = this.getRow(this.tipCount);
        tip[1] = this.getColumn(this.tipCount);
        if(tip[0] < 1 || tip[1] < 1) {
            tip = undefined;
        }
        return tip;
    }
    this.getNextEmptyPosition = function() {
        var temp = this.tipCount + 1;
        var tip = new Array(2);
        tip[0] = this.getRow(temp);
        tip[1] = this.getColumn(temp);
        if(tip[1] > 12 || tip[0] < 1 || tip[1] < 1) {
            tip = undefined;
        }
        return tip;
    }
    this.increment = function() {
        this.tipCount++;
    }
    this.decrement = function() {
        this.tipCount--;
    }
}
function Tipbox ( tips ) { this . tipCount = parseInt ( tips ) ; this . getRow = function ( n ) { return ( n - 1 ) % 8 + 1 ; } this . getColumn = function ( n ) { return ( ( n - 1 ) - ( n - 1 ) % 8 ) / 8 + 1 ; } this . hasTip = function ( ) { return this . tipCount > 0 ; } this . isEmpty = function ( ) { return this . tipCount < 1 ; } this . takeTip = function ( ) { var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( this . tipCount ) ; tip [ 1 ] = this . getColumn ( this . tipCount ) ; if ( tip [ 0 ] > 0 && tip [ 1 ] > 0 ) { this . tipCount -- ; } else { tip = undefined ; } return tip ; } this . putTip = function ( ) { var temp = this . tipCount + 1 ; var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( temp ) ; tip [ 1 ] = this . getColumn ( temp ) ; if ( tip [ 1 ] < 13 && tip [ 0 ] > 0 && tip [ 1 ] > 0 ) { this . tipCount ++ ; } else { tip = undefined ; } return tip ; } this . getNextTipPosition = function ( ) { var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( this . tipCount ) ; tip [ 1 ] = this . getColumn ( this . tipCount ) ; if ( tip [ 0 ] < 1 || tip [ 1 ] < 1 ) { tip = undefined ; } return tip ; } this . getNextEmptyPosition = function ( ) { var temp = this . tipCount + 1 ; var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( temp ) ; tip [ 1 ] = this . getColumn ( temp ) ; if ( tip [ 1 ] > 12 || tip [ 0 ] < 1 || tip [ 1 ] < 1 ) { tip = undefined ; } return tip ; } this . increment = function ( ) { this . tipCount ++ ; } this . decrement = function ( ) { this . tipCount -- ; } }
Tip box class to handle single-tip processes filling tips columns-wise
from up/left to down/right, i.e.
Tip box class to handle single - tip processes filling tips columns - wise from up / left to down / right i . e .
// Methods takeTip and putTip returns the next position and increments if // "successful": // Find the "last" tip: // Find the "last" empty position: // The following methods allow retrieval of coords without incrementation: // Find the "last" tip: // Find the "last" empty position: