bt cannon

This commit is contained in:
PolicyChanges1@gmail.com 2021-03-22 20:33:47 -04:00
parent b9e575ecbd
commit fa37f623f1
5 changed files with 132 additions and 148 deletions

138
dist/tetrion.js vendored
View File

@ -959,26 +959,40 @@ Tetris.prototype = {
document.getElementById("Openers").appendChild(newOpener); document.getElementById("Openers").appendChild(newOpener);
// Print Sequence Data to console // Print Sequence Data to console
console.log("this.hintQueue = new Array("); // console.log("this.hintQueue = new Array(");
this.shapeQueue.slice().reverse().forEach( function(shape, idx, arr) { console.log("shapes.getShape("+shape.nType()+ ((idx === arr.length-1) ? "));" : "),") ); } ); // this.shapeQueue.slice().reverse().forEach( function(shape, idx, arr) { console.log("shapes.getShape("+shape.nType()+ ((idx === arr.length-1) ? "));" : "),") ); } );
var shapes = []; var shapes = [];
this.shapeQueue.slice().reverse().forEach( function(shape, idx) { shapes.push(shape.x); shapes.push(shape.y); shapes.push(shape.state); } ); this.shapeQueue.slice().reverse().forEach( function(shape, idx) { shapes.push(shape.x); shapes.push(shape.y); shapes.push(shape.state); } );
console.log("var hintDataList = [" + shapes.join(",") + "];"); // console.log("var hintDataList = [" + shapes.join(",") + "];");
console.log("this.createHintQueue(hintDataList);"); // console.log("this.createHintQueue(hintDataList);");
openers.addSequence(this.shapeQueue); var sequenceCode = [];
var shapeArrayStr = [];
this.shapeQueue.slice().reverse().forEach( function(shape, idx, arr) { shapeArrayStr += "shapes.getShape("+shape.nType() + ((idx === arr.length-1) ? "));" : "), ") } );
sequenceCode += "case :\n\tthis.shapeQueue = new Array(" + shapeArrayStr + "\nbreak;" + "\n\n";
sequenceCode += "case :\n\tthis.hintQueue = new Array(" + shapeArrayStr;
sequenceCode += "\n\nvar hintDataList = [" + shapes.join(",") + "];" + "\nthis.createHintQueue(hintDataList);" + "\nbreak;";
prompt("Generated Code:", sequenceCode);
//openers.addSequence(this.shapeQueue);
//this.setFreePlay(); //this.setFreePlay();
this.gameState = consts.GAMESTATES[1]; //this.gameState = consts.GAMESTATES[1];
this.currentMinoInx = 0; this.currentMinoInx = 0;
//this.setCurrentOpener(99999);//this.currentMinoInx); //this.setCurrentOpener(99999);//this.currentMinoInx);
clearMatrix(this.matrix); clearMatrix(this.matrix);
this.currentOpener = 9999; this.currentOpener = 9999;
this.shapeQueue = []; this.shapeQueue = [];
this.hintQueue = []; this.hintQueue = [];
this._recurseGameState(); //this._recurseGameState();
}, },
setSettings: function() { setSettings: function() {
var newVal = document.getElementById("setting_value").value; var newVal = document.getElementById("setting_value").value;
@ -1003,8 +1017,7 @@ Tetris.prototype = {
this.levelTime = this.startTime; this.levelTime = this.startTime;
this.prevInputTime = this.startTime; this.prevInputTime = this.startTime;
// current tetrino index gets set to 0 at the end of opener sequence // current tetrino index gets set to 0 at the end of opener sequence
//if(this.currentMinoInx == undefined || this.currentMinoInx < 1000) // todo: refactor -- seppuku worthy this.currentMinoInx = 0;
this.currentMinoInx = 0;
this.shapeQueue = []; this.shapeQueue = [];
this.hintQueue = []; this.hintQueue = [];
this.holdStack = []; this.holdStack = [];
@ -1711,36 +1724,36 @@ var openerGenerator = {
break; break;
case 11: case 11:
this.shapeQueue = new Array( this.shapeQueue = new Array(
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(1), shapes.getShape(1),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(6), shapes.getShape(6),
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(6), shapes.getShape(6),
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(1), shapes.getShape(1),
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(6), shapes.getShape(6),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(1), shapes.getShape(1),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(6)); shapes.getShape(6));
break; break;
case 12: case 12:
this.shapeQueue = new Array( this.shapeQueue = new Array(
@ -1749,6 +1762,10 @@ var openerGenerator = {
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3)); shapes.getShape(3));
break; break;
case 13:
this.shapeQueue = new Array(shapes.getShape(4), shapes.getShape(6), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(6), shapes.getShape(0), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4));
break;
default: default:
this.shapeQueue.unshift(utils.deepClone(shapes.randomShape())); this.shapeQueue.unshift(utils.deepClone(shapes.randomShape()));
return; return;
@ -2070,6 +2087,12 @@ var openerGenerator = {
var hintDataList = [3,17,1,6,18,0,5,17,2,1,18,0]; var hintDataList = [3,17,1,6,18,0,5,17,2,1,18,0];
this.createHintQueue(hintDataList); this.createHintQueue(hintDataList);
break; break;
case 13:
this.hintQueue = new Array(shapes.getShape(4), shapes.getShape(6), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(6), shapes.getShape(0), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4));
var hintDataList = [0,18,0,3,18,0,-1,17,0,7,18,0,3,17,0,8,16,3,0,15,2,-2,14,0,3,15,2,3,14,0,1,13,3,8,14,3,7,12,2,5,16,2,3,14,3,6,17,3,5,18,0];
this.createHintQueue(hintDataList);
break;
default: default:
this.hintQueue.unshift(utils.deepClone(shapes.randomShape())); this.hintQueue.unshift(utils.deepClone(shapes.randomShape()));
return; return;
@ -2375,38 +2398,7 @@ function ShapeO() {
} }
function ShapeI() { function ShapeI() {
/* // North
var state1 = [
[1, 0, 0, 0],
[1, 0, 0, 0],
[1, 0, 0, 0],
[1, 0, 0, 0]
];
// East
var state2 = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 1, 1, 1],
[0, 0, 0, 0]
];
// South
var state3 = [
[0, 0, 1, 0],
[0, 0, 1, 0],
[0, 0, 1, 0],
[0, 0, 1, 0]
];
// West
var state4 = [
[0, 0, 0, 0],
[1, 1, 1, 1],
[0, 0, 0, 0],
[0, 0, 0, 0]
];
*/
// North // North
var state1 = [ var state1 = [
[0, 0, 0, 0], [0, 0, 0, 0],
@ -3120,8 +3112,6 @@ function randomShape() {
} }
function getShape(shapei) { function getShape(shapei) {
var result = shapei var result = shapei
var shape; var shape;

View File

@ -194,6 +194,10 @@ this.resizebg();
document.getElementById("setDTCannonTSZbaseVar").addEventListener("click", function() { tetrion.setCurrentOpener(10); } ); document.getElementById("setDTCannonTSZbaseVar").addEventListener("click", function() { tetrion.setCurrentOpener(10); } );
document.getElementById("setDTCannonLHVar").addEventListener("click", function() { tetrion.setCurrentOpener(11); } ); document.getElementById("setDTCannonLHVar").addEventListener("click", function() { tetrion.setCurrentOpener(11); } );
document.getElementById("TestSequence").addEventListener("click", function() { tetrion.setCurrentOpener(12); } ); document.getElementById("TestSequence").addEventListener("click", function() { tetrion.setCurrentOpener(12); } );
//document.getElementById("setStdPCOpenerVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
document.getElementById("setBTCannonVar").addEventListener("click", function() { tetrion.setCurrentOpener(13); } );
document.getElementById("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } ); document.getElementById("enablegamepad").addEventListener("click", function() { tetrion.toggleGamepad(); } );

View File

@ -275,26 +275,40 @@ Tetris.prototype = {
document.getElementById("Openers").appendChild(newOpener); document.getElementById("Openers").appendChild(newOpener);
// Print Sequence Data to console // Print Sequence Data to console
console.log("this.hintQueue = new Array("); // console.log("this.hintQueue = new Array(");
this.shapeQueue.slice().reverse().forEach( function(shape, idx, arr) { console.log("shapes.getShape("+shape.nType()+ ((idx === arr.length-1) ? "));" : "),") ); } ); // this.shapeQueue.slice().reverse().forEach( function(shape, idx, arr) { console.log("shapes.getShape("+shape.nType()+ ((idx === arr.length-1) ? "));" : "),") ); } );
var shapes = []; var shapes = [];
this.shapeQueue.slice().reverse().forEach( function(shape, idx) { shapes.push(shape.x); shapes.push(shape.y); shapes.push(shape.state); } ); this.shapeQueue.slice().reverse().forEach( function(shape, idx) { shapes.push(shape.x); shapes.push(shape.y); shapes.push(shape.state); } );
console.log("var hintDataList = [" + shapes.join(",") + "];"); // console.log("var hintDataList = [" + shapes.join(",") + "];");
console.log("this.createHintQueue(hintDataList);"); // console.log("this.createHintQueue(hintDataList);");
openers.addSequence(this.shapeQueue); var sequenceCode = [];
var shapeArrayStr = [];
this.shapeQueue.slice().reverse().forEach( function(shape, idx, arr) { shapeArrayStr += "shapes.getShape("+shape.nType() + ((idx === arr.length-1) ? "));" : "), ") } );
sequenceCode += "case :\n\tthis.shapeQueue = new Array(" + shapeArrayStr + "\nbreak;" + "\n\n";
sequenceCode += "case :\n\tthis.hintQueue = new Array(" + shapeArrayStr;
sequenceCode += "\n\nvar hintDataList = [" + shapes.join(",") + "];" + "\nthis.createHintQueue(hintDataList);" + "\nbreak;";
prompt("Generated Code:", sequenceCode);
//openers.addSequence(this.shapeQueue);
//this.setFreePlay(); //this.setFreePlay();
this.gameState = consts.GAMESTATES[1]; //this.gameState = consts.GAMESTATES[1];
this.currentMinoInx = 0; this.currentMinoInx = 0;
//this.setCurrentOpener(99999);//this.currentMinoInx); //this.setCurrentOpener(99999);//this.currentMinoInx);
clearMatrix(this.matrix); clearMatrix(this.matrix);
this.currentOpener = 9999; this.currentOpener = 9999;
this.shapeQueue = []; this.shapeQueue = [];
this.hintQueue = []; this.hintQueue = [];
this._recurseGameState(); //this._recurseGameState();
}, },
setSettings: function() { setSettings: function() {
var newVal = document.getElementById("setting_value").value; var newVal = document.getElementById("setting_value").value;
@ -319,8 +333,7 @@ Tetris.prototype = {
this.levelTime = this.startTime; this.levelTime = this.startTime;
this.prevInputTime = this.startTime; this.prevInputTime = this.startTime;
// current tetrino index gets set to 0 at the end of opener sequence // current tetrino index gets set to 0 at the end of opener sequence
//if(this.currentMinoInx == undefined || this.currentMinoInx < 1000) // todo: refactor -- seppuku worthy this.currentMinoInx = 0;
this.currentMinoInx = 0;
this.shapeQueue = []; this.shapeQueue = [];
this.hintQueue = []; this.hintQueue = [];
this.holdStack = []; this.holdStack = [];

View File

@ -174,36 +174,36 @@ var openerGenerator = {
break; break;
case 11: case 11:
this.shapeQueue = new Array( this.shapeQueue = new Array(
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(1), shapes.getShape(1),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(6), shapes.getShape(6),
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(6), shapes.getShape(6),
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(1), shapes.getShape(1),
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(6), shapes.getShape(6),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(5), shapes.getShape(5),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(1), shapes.getShape(1),
shapes.getShape(3), shapes.getShape(3),
shapes.getShape(4), shapes.getShape(4),
shapes.getShape(0), shapes.getShape(0),
shapes.getShape(6)); shapes.getShape(6));
break; break;
case 12: case 12:
this.shapeQueue = new Array( this.shapeQueue = new Array(
@ -212,6 +212,10 @@ var openerGenerator = {
shapes.getShape(2), shapes.getShape(2),
shapes.getShape(3)); shapes.getShape(3));
break; break;
case 13:
this.shapeQueue = new Array(shapes.getShape(4), shapes.getShape(6), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(6), shapes.getShape(0), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4));
break;
default: default:
this.shapeQueue.unshift(utils.deepClone(shapes.randomShape())); this.shapeQueue.unshift(utils.deepClone(shapes.randomShape()));
return; return;
@ -533,6 +537,12 @@ var openerGenerator = {
var hintDataList = [3,17,1,6,18,0,5,17,2,1,18,0]; var hintDataList = [3,17,1,6,18,0,5,17,2,1,18,0];
this.createHintQueue(hintDataList); this.createHintQueue(hintDataList);
break; break;
case 13:
this.hintQueue = new Array(shapes.getShape(4), shapes.getShape(6), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(6), shapes.getShape(0), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4));
var hintDataList = [0,18,0,3,18,0,-1,17,0,7,18,0,3,17,0,8,16,3,0,15,2,-2,14,0,3,15,2,3,14,0,1,13,3,8,14,3,7,12,2,5,16,2,3,14,3,6,17,3,5,18,0];
this.createHintQueue(hintDataList);
break;
default: default:
this.hintQueue.unshift(utils.deepClone(shapes.randomShape())); this.hintQueue.unshift(utils.deepClone(shapes.randomShape()));
return; return;

View File

@ -209,38 +209,7 @@ function ShapeO() {
} }
function ShapeI() { function ShapeI() {
/* // North
var state1 = [
[1, 0, 0, 0],
[1, 0, 0, 0],
[1, 0, 0, 0],
[1, 0, 0, 0]
];
// East
var state2 = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 1, 1, 1],
[0, 0, 0, 0]
];
// South
var state3 = [
[0, 0, 1, 0],
[0, 0, 1, 0],
[0, 0, 1, 0],
[0, 0, 1, 0]
];
// West
var state4 = [
[0, 0, 0, 0],
[1, 1, 1, 1],
[0, 0, 0, 0],
[0, 0, 0, 0]
];
*/
// North // North
var state1 = [ var state1 = [
[0, 0, 0, 0], [0, 0, 0, 0],
@ -954,8 +923,6 @@ function randomShape() {
} }
function getShape(shapei) { function getShape(shapei) {
var result = shapei var result = shapei
var shape; var shape;