Saturday, October 06, 2018

Proposal: dictionary of fire

became popular 6 to 0. Enacted by Derrick

Adminned at 08 Oct 2018 16:47:32 UTC

If the proposal Fire With Fire has passed, this proposal does nothing instead.

After this line
var randomSeed = “__RANDOM”;
in the text of the Master Control Program add the following functions after replacing each "\]" with a "]"


function makeFirewallDictionary(IO){
var firewallDictionary = {};
var tempstr = IO.split("\n\n");
var program;
for( var i = 0; i < tempstr.length; i++ ){
program = tempstr[i\].split("\n");
firewallDictionary[program.shift()] = program;
}
return firewallDictionary;
}

function fireCellValue(row, column, firewall){
return firewall[row][column];
}

function isAdj2Coord(midRow, midCol, sigEquip, firewall){
properties = [];
numpad = [ 1, 2, 3, 4, 6, 7, 8, 9 ];
if(midCol == 0){
if(numpad.includes(7)){
numpad.splice(numpad.indexOf(7), 1);
}
if(numpad.includes(8)){
numpad.splice(numpad.indexOf(8), 1);
}
if(numpad.includes(9)){
numpad.splice(numpad.indexOf(9), 1);
}
}
if(midCol == 7){
if(numpad.includes(1)){
numpad.splice(numpad.indexOf(1), 1);
}
if(numpad.includes(2)){
numpad.splice(numpad.indexOf(2), 1);
}
if(numpad.includes(3)){
numpad.splice(numpad.indexOf(3), 1);
}
}
if(midRow == 0){
if(numpad.includes(7)){
numpad.splice(numpad.indexOf(7), 1);
}
if(numpad.includes(4)){
numpad.splice(numpad.indexOf(4), 1);
}
if(numpad.includes(1)){
numpad.splice(numpad.indexOf(1), 1);
}
}
if(midRow == 7){
if(numpad.includes(9)){
numpad.splice(numpad.indexOf(9), 1);
}
if(numpad.includes(6)){
numpad.splice(numpad.indexOf(6), 1);
}
if(numpad.includes(3)){
numpad.splice(numpad.indexOf(3), 1);
}
}
for(i = 0; i < numpad.length; i++){
numpad[i\] = numpadValues(numpad[i\]);
}
for(i = 0; i < numpad.length; i++){
if(fireCellValue(midRow + numpad[i\][1], midCol + numpad[i\][0], firewall) == sigEquip){
return true;
}
}
return false;
}

function numpadValues(num){
switch(num){
case 1:
return [-1, 1];
case 2:
return [0, 1];
case 3:
return [1, 1];
case 4:
return [-1, 0];
case 6:
return [1, 0];
case 7:
return [-1, -1];
case 8:
return [0, -1];
case 9:
return [1, -1];
default:
return [0, 0];
}
}

function inFireWall(firewall, equip){
for(i = 0; i < firewall.length; i++){
if(firewall[i\].includes(equip)){
return true;
}
}
return false;
}

functions which deal with the firewalls. I tested them so they should work but I could’ve missed a few things since I don’t really know javascript.

Comments

Lulu: she/her

07-10-2018 02:36:08 UTC

against

Lulu: she/her

07-10-2018 02:36:28 UTC

for pressed the wrong button, sorry

Trigon:

07-10-2018 17:33:31 UTC

On the one hand, these functions might be helpful in the future sometime, but on the other hand, they are very repetitive and ugly. Therefore I vote imperial but my vote might change.

Trigon:

07-10-2018 17:59:13 UTC

Also, what is up with the number pad functions? When will we ever need them? Are we planning on using numbers in conjunction with the firewall? Should we not wait until we know what the actual contents of the firewall are before creating functions to deal with it?

card:

08-10-2018 01:22:22 UTC

in short, the numbers in numberpad are not used in the firewall at all; I agree that we should expand on exactly what can be present in a firewall and allow programs to modify them in a future proposal.

The numberpad variable is simply set up like the numberpad on a keyboard and having offsets with 5 as the origin. For example the 3 key corresponds to the character that is 1 row under and 1 column to the right of the character that is being checked for adjacency. The Y axis is inverted when compared to a regular graph because of how array indexing works. I’m sure there’s a better way to do this function but I don’t know it and nobody else had made a proposal for this functionality.

Kevan: he/him

08-10-2018 07:59:42 UTC

for

derrick: he/him

08-10-2018 13:52:27 UTC

for

Though I plan to rewrite some of these. That appears to be my role this dynasty. I should figure out how to use it to win…

Brendan: he/him

08-10-2018 14:54:21 UTC

for