Browse Source

Board with GameMachine Random Normal Distribution on numbers + NPC playing after you

Nikatlas 6 years ago
parent
commit
92ec451c28

+ 3 - 3
src/Game/game/index.js

@@ -3,7 +3,7 @@ const GameMoves = require('./machine/GameMoves');
 const Card = require('./machine/Card');
 
 module.exports = {
-	Card,
-	GameMachine,
-	GameMoves
+    Card,
+    GameMachine,
+    GameMoves
 }

+ 15 - 12
src/Game/game/machine/Card.js

@@ -1,17 +1,20 @@
-class Card {
-	constructor() {
-		this.attack = [0,0,0,0];
-		this.portrait = "";
-		this.owner = "";
-	}
+// import fckn generator to check different Distributions
+var dg = require('../../../helpers/deckGenerator').createRandomDeck;
+
+let deck = dg();
 
-	setAttack(attack) {
-		this.attack = attack;
-	}
+class Card {
+    constructor(id = 0) {
+        this.attack = deck[id];
+    }
 
-	setOwner(owner) {
-		this.owner = owner;
-	}
+    setAttack(attack) {
+        this.attack = attack;
+    }
 
+    setOwner(owner) {
+        this.owner = owner;
+    }
 }
+
 module.exports = Card;

+ 36 - 38
src/Game/game/machine/GameMachine.js

@@ -1,4 +1,4 @@
-var Card = require('./Card.js');
+// var Card = require('./Card.js');
 
 class GameMachine {
     constructor() {
@@ -25,6 +25,9 @@ class GameMachine {
     runMove(move) {
         move.performMove(this.state.board);
     }
+    ownerOf(x) {
+        return this.state.board.owners[x];
+    }
 }
 
 class Board {
@@ -38,9 +41,9 @@ class Board {
         for (var i=0; i < 9; i += 1) {
             this.triggerPaths[i] = [];
             this.plusPaths[i] = {
-                winner: -1,
+                winners: [],
                 sums: []
-            }
+            };
         }
     }
 
@@ -49,8 +52,8 @@ class Board {
         console.log('---------------------------');
         console.log('Cards :');
         let s = '';
-        for(var i=0,j=0;i<this.data.length;i+=1) {
-            s += this.owners[i] + ':' + this.data[i] + '\t';
+        for(let i=0,j=0;i<9;i+=1) {
+            s += `P${this.owners[i]}:${(this.data[i] ? this.data[i].attack.reduce((a,b) => a + b + "|", "|") : 'Empty')}\t`;
             j += 1;
             if(j%3===0)s += '\n';
         }
@@ -59,8 +62,8 @@ class Board {
         console.log('Triggers');
         console.log('---------------------------');
         s = '';
-        for(var i=0,j=0;i<this.triggerPaths.length;i+=1) {
-            s += '[' + this.triggerPaths[i] + ']' + '\t\t';
+        for(let i=0,j=0;i<9;i+=1) {
+            s += `[${this.triggerPaths[i]}]\t\t`;
             j += 1;
             if(j%3===0)s += '\n';
         }
@@ -69,8 +72,8 @@ class Board {
         console.log('Pluspaths');
         console.log('---------------------------');
         s = '';
-        for(var i=0,j=0;i<this.plusPaths.length;i+=1) {
-            s += '[' + (this.plusPaths[i].winner) + ']' + '\t\t';
+        for(let i=0,j=0;i<9;i+=1) {
+            s += `[${(this.plusPaths[i].winners.reduce((a,b) => a + b + '|', "|"))}]\t\t`;
             j += 1;
             if(j%3===0)s += '\n';
         }
@@ -88,7 +91,7 @@ class Board {
     }
 
     _calculatePlusAndTriggers(position) {
-        const attacker      = this.data[position];
+        const attacker = this.data[position];
         for (let j = 0; j < 4; j += 1) {
             if ( Board.ATTACK_VECTORS[position][j] === 0 ) continue;
             
@@ -101,26 +104,26 @@ class Board {
                 this.plusPaths[      position  ].sums[j] = sum;
                 this.plusPaths[   position + dx].sums[defendJ] = sum;
                 this.triggerPaths[   position  ][j] =   attacker.attack[j] - attackedCard.attack[defendJ];
-                this.triggerPaths[position + dx][defendJ] =   -this .triggerPaths[position][j]; // opposite to the above
+                this.triggerPaths[position + dx][defendJ] =   -this.triggerPaths[position][j]; // opposite to the above
             }
         }
     }
 
     _getDisplacement(j) {
         switch(j) {
-            case 0: return 1;//return {x: 1, y:0};
-            case 1: return -3;//return {x: 0, y:1};
-            case 2: return -1;//return {x: -1, y:0};
-            case 3: return 3;//return {x: 0, y:-1};
-            default: throw Error("Cannot _getDisplacement of this value: " + j);
+        case 0: return 1;   //return {x: 1, y:0};
+        case 1: return -3;  //return {x: 0, y:1};
+        case 2: return -1;  //return {x: -1, y:0};
+        case 3: return 3;   //return {x: 0, y:-1};
+        default: throw Error ("Cannot _getDisplacement of this value: " + j);
         }
     }
 
     _flipCard(position, combo, owner) {
         // change owner!
-
+        let isFlipping = owner !== this.owners[position];
         this.owners[position] = owner;
-        if(combo) this._analyze(position, combo);
+        if(combo && isFlipping) this._analyze(position, combo);
     }
 
     _analyze(position, combo) {
@@ -128,21 +131,21 @@ class Board {
         if(         this._checkSameRule(position) && !combo ) {
             // Apply Same Rule
             this._applySameRule(position);
-        } else if ( this._checkPlusRule(position) && !combo ) {
+        }
+        if ( this._checkPlusRule(position) && !combo ) {
             // Apply Plus Rule
             this._applyPlusRule(position);
-        } else {
-            this._applyAttackRule(position);
-        }
+        } 
+        this._applyAttackRule(position, combo);
     }
 
-    _applyAttackRule(position) { //seems ok
+    _applyAttackRule(position, combo = false) { //seems ok
         if ( !this.triggerPaths[position] ) return;
         for (let j = 0; j < 4; j += 1) {
             if ( Board.ATTACK_VECTORS[position][j] === 0 ) continue;
             const dx = this._getDisplacement(j);
             if ( this.triggerPaths[position][j] > 0 ) {
-                this._flipCard(position + dx, false, this.owners[position]);
+                this._flipCard(position + dx, combo, this.owners[position]);
             }
         }
     }
@@ -154,21 +157,20 @@ class Board {
             if ( this.triggerPaths[position][j] === 0 ) {
                 this._flipCard(position + dx, true, this.owners[position]);
             }
-        }   
+        }
     }
 
     _applyPlusRule(position) {
         for (let j = 0; j < 4; j += 1) { // this for loop can be fixed seems obsolete & slow
             if ( Board.ATTACK_VECTORS[position][j] === 0 ) continue;
             const dx = this._getDisplacement(j);
-            if ( this.plusPaths[position].sums[j] === this.plusPaths[position].winner ) {
+            if ( this.plusPaths[position].winners.includes(this.plusPaths[position].sums[j]) ) {
                 this._flipCard(position + dx, true, this.owners[position]);
             }
         }
     }
 
     _checkSameRule(position) {
-        const card = this.data[position];
         let  sames = 0;
         for (let j = 0; j < 4; j += 1) {
             if ( Board.ATTACK_VECTORS[position][j] === 0 ) continue;            
@@ -181,28 +183,26 @@ class Board {
     }
 
     _checkPlusRule(position) { // refactor plz // need fix (problem double plus a.k.a. four side attack)
-        const card = this.data[position];
         let pluses = {};
-        let sum = -1;
         for (let j = 0; j < 4; j += 1) {
             if ( Board.ATTACK_VECTORS[position][j] === 0 ) continue;
-            if(sum = this.plusPaths[position].sums[j])
+            let sum = this.plusPaths[position].sums[j];
+            if ( sum ) {
                 pluses[sum] = (pluses[sum] || 0) + 1;
+            }
         }
         for (var i in pluses) {
             if (pluses[i] > 1) {
-                this.plusPaths[position].winner = parseInt(i);
-                console.log(i);
-                return true;
+                this.plusPaths[position].winners.push(parseInt(i, 10)); 
             }
         }
-        this.plusPaths[position].winner = -1;
-        return false;
+        return this.plusPaths[position].winners.length > 0;
     }
 
     isEmpty(position) {
         return !!this.data[position];
     }
+
 }
 // START From top left goin row row  
 Board.ATTACK_VECTORS = [
@@ -218,6 +218,4 @@ Board.ATTACK_VECTORS = [
     [0, 1, 1, 0]
 ];
 
-module.exports = {
-    GameMachine
-};
+module.exports = GameMachine;

+ 16 - 12
src/Game/game/machine/GameMachine.test.js

@@ -5,32 +5,36 @@ let Card = require('./Card');
 var mac = new GameMachine();
 
 
-let card = new Card();
-card.setAttack([4,2,3,1]);
+let card = new Card(1);
+let ncard = new Card(2);
+let nncard = new Card(3);
+//				R U L D
+// card.setAttack([4,2,3,1]);
 card.setOwner(666);
 
-
-let ncard = new Card();
-ncard.setAttack([4,3,3,10]);
+//				 R U L D
+// ncard.setAttack([4,3,3,10]);
 ncard.setOwner(666);
 
-let nncard = new Card();
-nncard.setAttack([8,5,6,9]);
+// nncard.setAttack([8,5,6,9]);
 nncard.setOwner(665);
 
+
 let move = new Moves.PlaceMove(card, 4, 666);
-mac.runMove(move);
 
 let nmove = new Moves.PlaceMove(card, 3, 665);
-mac.runMove(nmove);
 
 let nnmove = new Moves.PlaceMove(ncard, 1, 666);
-mac.runMove(nnmove);
-
 
 let nnnmove = new Moves.PlaceMove(nncard, 0, 665);
-mac.runMove(nnnmove);
 
 
+mac.runMove(move);
+mac.state.board.debug();
+mac.runMove(nmove);
+mac.state.board.debug();
+mac.runMove(nnmove);
+mac.state.board.debug();
+mac.runMove(nnnmove);
 mac.state.board.debug();
 

+ 24 - 0
src/Game/views/base/Card.js

@@ -8,7 +8,9 @@ import Injector from '../../services/Injector';
 
 import Deck from '../../assets/deck';
 
+import Text from '../misc/Text';
 
+import Machine from '../../game';
 
 const BlueURL = '/files/assets/cards/frame_blue.png';
 const BlueImage = PIXI.Texture.fromImage(BlueURL);
@@ -19,6 +21,8 @@ const RedImage = PIXI.Texture.fromImage(RedURL);
 const LabelURL = '/files/assets/cards/label.png';
 const LabelImage = PIXI.Texture.fromImage(LabelURL);
 
+
+
 class Card extends GuiableContainer{
     constructor(props) {
         super(props);
@@ -39,6 +43,8 @@ class Card extends GuiableContainer{
             id: id || 0
         };
 
+        this.id = id;
+
         // GUI
         this.addFolder('Card');
         //this.addToFolder('Card', this, 'imageURL').onFinishChange((v) => this.loadImage(v));
@@ -90,6 +96,16 @@ class Card extends GuiableContainer{
         this.addChild(this.frame);
 
         this.parentLayer = Injector.getByName('MainLayer');
+
+        this.numbers = 
+        [
+            new Text({text: '1', x:  176, y: -17}),
+            new Text({text: '1', y: -268}),
+            new Text({text: '1', x: -176, y: -17}),
+            new Text({text: '1', y:  268})
+        ];
+        this.numbers.forEach((item) => this.addChild(item));
+
         dragAndDrop(this);
 
         this.loadCard(id || 0);
@@ -99,9 +115,11 @@ class Card extends GuiableContainer{
     setTeam(team) {
         switch(team) {
         case 0: case 'R': case 'r': case false:
+            this.team = 0;
             this.frame.texture = RedImage;
             break;
         case 1: case 'B': case 'b': case true:
+            this.team = 1;
             this.frame.texture = BlueImage;
             break;
         default: break;
@@ -110,8 +128,12 @@ class Card extends GuiableContainer{
 
     loadCard(number) {
         number = parseInt(number+0.5, 10);
+        this.card = number;
         this.imageURL = Deck.Filenames[number];
         this.sprite.texture = Deck.Textures[number];
+
+        this.machineCard = new Machine.Card(number);
+        this.machineCard.attack.forEach((a,i) => this.numbers[i].setText(a));
     }
 
     setTexture(texture) {
@@ -146,6 +168,8 @@ class Card extends GuiableContainer{
 
     // Animate to Position
     moveTo(point, milliseconds=1000) {
+        if(!point)
+            debugger; // error with x undefined...
         let path = new PIXI.tween.TweenPath();
         path.moveTo(this.position.x, this.position.y).lineTo(point.x, point.y);
 

+ 6 - 1
src/Game/views/base/CardHolder.js

@@ -35,7 +35,8 @@ class CardHolder extends GuiableContainer {
         this.construct(props);
         this.appear();
         this.uncloak();
-        this.show();
+        // this.show(); 
+        this.hide();
     }
 
     construct() {
@@ -80,6 +81,10 @@ class CardHolder extends GuiableContainer {
     getCard() {
         return this._card;
     }
+    
+    isEmpty() {
+        return this._card === null || this._card === undefined;
+    }
 
     setEvents() {
         this.sprite.on('mouseup', this._placeFn);

+ 15 - 8
src/Game/views/buildings/Board.js

@@ -1,10 +1,10 @@
 import * as PIXI from 'pixi.js';
-import config from '../../config';
+// import config from '../../config';
 
 import GuiableContainer from '../../../helpers/Guiable';
-import Deck from '../../assets/deck';
+// import Deck from '../../assets/deck';
 import CardHolder from '../base/CardHolder';
-import CollectionHolder from '../base/CollectionHolder';
+// import CollectionHolder from '../base/CollectionHolder';
 import Injector from '../../services/Injector';
 
 class BoardHandler extends GuiableContainer{
@@ -12,8 +12,7 @@ class BoardHandler extends GuiableContainer{
         super(props);
         let {
             x,
-            y,
-            id
+            y
         } = props;
 
         // Properties Component 
@@ -36,8 +35,6 @@ class BoardHandler extends GuiableContainer{
 
     construct(props) {
         let {
-            id,
-            team,
             GameLayer
         } = props;
         
@@ -75,12 +72,22 @@ class BoardHandler extends GuiableContainer{
         this.holders.forEach((item) => this.addChild(item));
     }
 
+    updateTeam(position, team) {
+        if (!this.holders[position].isEmpty()) {   
+            this.holders[position].getCard().setTeam(team);
+        }
+    }
+
+    isEmpty(x) { return !this.holders[x]._locked; }
+
     getCard(x,y) {
         return this.holders[3*y+x].getCard();
     }
 
     placeCard(position, card) {
-       
+        if(this.onCardPlaced) {
+            this.onCardPlaced(position, card);
+        }
     }
 
     onClick(fn) {

+ 4 - 7
src/Game/views/buildings/Collection.js

@@ -1,8 +1,8 @@
-import * as PIXI from 'pixi.js';
-import config from '../../config';
+// import * as PIXI from 'pixi.js';
+// import config from '../../config';
 
 import GuiableContainer from '../../../helpers/Guiable';
-import Deck from '../../assets/deck';
+// import Deck from '../../assets/deck';
 import CardHolder from '../base/CardHolder';
 
 class CollectionHandler extends GuiableContainer{
@@ -10,8 +10,7 @@ class CollectionHandler extends GuiableContainer{
         super(props);
         let {
             x,
-            y,
-            id
+            y
         } = props;
 
         // Properties Component 
@@ -33,8 +32,6 @@ class CollectionHandler extends GuiableContainer{
 
     construct(props) {
         let {
-            id,
-            team,
             GameLayer
         } = props;
         

+ 4 - 7
src/Game/views/buildings/Deck.js

@@ -1,8 +1,8 @@
-import * as PIXI from 'pixi.js';
-import config from '../../config';
+// import * as PIXI from 'pixi.js';
+// import config from '../../config';
 
 import GuiableContainer from '../../../helpers/Guiable';
-import Deck from '../../assets/deck';
+// import Deck from '../../assets/deck';
 import CardHolder from '../base/CardHolder';
 
 class DeckHandler extends GuiableContainer{
@@ -10,8 +10,7 @@ class DeckHandler extends GuiableContainer{
         super(props);
         let {
             x,
-            y,
-            id
+            y
         } = props;
 
         // Properties Component 
@@ -33,8 +32,6 @@ class DeckHandler extends GuiableContainer{
 
     construct(props) {
         let {
-            id,
-            team,
             GameLayer
         } = props;
         

+ 6 - 6
src/Game/views/demo/Board.js

@@ -1,10 +1,10 @@
 import * as PIXI from 'pixi.js';
 
-import Card from '../base/Card';
-import CardHolder from '../base/CardHolder';
+// import Card from '../base/Card';
+// import CardHolder from '../base/CardHolder';
 import BoardHandler from '../buildings/Board';
 import DeckHandler from '../buildings/Deck';
-import Injector from '../../services/Injector';
+// import Injector from '../../services/Injector';
 
 class BoardDemo extends PIXI.Container{
     constructor(props) {
@@ -13,9 +13,9 @@ class BoardDemo extends PIXI.Container{
         let {GameLayer} = props;
 
 
-        let card = new Card({GameLayer, 'x': 100, 'y': -230, team: 0, id: 4}).scaleTo(0.27);
-        card.parentLayer = Injector.getByName('MainLayer');
-        this.addChild(card);
+        // let card = new Card({GameLayer, 'x': 100, 'y': -230, team: 0, id: 4}).scaleTo(0.27);
+        // card.parentLayer = Injector.getByName('MainLayer');
+        // this.addChild(card);
         
         let board = new BoardHandler({GameLayer, 'x': -250, 'y': 0 });
         this.addChild(board);

+ 51 - 9
src/Game/views/demo/BoardPlay.js

@@ -1,35 +1,77 @@
 import * as PIXI from 'pixi.js';
 
 import Card from '../base/Card';
-import Injector from '../../services/Injector';
+// import Injector from '../../services/Injector';
 import BoardStage from './Board';
 
+import * as Machine from '../../game';
+console.log(Machine);
+let GameMachine = new Machine.GameMachine();
+
 class BoardPlayDemo extends PIXI.Container{
     constructor(props) {
         super();
 
         let {GameLayer} = props;
+        this.GameLayer = GameLayer;
 
+        this.stage = new BoardStage(props);
+        this.addChild(this.stage);
 
-        let stage = new BoardStage(props);
-        this.addChild(stage);
-
-        
         for(var i=0;i<5;i++) {
-            let rn = parseInt((Math.random()*1000) % 6);
+            let rn = parseInt((Math.random()*1000) % 6, 10);
             let card = new Card({GameLayer, id:rn});
             let t = i;
-            stage.deck.getHolder(t).occupy(card);
+            this.stage.deck.getHolder(t).occupy(card);
             // setTimeout(() => ) , 100);
-
             this.addChild(card);
         }
 
+        this.stage.board.onCardPlaced = (p,c) => this.moveOnMachine(p,c);
+
+        document.onkeypress = (e) => {
+            e = e || window.event;
+            if (e.keyCode === '80') {
+                if(this.freeSlots.includes(1))
+                    this.NPCMove();
+            }
+        };
+
+        this.freeSlots = [1,1,1, 1,1,1 ,1,1,1];
     }
 
-    _kill = () => {
+    moveOnMachine(position, card) {
+        // My move to machine
+        let move = new Machine.GameMoves.PlaceMove(new Machine.Card(card.id), position, card.team);
+        GameMachine.runMove(move);
+        this.freeSlots[position] = 0;
+        this.freeSlots.forEach((a,index) => {
+            if(a === 1) return;
+            this.stage.board.updateTeam(index, GameMachine.ownerOf(index));
+        });
+
+        // Play NPC
+        if( card.team === 0 ) {
+            if(this.freeSlots.includes(1))
+                    this.NPCMove();
+        }
     }
 
+    NPCMove() {
+        // Random NPC move to machine
+        let cid = parseInt(Math.random() * 123456, 10) % 6;
+        let pos;
+        do{
+            pos = parseInt(Math.random() * 12332145, 10) % 9; 
+        } while (!this.stage.board.isEmpty(pos));
+
+        let cc = new Card({GameLayer:this.GameLayer, id:cid, team: 1});
+        this.addChild(cc);
+        this.stage.board.holders[pos].occupy(cc);
+    }
+
+    _kill = () => {}
+
     getAsJSON = () => {return {component: 'demo/BoardPlay'}}
 }
 

+ 1 - 1
src/Game/views/demo/Collection.js

@@ -1,7 +1,7 @@
 import * as PIXI from 'pixi.js';
 
 import Card from '../base/Card';
-import CardHolder from '../base/CardHolder';
+// import CardHolder from '../base/CardHolder';
 import CollectionHandler from '../buildings/Collection';
 import DeckHandler from '../buildings/Deck';
 import Injector from '../../services/Injector';

+ 2 - 2
src/Game/views/demo/CollectionPlay.js

@@ -1,7 +1,7 @@
 import * as PIXI from 'pixi.js';
 
 import Card from '../base/Card';
-import Injector from '../../services/Injector';
+// import Injector from '../../services/Injector';
 import BoardStage from './Board';
 
 class BoardPlayDemo extends PIXI.Container{
@@ -16,7 +16,7 @@ class BoardPlayDemo extends PIXI.Container{
 
         
         for(var i=0;i<5;i++) {
-            let rn = parseInt((Math.random()*1000) % 6);
+            let rn = parseInt((Math.random()*1000) % 6, 10);
             let card = new Card({GameLayer, id:rn});
             let t = i;
             stage.deck.getHolder(t).occupy(card);

+ 2 - 2
src/Game/views/misc/Text.js

@@ -12,7 +12,7 @@ class Text extends GuiableContainer {
 		} = props;
 
 		this.text = text || '';
-		this.style = style || '';
+		this.style = style || 'Normal';
 		this.x = x || 0;
 		this.y = y || 0;
 
@@ -60,7 +60,7 @@ let TextStylesNames = {
 };
 
 let TextStyles = {
-	Normal: new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 21, fill : 0x000000, align : 'center'}),
+	Normal: new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 61, fill : 0xffffff, align : 'center'}),
 	Light:  new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 22, fill : 0x000000, align : 'center'}),
 	Heavy:  new PIXI.TextStyle({fontFamily : 'Tahoma', fontSize: 25, fill : 0x022005, align : 'center'}),
 	Comic:  new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 28, fill : 0x000000, align : 'Left'}),

+ 42 - 31
src/components/Stats.js

@@ -2,20 +2,8 @@ import React, { Component } from 'react';
 import './Stats.css';
 import Chart from 'chart.js';
 
-import Zigg from '../helpers/generator'
+import {random, createRandomDeck} from '../helpers/deckGenerator';
 
-var seed = 1;
-
-let gen = new Zigg();
-function random() {
-    // var x = Math.sin(seed++) * 10000;
-    // return (x - Math.floor(x))* 123456;
-    let n =  gen.nextGaussian() * 2 + 4.5;
-    return n;
-}
-function r9() {
-    return (parseInt( random() ) % 9) + 1;
-}
 let bgColors = [	
 	'rgba(255, 99, 132, 0.2)',
     'rgba(54, 162, 235, 0.2)',
@@ -34,12 +22,12 @@ let borderColors = [
 
 function createChart(chartID, data, title = "Simple Attack", maxScale = 30) {
 	let labels = Array.apply(null, Array(data.length)).map((a,i) => i+1);
-	let numbers = Array.apply(null, Array(data.length)).map((a,i) => parseInt(random() * 1032132 % 5));
+	let numbers = Array.apply(null, Array(data.length)).map((a,i) => parseInt(random() * 1032132 % 5, 10));
 	let borders = numbers.map((a) => borderColors[a]); 
 	let bgs = numbers.map((a) => bgColors[a]);
 
 	var ctx = document.getElementById(chartID).getContext('2d');
-		var WA = new Chart(ctx, {
+		new Chart(ctx, {
 		    type: 'bar',
 		    data: {
 		        labels: labels,
@@ -74,27 +62,16 @@ class Stats extends Component {
 			deck
 		} = props;
 
-		deck = this.createRandomDeck();
+		deck = createRandomDeck();
 		this.numbers = this.calculateNumbers(deck);
 		this.sums    = this.calculateSummables(this.numbers);
 		this.wapropabilities = this.findWinning(deck);
 		this.losepropabilities = this.findLosing(deck);
 		this.samepropabilities = this.findSame(deck);
 		this.solosamepropabilities = this.findSoloSame(this.samepropabilities);
+		this.plustriggers = this.findPlusTriggers(this.numbers);
 	}
 	
-	createRandomDeck() {
-		let a = [];
-		for(var j=0;j<100;j++){
-			let b = [];
-			for(var i=0;i<4;i++){
-				b[i] = r9();
-			}
-			a.push(b);
-		}
-		return a;
-	}
-
 	componentDidMount() {
         createChart("chart11", this.numbers[0], "Right Numbers Distribution");
         createChart("chart12", this.numbers[1], "Up Numbers Distribution");
@@ -113,7 +90,10 @@ class Stats extends Component {
         createChart("chart43", this.samepropabilities[2], "Left Same Chance", 100);
         createChart("chart44", this.samepropabilities[3], "Down Same Chance", 100);
         createChart("chart51", this.solosamepropabilities, "Same Chance Of card", 100);
+        createChart("chart61", this.plustriggers[0], "R-L Plus Triggers", 250);
+        createChart("chart62", this.plustriggers[1], "U-D Plus Triggers", 250);
 	}
+
 	componentWillUnmount() {
        
 	}
@@ -124,7 +104,7 @@ class Stats extends Component {
 
 	findSame(deck) {
 		let nums = this.calculateNumbers(deck);
-		let sums = this.calculateSummables(nums);
+		// let sums = this.calculateSummables(nums);
 
 		let cards = deck.map((card) => {
 			return [
@@ -149,6 +129,23 @@ class Stats extends Component {
 		return a;
 	}
 
+	findPlusTriggers(nums) {
+		let c = [
+			Array.apply(null, Array(19)).map(Number.prototype.valueOf,0),
+			Array.apply(null, Array(19)).map(Number.prototype.valueOf,0)
+		];
+		for (let i = 0; i < 2; i++) {
+			let a = nums[i];
+			let b = nums[i+2];
+			for (let j=0; j < 9; j++) {
+				for (let z=0; z < 9; z++) {
+					c[i][j+z+1] += a[j] + b[z];
+				}
+			}
+		}
+		return c;
+	}
+
 	findLosing(deck) {
 		let wins = this.findWinning(deck);
 		let loses = wins.map((sidewins) => sidewins.map((n) => 100-n));
@@ -190,8 +187,8 @@ class Stats extends Component {
 			Array.apply(null, Array(9)).map(Number.prototype.valueOf,0)
 		];
 
-		deck.map((card) => 
-			card.map((number,side) => {
+		deck.forEach((card) => 
+			card.forEach((number,side) => {
 				nums[side][number-1] += 1;
 			})
 		);
@@ -265,6 +262,20 @@ class Stats extends Component {
 		    		<canvas id="chart51" width="200" height="100"></canvas>
 		    	</div>
 		    </div>
+		    <div>
+		    	<div className="chartBox-lg">
+		    		<canvas id="chart51" width="200" height="100"></canvas>
+		    	</div>
+		    </div>
+		    <div>
+		    	<div className="chartBox">
+		    		<canvas id="chart61" width="250" height="100"></canvas>
+		    	</div>
+		    	<div className="chartBox">
+		    		<canvas id="chart62" width="250" height="100"></canvas>
+		    	</div>
+		    </div>
+		    
 	    </div>
 	    );
 	}

+ 29 - 0
src/helpers/deckGenerator.js

@@ -0,0 +1,29 @@
+let Zigg = require('./generator');
+
+// var seed = 1;
+
+let gen = new Zigg();
+function random() {
+    // var x = Math.sin(seed++) * 10000;
+    // return (x - Math.floor(x))* 123456;
+    let n =  gen.nextGaussian() * 2 + 4.5;
+    return n;
+}
+function r9() {
+    return (parseInt( random(), 10) % 9) + 1;
+}
+
+function createRandomDeck() {
+    let a = [];
+    for(var j=0;j<100;j++){
+        let b = [];
+        for(var i=0;i<4;i++){
+            b[i] = r9();
+        }
+        a.push(b);
+    }
+    return a;
+}
+
+
+module.exports = {random, Zigg, createRandomDeck};

+ 4 - 4
src/helpers/generator.js

@@ -1,6 +1,6 @@
-function Ziggurat(){
+function Ziggurat(seeder = 123456789){
 
-  var jsr = 123456789;
+  var jsr = seeder;
 
   var wn = Array(128);
   var fn = Array(128);
@@ -23,7 +23,7 @@ function Ziggurat(){
     var y;
     while(true){
       x = hz * wn[iz];
-      if( iz == 0 ){
+      if( iz === 0 ){
         x = (-Math.log(UNI()) * r1); 
         y = -Math.log(UNI());
         while( y + y < x * x){
@@ -89,4 +89,4 @@ function Ziggurat(){
   zigset();
 }
 
-export default Ziggurat;
+module.exports = Ziggurat;