From 784efd7b6534117850dddd8ae118ae5ec327cb2d Mon Sep 17 00:00:00 2001 From: M4YX0R Date: Sun, 16 Jan 2022 12:26:41 +0300 Subject: [PATCH 1/6] Discord link added and fix to run links in new tab --- dist/index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/index.html b/dist/index.html index d2fe2742..f49c7f74 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,8 @@ The Life Engine - + + @@ -67,8 +68,9 @@

The Life Engine

@@ -153,6 +155,8 @@

Brain

+ +
From d20f4a110ea3a5c33bef4804c5db11a7a98a400a Mon Sep 17 00:00:00 2001 From: M4YX0R Date: Sun, 16 Jan 2022 13:38:47 +0300 Subject: [PATCH 2/6] One click discord emoji code copy to clipboard! --- dist/css/style.css | 4 +-- dist/index.html | 3 +- src/Controllers/ControlPanel.js | 60 +++++++++++++++++++++++++++++++++ src/Organism/Cell/CellStates.js | 21 ++++++------ 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/dist/css/style.css b/dist/css/style.css index 5c7d20c7..378b7daf 100644 --- a/dist/css/style.css +++ b/dist/css/style.css @@ -170,7 +170,7 @@ button:active{ #editor-panel{ display: flex; } -.edit-mode-btn { +.edit-mode-btn, .copy-code { width: 30px; height: 30px; margin-top: 5px; @@ -184,7 +184,7 @@ button:active{ #organism-options { display: none; } -#drop-org { +#copy-dc-code { bottom: 0; } #editor-env { diff --git a/dist/index.html b/dist/index.html index f49c7f74..203bdd24 100644 --- a/dist/index.html +++ b/dist/index.html @@ -80,6 +80,7 @@

The Life Engine

+
@@ -155,8 +156,6 @@

Brain

- -
diff --git a/src/Controllers/ControlPanel.js b/src/Controllers/ControlPanel.js index f57b94b4..b61d50f0 100644 --- a/src/Controllers/ControlPanel.js +++ b/src/Controllers/ControlPanel.js @@ -3,6 +3,7 @@ const Modes = require("./ControlModes"); const StatsPanel = require("../Stats/StatsPanel"); const RandomOrganismGenerator = require("../Organism/RandomOrganismGenerator") const WorldConfig = require("../WorldConfig"); +const CellStates = require("../Organism/Cell/CellStates"); class ControlPanel { constructor(engine) { @@ -361,6 +362,65 @@ class ControlPanel { this.env_controller.resetView(); }.bind(this)); + $('#copy-dc-code').click( function(){ + let cells = this.engine.organism_editor.organism.anatomy.cells; + let code = ""; + let startx = 0; + let starty = 0; + let endx = 0; + let endy = 0; + + for (var cell of cells) { + if(cell.loc_col < startx) { + startx = cell.loc_col; + } + if(cell.loc_col > endx) { + endx = cell.loc_col; + } + if(cell.loc_row < starty) { + starty = cell.loc_row; + } + if(cell.loc_row > endy) { + endy = cell.loc_row; + } + } + //iterate from top left to bottom right + for(var i = starty; i <= endy; i++) { + for(var j = startx; j <= endx; j++) { + let cell = cells.find(c => c.loc_row == i && c.loc_col == j); + if(cell == undefined) { + code += CellStates.empty.dc_code; + }else { + if(cell.state.dc_code == ':eye:'){ + switch (cell.direction) { + case 0://up + code += ':eyeu:'; + break; + case 1://right + code += ':eyer:'; + break; + case 2://down + code += ':eyed:'; + break; + case 3://left + code += ':eyel:'; + break; + default: + code += ':eye:'; + break; + } + }else{ + code += cell.state.dc_code; + } + } + } + code += "\n"; + } + + console.log(code); + navigator.clipboard.writeText(code); + }.bind(this)); + var env = this.engine.env; $('#reset-env').click( function() { env.reset(); diff --git a/src/Organism/Cell/CellStates.js b/src/Organism/Cell/CellStates.js index 9bf54f8c..a9ab720a 100644 --- a/src/Organism/Cell/CellStates.js +++ b/src/Organism/Cell/CellStates.js @@ -1,8 +1,9 @@ // A cell state is used to differentiate type and render the cell class CellState{ - constructor(name) { + constructor(name, dc_code = ':vd:') { this.name = name; this.color = 'black'; + this.dc_code = dc_code; } render(ctx, cell, size) { @@ -13,47 +14,47 @@ class CellState{ class Empty extends CellState { constructor() { - super('empty'); + super('empty',':vd:'); } } class Food extends CellState { constructor() { - super('food'); + super('food',':food:'); } } class Wall extends CellState { constructor() { - super('wall'); + super('wall',':wall:'); } } class Mouth extends CellState { constructor() { - super('mouth'); + super('mouth',':eat:'); } } class Producer extends CellState { constructor() { - super('producer'); + super('producer',':prod:'); } } class Mover extends CellState { constructor() { - super('mover'); + super('mover',':mov:'); } } class Killer extends CellState { constructor() { - super('killer'); + super('killer',':kill:'); } } class Armor extends CellState { constructor() { - super('armor'); + super('armor',':arm:'); } } class Eye extends CellState { constructor() { - super('eye'); + super('eye',':eye:'); this.slit_color = 'black'; } render(ctx, cell, size) { From 2551229c6f41a54ae51847238f00b5ea39e2c276 Mon Sep 17 00:00:00 2001 From: M4YX0R Date: Sun, 16 Jan 2022 21:02:14 +0300 Subject: [PATCH 3/6] Include organism data (brain, move range etc.) --- dist/index.html | 2 +- src/Controllers/ControlPanel.js | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/dist/index.html b/dist/index.html index 203bdd24..ff4e223f 100644 --- a/dist/index.html +++ b/dist/index.html @@ -123,7 +123,7 @@

Edit Organism

Cell count:

- +
diff --git a/src/Controllers/ControlPanel.js b/src/Controllers/ControlPanel.js index b61d50f0..9d4b48ba 100644 --- a/src/Controllers/ControlPanel.js +++ b/src/Controllers/ControlPanel.js @@ -363,7 +363,9 @@ class ControlPanel { }.bind(this)); $('#copy-dc-code').click( function(){ - let cells = this.engine.organism_editor.organism.anatomy.cells; + let org = this.engine.organism_editor.organism; + let anatomy = org.anatomy; + let cells = anatomy.cells; let code = ""; let startx = 0; let starty = 0; @@ -414,7 +416,34 @@ class ControlPanel { } } } - code += "\n"; + + code += '\n'; + } + + code += "Cell Count: " + cells.length + "\n"; + if(anatomy.is_mover) code += "Move Range: " + org.move_range + "\n"; + code += "Mutation Rate: " + org.mutability + "\n"; + if(anatomy.is_mover && anatomy.has_eyes){ + let brain = org.brain; + + let chase_types = []; + let retreat_types = []; + for(let cell_name in brain.decisions) { + let decision = brain.decisions[cell_name]; + if (decision == 1) { + retreat_types.push(cell_name) + } + else if (decision == 2) { + chase_types.push(cell_name); + } + } + + if(chase_types.length > 0) { + code += "Move Towards: " + chase_types.join(', ') + "\n"; + } + if(retreat_types.length > 0) { + code += "Move Away From: " + retreat_types.join(', ') + "\n"; + } } console.log(code); From d4c3090f96cc9e74135079a38a3bb6004d0d9946 Mon Sep 17 00:00:00 2001 From: M4YX0R Date: Mon, 17 Jan 2022 18:44:42 +0300 Subject: [PATCH 4/6] Hotkey to copy org discord code to clipboard --- dist/index.html | 4 ++-- src/Controllers/ControlPanel.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/index.html b/dist/index.html index ff4e223f..c063bf11 100644 --- a/dist/index.html +++ b/dist/index.html @@ -80,7 +80,7 @@

The Life Engine

- +
@@ -186,7 +186,7 @@

Reset Options



- +
diff --git a/src/Controllers/ControlPanel.js b/src/Controllers/ControlPanel.js index 9d4b48ba..fddf3234 100644 --- a/src/Controllers/ControlPanel.js +++ b/src/Controllers/ControlPanel.js @@ -91,7 +91,10 @@ class ControlPanel { case 'c': $('#drop-org').click(); break; - case 'v': // toggle hud + case 'v': + $('#copy-dc-code').click(); + break; + case 'b': // toggle hud if (this.no_hud) { let control_panel_display = this.control_panel_active ? 'grid' : 'none'; let hot_control_display = !this.control_panel_active ? 'block' : 'none'; @@ -107,7 +110,7 @@ class ControlPanel { } this.no_hud = !this.no_hud; break; - case 'b': + case 'n': $('#clear-walls').click(); } }); From 5ab9e02cb4297b9f8e792b46db050d8790d89c4f Mon Sep 17 00:00:00 2001 From: M4YX0R Date: Tue, 18 Jan 2022 06:52:55 +0300 Subject: [PATCH 5/6] :__: fits better with discord instead :vd: --- src/Organism/Cell/CellStates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Organism/Cell/CellStates.js b/src/Organism/Cell/CellStates.js index a9ab720a..c81433b9 100644 --- a/src/Organism/Cell/CellStates.js +++ b/src/Organism/Cell/CellStates.js @@ -14,7 +14,7 @@ class CellState{ class Empty extends CellState { constructor() { - super('empty',':vd:'); + super('empty',':__:'); } } class Food extends CellState { From fa104e3ff88143b8b721e8c668ae9915437c008d Mon Sep 17 00:00:00 2001 From: M4YX0R Date: Tue, 18 Jan 2022 06:56:35 +0300 Subject: [PATCH 6/6] I have changed my mind. :vd: emoji feels better --- src/Organism/Cell/CellStates.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Organism/Cell/CellStates.js b/src/Organism/Cell/CellStates.js index c81433b9..b94a61ae 100644 --- a/src/Organism/Cell/CellStates.js +++ b/src/Organism/Cell/CellStates.js @@ -1,6 +1,6 @@ // A cell state is used to differentiate type and render the cell class CellState{ - constructor(name, dc_code = ':vd:') { + constructor(name, dc_code = ':__:') { this.name = name; this.color = 'black'; this.dc_code = dc_code; @@ -14,7 +14,7 @@ class CellState{ class Empty extends CellState { constructor() { - super('empty',':__:'); + super('empty',':vd:'); } } class Food extends CellState {