Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var eff = [[0,-1,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0],
- [0,0,-1,0,0,1,1,0,0,0,0,0,0,-1,0,0,1,-1],
- [0,1,0,0,2,-1,1,0,0,0,0,1,-1,0,-1,0,0,0],
- [0,1,0,1,-1,0,1,0,0,0,0,1,0,-1,0,0,0,1],
- [0,0,0,1,0,1,0,0,0,0,-1,-1,2,0,-1,0,0,0],
- [1,-1,1,1,-1,0,0,0,-1,1,-1,-1,0,0,0,0,0,0],
- [0,1,-1,0,1,-1,0,0,0,-1,0,1,0,0,0,0,0,0],
- [0,2,0,1,0,0,1,-1,0,0,0,0,0,0,0,0,-1,0],
- [1,-1,1,2,-1,1,1,0,1,-1,0,1,0,1,1,1,0,1],
- [0,0,0,0,-1,-1,1,0,1,1,-1,1,0,0,1,0,0,1],
- [0,0,0,0,0,0,0,0,1,1,1,-1,-1,0,1,0,0,0],
- [0,0,-1,-1,1,0,-1,0,0,-1,1,1,1,0,-1,0,0,0],
- [0,0,1,0,-1,0,0,0,1,0,0,0,1,0,0,0,0,0],
- [0,1,0,0,0,0,-1,-1,0,0,0,0,0,1,0,0,-1,0],
- [0,-1,0,0,0,-1,0,0,-1,-1,0,0,0,0,1,0,0,0],
- [0,0,0,0,0,0,0,0,0,1,1,1,1,0,-1,-1,0,-1],
- [0,-1,0,0,0,0,-1,1,0,0,0,0,0,2,0,0,1,-1],
- [0,1,0,-1,0,0,1,0,-1,0,0,0,0,0,0,2,1,0]];
- var aeff = [[0,0,0,0,0,-1,0,-2,-1,0,0,0,0,0,0,0,0,0],
- [1,0,-1,-1,0,1,-1,-2,1,0,0,0,0,-1,1,0,1,-1],
- [0,1,0,0,0,-1,1,0,-1,0,0,1,-1,0,0,0,0,0],
- [0,0,0,-1,-1,-1,0,-1,-2,0,0,1,0,0,0,0,0,1],
- [0,0,-2,1,0,1,-1,0,1,1,0,-1,1,0,0,0,0,0],
- [0,-1,1,0,-1,0,1,0,-1,1,0,0,0,0,1,0,0,0],
- [0,-1,-1,-1,0,0,0,-1,-1,-1,0,1,0,1,0,0,1,-1],
- [-2,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,-1,0],
- [0,0,0,0,0,1,0,0,-1,-1,-1,0,-1,0,1,0,0,1],
- [0,0,0,0,0,-1,1,0,1,-1,-1,1,0,0,1,-1,0,0],
- [0,0,0,0,1,1,0,0,0,1,-1,-1,0,0,0,-1,0,0],
- [0,0,-1,-1,1,1,-1,0,-1,-1,1,-1,0,0,0,-1,0,0],
- [0,0,1,0,-2,0,0,0,0,0,1,-1,-1,0,0,-1,0,0],
- [0,1,0,1,0,0,0,0,-1,0,0,0,0,-1,0,0,-2,0],
- [0,0,1,0,1,0,0,0,-1,-1,-1,1,0,0,-1,1,0,0],
- [0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,1,0,-2],
- [0,-1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,-1,-1],
- [0,1,0,-1,0,0,0,0,-1,-1,0,0,0,0,0,1,1,0]];
- var types = ['normal','fighting','flying','poison','ground','rock','bug','ghost','steel','fire','water','grass','electric','psychic','ice','dragon','dark','fairy'];
- var hiscore = 0;
- var hiteam = [[]];
- var hieff = [[[],[]]];
- var start = new Date().getTime();
- types.slice().forEach(function(type,index) {
- //type = 'normal';
- //index = 0;
- var team = [type];
- var score = 0;
- var def = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
- types.forEach(function(type2,index2){
- index2 += 18-types.length;
- if (team.indexOf(type2) === -1) {
- team.push(type2);
- types.forEach(function(type3,index3){
- index3 += 18-types.length;
- if (team.indexOf(type3) === -1) {
- team.push(type3);
- types.forEach(function(type4,index4){
- index4 += 18-types.length;
- if (team.indexOf(type4) === -1) {
- team.push(type4);
- types.forEach(function(type5,index5){
- index5 += 18-types.length;
- if (team.indexOf(type5) === -1) {
- team.push(type5);
- types.forEach(function(type6,index6){
- index6 += 18-types.length;
- if (team.indexOf(type6) === -1) {
- team.push(type6);
- // Evaluate Team
- def[1] = selectHighestValues(eff[index], eff[index2], eff[index3], eff[index4], eff[index5], eff[index6]);
- def[0] = selectHighestValues(aeff[index], aeff[index2], aeff[index3], aeff[index4], aeff[index5], aeff[index6]);
- score = def[1].reduce(getSum) + (5 * def[0].reduce(getSum));
- if (score > hiscore) {
- hiscore = score;
- hiteam = [team.slice().sort()];
- hieff = [def.slice()];
- } else if (score === hiscore) {
- hiteam.push(team.slice().sort());
- hieff.push(def.slice());
- }
- team.pop();
- }
- });
- team.pop();
- }
- });
- team.pop();
- }
- });
- team.pop();
- }
- });
- team.pop();
- }
- });
- types.shift();
- });
- hiteam.forEach(function(val){console.log(val);});
- console.log(hieff[0]);
- console.log(hiteam.length);
- console.log(hiscore);
- console.log(new Date().getTime() - start);
- function selectHighestValues (arr1, arr2, arr3, arr4, arr5, arr6) {
- var length = arr1.length;
- var arr = [];
- for (var i = 0; i < length; i++) {
- arr[i] = Math.max(arr1[i], arr2[i], arr3[i], arr4[i], arr5[i], arr6[i], 0);
- }
- return arr;
- }
- function getSum(total, num) {
- return total + num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement