Close Menu
Soshace Digital Blog

    Subscribe to Updates

    Get The Latest News, Updates, And Amazing Offers

    What's Hot
    Programming

    Уроки React. Урок 7

    Interview

    How to Take Control of Your Tech Interview | Take Charge in Three Easy Steps

    Node.js

    Node.js Lesson 4: NPM Package Structure

    Important Pages:
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Today's Picks:
    • Scaling Success: Monitoring Indexation of Programmatic SEO Content
    • Leveraging Influencers: Key Drivers in New Product Launches
    • How Privacy-First Marketing Will Transform the Industry Landscape
    • The Impact of Social Proof on Thought Leadership Marketing
    • Balancing Value-Driven Content and Promotional Messaging Strategies
    • Top Influencer Marketing Platforms to Explore in 2025
    • Emerging Trends in Marketing Automation and AI Tools for 2023
    • Strategies to Mitigate Duplicate Content in Programmatic SEO
    Sunday, September 28
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Soshace Digital Blog
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Services
    • SaaS & Tech

      Maximizing Efficiency: How SaaS Lowers IT Infrastructure Costs

      August 27, 2025

      Navigating Tomorrow: Innovations Shaping the Future of SaaS

      August 27, 2025

      Maximizing Impact: Strategies for SaaS & Technology Marketing

      August 27, 2025
    • AI & Automation

      Enhancing Customer Feedback Analysis Through AI Innovations

      August 27, 2025

      Navigating the Impact of AI on SEO and Search Rankings

      August 27, 2025

      5 Automation Hacks Every Home Service Business Needs to Know

      May 3, 2025
    • Finance & Fintech

      Critical Missteps in Finance Marketing: What to Avoid

      August 27, 2025

      Analyzing Future Fintech Marketing Trends: Insights Ahead

      August 27, 2025

      Navigating the Complex Landscape of Finance and Fintech Marketing

      August 27, 2025
    • Legal & Compliance

      Exploring Thought Leadership’s Impact on Legal Marketing

      August 27, 2025

      Maximizing LinkedIn: Strategies for Legal and Compliance Marketing

      August 27, 2025

      Why Transparency Matters in Legal Advertising Practices

      August 27, 2025
    • Medical Marketing

      Enhancing Online Reputation Management in Hospitals: A Guide

      August 27, 2025

      Analyzing Emerging Trends in Health and Medical Marketing

      August 27, 2025

      Exploring Innovative Content Ideas for Wellness Blogs and Clinics

      August 27, 2025
    • E-commerce & Retail

      Strategic Seasonal Campaign Concepts for Online and Retail Markets

      August 27, 2025

      Emerging Trends in E-commerce and Retail Marketing Strategies

      August 27, 2025

      Maximizing Revenue: The Advantages of Affiliate Marketing for E-Commerce

      August 27, 2025
    • Influencer & Community

      Leveraging Influencers: Key Drivers in New Product Launches

      August 27, 2025

      Top Influencer Marketing Platforms to Explore in 2025

      August 27, 2025

      Key Strategies for Successful Influencer Partnership Negotiations

      August 27, 2025
    • Content & Leadership

      The Impact of Social Proof on Thought Leadership Marketing

      August 27, 2025

      Balancing Value-Driven Content and Promotional Messaging Strategies

      August 27, 2025

      Analyzing Storytelling’s Impact on Content Marketing Effectiveness

      August 27, 2025
    • SEO & Analytics

      Scaling Success: Monitoring Indexation of Programmatic SEO Content

      August 27, 2025

      Strategies to Mitigate Duplicate Content in Programmatic SEO

      August 27, 2025

      Effective Data Visualization Techniques for SEO Reporting

      August 27, 2025
    • Marketing Trends

      How Privacy-First Marketing Will Transform the Industry Landscape

      August 27, 2025

      Emerging Trends in Marketing Automation and AI Tools for 2023

      August 27, 2025

      Maximizing ROI: Key Trends in Paid Social Advertising

      August 27, 2025
    Soshace Digital Blog
    Blog / JavaScript / Swarm Intelligence: Intensities
    JavaScript

    Swarm Intelligence: Intensities

    Nikita BraginBy Nikita BraginApril 23, 2023Updated:April 26, 2023No Comments5 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Swarm Intelligence: Intensities
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link
    Multiple intensities
    Multiple intensities

    In this article, I want to make the task more complex. Last time, I implemented an organism that selected the maximum intensity around it and moved on. By intensity, I mean a circular gradient; the organism’s task is to reach the maximum point in the shortest way possible. There was only one center of intensity, and consequently, there was only one path of upward movement along the increasing gradient. This time, there will be multiple intensities, the path will be more winding, and the organism will make decisions based on the average intensity values around it.

    Implementation of multiple intensity sources

    So, I have a desire to infinitely add the number of possible sources, and I decided to describe the intensity with its control elements in the form of a class. Accordingly, next time, we will only need to create a new object.

    Multiple Intensities' Controls
    Multiple Intensities’ Controls

    The main method, which will create the intensity, remains almost unchanged:

    applyGradient(xCenter, yCenter) {
        const newGradient = [];
        const radius = this.selectedIntensity;
    
        const minX = Math.max(0, xCenter - radius);
        const maxX = Math.min(this.numberOfColumns - 1, xCenter + radius);
        const minY = Math.max(0, yCenter - radius);
        const maxY = Math.min(this.numberOfRows - 1, yCenter + radius);
    
        for (let y = minY; y <= maxY; y++) {
          for (let x = minX; x <= maxX; x++) {
            const xDistance = xCenter - x;
            const yDistance = yCenter - y;
            const distance = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2));
            const intensity = Number(Math.max(0, this.selectedIntensity - distance).toFixed(2));
            const color = this.selectedColor;
    
            if (intensity > 0) {
              newGradient.push({
                x: x,
                y: y,
                color: color,
                intensity: intensity
              });
            }
          }
        }
    
        if (_.isEmpty(this.gradientIntensityMap)) {
          this.gradientIntensityMap = newGradient;
          this.gradientIndex = this.gridInstance.registerNewIntensity(newGradient);
          return;
        }
    
        this.gradientIntensityMap = newGradient;
        this.gridInstance.updateIntensity(this.gradientIndex, newGradient);
      }
    

    Next, since there will be multiple intensities, we face the task of combining the intensity results together on the field. We need to calculate the sum of colors and intensities for each cell of the field where the intersection will occur. First, I register each new intensity using the Grid class method: registerNewIntensity. After that, I perform the calculation of the combined intensities.

    Read More:  Comparative Analysis of Free Tools for Physical Memory Dumps Parsing
    Combined intensities
    Combined intensities

    The method that combines the intensities is extracted into the class that creates the field grid. Here’s what it looks like:

    mergeIntensities() {
      this.intensityMap = {};
    
        for (const key in this.intensityInstances) {
          const instanceIntensityArray = this.intensityInstances[key];
          for (const cell of instanceIntensityArray) {
            const numberOfTheCell = cell.y * this.numberOfColumns + cell.x;
    
            const currentIntensityInstance = this.intensityMap[numberOfTheCell];
    
            if (cell.organism) {
              this.intensityMap[numberOfTheCell] = {
                color: cell.color,
                organism: true,
                intensity: currentIntensityInstance.intensity
              };
              continue;
            }
    
            let mergedIntensities;
            if (!currentIntensityInstance) {
              mergedIntensities = cell.intensity;
              this.intensityMap[numberOfTheCell] = {
                color: cell.color,
                intensity: cell.intensity,
              };
              continue;
            }
    
            mergedIntensities = (Number(currentIntensityInstance.intensity) + Number(cell.intensity));
            if (mergedIntensities > this.maxIntensity) {
                mergedIntensities = this.maxIntensity;
            }
            const mergedColors = mergeRGBColors(currentIntensityInstance.color, cell.color);
            this.intensityMap[numberOfTheCell] = {
              color: mergedColors,
              intensity: mergedIntensities,
            };
          }
        }
    
        this.reDrawTheGrid();
      }
    

    Another interesting innovation in the new approach is choosing the next cell step based on the highest average value of the intensity sum of the 9 surrounding cells instead of choosing the cell with the highest intensity.

    8 Neighbour cells
    8 Neighbour cells

    In the previous implementation, I selected the cell with the highest intensity and moved forward. In the new implementation, I choose the cell with the highest average intensity value around it. In this case, we have a higher probability that we will end up in the area with the highest possible intensity around the new cell for the next step. At the same time, the organism can only see one cell deep around itself. That is, when choosing the next cell, the organism will rely on the average value of the visible cells.

    setDecisionMap (){
        const dataMap = this.getKeyDataMap();
        console.log ("dataMap", dataMap);
        const neighbors = [
          [-1, -1], [-1, 0], [-1, 1],
          [0, -1], [0, 0], [0, 1],
          [1, -1], [1, 0], [1, 1],
        ];
    
        let keyDecisionMap = {};
        let decisionMap = [];
    
        for (const dataKey in dataMap) {
          const dataInstance = dataMap[dataKey];
          let numberOfneighbours = 0;
          let neighboursIntensitySum = 0;
    
          for (const [dx, dy] of neighbors) {
            let x = dataInstance.x + dx;
            let y = dataInstance.y + dy;
            let neighbourIntsance = dataMap[y * this.numberOfColumns + x];
            if (neighbourIntsance){
              numberOfneighbours++;
              neighboursIntensitySum = neighboursIntensitySum + neighbourIntsance.intensity;
            }
          }
    
          const decisionValue = Math.round(neighboursIntensitySum / numberOfneighbours * 1000) / 1000;
          const decision = {
            x: dataInstance.x,
            y: dataInstance.y,
            value: decisionValue
          };
          keyDecisionMap[dataKey] = decision;
          decisionMap.push(decision);
          }
    
          this.keyDecisionMap = keyDecisionMap;
          this.decisionMap = decisionMap;
        }
    

    Why did we need a new approach? Because with intersecting intensities, the organism may face a choice between two cells with the same intensity. In the case of a single intensity, this problem did not arise. In the new approach, we will calculate the average intensity value for each area of the potential step. This way, the decision will be more balanced, and the organism will end up in an area with a higher potential on average across the surrounding field. Using the previous logic, the organism could easily end up in an area with a high central intensity and low intensity around it.

    Read More:  Enim Facilisis Gravida Neque Convallis Cras Semper Auctor

    Although the new solution for choosing the next step is more balanced, the choice based on the average value in its current form does not solve the uncertainty problem. There are still many areas with the same average value, which is not much different from the first case, and the organism will go in circles, ending up in zones with the same average intensity for neighboring cells. We will try to address this issue more thoroughly next time.

    Link to the source: https://github.com/brnikita/Cellular-Automata/tree/Step-2.-Multiple-Intensities
    Previous article: https://blog.soshace.com/my-way-to-agi-infusoria-slipper/

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Nikita Bragin

      Related Posts

      Streamlining Resource Allocation for Enhanced Project Success

      December 18, 2024

      Conducting Effective Post-Project Evaluations: A Guide

      December 16, 2024

      Strategies for Keeping Projects on Track and Meeting Deadlines

      December 10, 2024
      Leave A Reply Cancel Reply

      You must be logged in to post a comment.

      Stay In Touch
      • Facebook
      • Twitter
      • Pinterest
      • Instagram
      • YouTube
      • Vimeo
      Don't Miss
      Wiki December 31, 2015

      Работа с заказчиком

      1) Оценка проекта. Заказчик должен точно понимать что и главное когда будет реализовано. Можно использовать как таск трекер со стороны заказчика, так и предложить свой вариант.

      Strategic Approaches to Secure Capital for Your Tech Startup

      November 28, 2024

      7 Best App Makers to Build Your Own Mobile App

      September 19, 2019

      Best Resources for Preparing for Your Technical Interview: Books and Online Platforms

      June 21, 2019

      Categories

      • AI & Automation
      • Angular
      • ASP.NET
      • AWS
      • B2B Leads
      • Beginners
      • Blogs
      • Business Growth
      • Case Studies
      • Comics
      • Consultation
      • Content & Leadership
      • CSS
      • Development
      • Django
      • E-commerce & Retail
      • Entrepreneurs
      • Entrepreneurship
      • Events
      • Express.js
      • Facebook Ads
      • Finance & Fintech
      • Flask
      • Flutter
      • Franchising
      • Funnel Strategy
      • Git
      • GraphQL
      • Home Services Marketing
      • Influencer & Community
      • Interview
      • Java
      • Java Spring
      • JavaScript
      • Job
      • Laravel
      • Lead Generation
      • Legal & Compliance
      • LinkedIn
      • Machine Learning
      • Marketing Trends
      • Medical Marketing
      • MSP Lead Generation
      • MSP Marketing
      • NestJS
      • Next.js
      • Node.js
      • Node.js Lessons
      • Paid Advertising
      • PHP
      • Podcasts
      • POS Tutorial
      • Programming
      • Programming
      • Python
      • React
      • React Lessons
      • React Native
      • React Native Lessons
      • Recruitment
      • Remote Job
      • SaaS & Tech
      • SEO & Analytics
      • Soshace
      • Startups
      • Swarm Intelligence
      • Tips
      • Trends
      • Vue
      • Wiki
      • WordPress
      Top Posts

      Comprehension in Python

      Programming February 5, 2020

      React Lesson 8: Deep Dive into React Redux

      JavaScript February 9, 2020

      Mastering Project Performance Reviews: A Step-by-Step Guide

      JavaScript December 9, 2024

      React Lesson 2: Homework Assignment

      JavaScript November 1, 2019

      Subscribe to Updates

      Get The Latest News, Updates, And Amazing Offers

      About Us
      About Us

      Soshace Digital delivers comprehensive web design and development solutions tailored to your business objectives. Your website will be meticulously designed and developed by our team of seasoned professionals, who combine creative expertise with technical excellence to transform your vision into a high-impact, user-centric digital experience that elevates your brand and drives measurable results.

      7901 4th St N, Suite 28690
      Saint Petersburg, FL 33702-4305
      Phone: 1(877)SOSHACE

      Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
      Our Picks
      Programming

      Code Review

      Programming

      2. Уроки Node.js. Модули Часть 2

      Interview

      Interview with Alex

      Most Popular

      Writing end-to-end tests for Nuxt apps using jsdom and AVA

      JavaScript

      GraphQL

      Programming

      Build Real-World React Native App #6: Show Bookmark and Categories

      JavaScript
      © 2025 Soshace Digital.
      • Home
      • About
      • Services
      • Contact Us
      • Privacy Policy
      • Terms & Conditions

      Type above and press Enter to search. Press Esc to cancel.