Git Product home page Git Product logo

irma4's Introduction

irma4

Fourth version of irma artificial life simulator on rust

irma4's People

Contributors

tmptrash avatar

Watchers

 avatar  avatar

irma4's Issues

Implement performance measure approach

The meaning of this is to have some code, function, or crate, which measures the performance of a function or a piece of code in nanoseconds or milliseconds. Good to have a flame chart for the entire app to see the global picture and performance GAPs.

Add gui plugin

It should visualize all the data in a world
Add stuff:

  • Zoom by mouse scroll button
  • Move into 4 directions (by mouse or arrow keys)
  • in add_listeners() func x, y should be calculated according to the size and offset of the canvas, because canvas may show only a part of big world (zoom, scroll). For now we just put a pixel with x,y.
    Update: https://github.com/Rust-SDL2/rust-sdl2/blob/master/examples/gfx-demo.rs

Improve irma4 repo on github

Do the same like we had for irma project. I mean meaningful description, all available commands. Links to documentation and so on.

Implement mov atom

This is the most complex part. mov atom must be optimized by speed as much as possible because it grabs most of the CPU resources.

Playground skeleton

Should work like a container for different applications like:

  • Atoms and molecules editor by mouse and some menu with settings. Should support atom type, bonds, position, atom selection
enum Dirs {
    NO         = -1,
    LEFT_UP    = 0,
    UP         = 1,
    UP_RIGHT   = 2,
    RIGHT      = 3,
    RIGHT_DOWN = 4,
    DOWN       = 5,
    DOWN_LEFT  = 6,
    LEFT       = 7
}
const TYPE_MOV = 0b0010000000000000;
const TYPE_SPL = 0b0110000000000000;
const TYPE_FIX = 0b0100000000000000;
const TYPE_IF  = 0b1000000000000000;
const TYPE_JOB = 0b1010000000000000;

const log = console.log.bind(console);

function hex(atom: number) { return '0b' + atom.toString(2).padStart(16, '0').match(/.{1,4}/g)?.join('_') }
/**
 * Returns standard header (type + vm dir + vm dir bit). This header exists
 * for all atom types. Here are related bits: 0 atom type 3 vmDir 6 vmDir on/off
 *                                            XXX         XXX     X
 * @param  atomType Type of the atom (0 - empty, 1 - mov, 2 - fix,...)
 * @param  vmDir    Direction of near atom, where VM will be moved (0..7)
 * @return 16bit number
 */
function head(atomType: number, vmDir: Dirs = Dirs.NO): number {
    let atom = atomType;                         // atom type
    if (vmDir >= Dirs.LEFT_UP && vmDir <= Dirs.LEFT) {
        atom |= (vmDir << 10);                   // VM dir
        atom |= (1 << 9);                        // VM dir bit
    } else {
        atom &= 0b1111110111111111;              // no VM dir bit
    }
    return atom;
}
/**
 * Returns mov atom as binary u16 number (Rust format)
 */
function mov(movDir: Dirs, vmDir: Dirs = Dirs.NO): string {
    let atom = head(TYPE_MOV, vmDir);            // mov type
    if (movDir < Dirs.LEFT_UP || movDir > Dirs.LEFT) { throw 'Invalid "mov" atom direction' }
    atom |= (movDir << 6);                       // move dir
    return hex(atom);
}
/**
 * Returns fix atom as binary u16 number (Rust format)
 */
function fix(dir1: Dirs, dir2: Dirs, vmDir: Dirs = Dirs.NO): string {
    let atom = head(TYPE_FIX, vmDir);            // fix type
    if (dir1 < Dirs.LEFT_UP || dir1 > Dirs.LEFT) { throw 'Invalid "fix" direction 1' }
    atom |= (dir1 << 6);                         // dir1
    if (dir2 < Dirs.LEFT_UP || dir2 > Dirs.LEFT) { throw 'Invalid "fix" direction 2' }
    atom |= (dir2 << 3);                         // dir2
    return hex(atom);
}
/**
 * Returns spl atom as binary u16 number (Rust format)
 */
function spl(vmDir: Dirs = Dirs.NO, dir1: Dirs = Dirs.LEFT_UP, dir2: Dirs = Dirs.LEFT_UP): string {
    let atom = head(TYPE_SPL, vmDir);            // spl type
    if (dir1 < Dirs.LEFT_UP || dir1 > Dirs.LEFT) { throw 'Invalid "spl" direction 1' }
    atom |= (dir1 << 6);                         // dir1
    if (dir2 < Dirs.LEFT_UP || dir2 > Dirs.LEFT) { throw 'Invalid "spl" direction 2' }
    atom |= (dir2 << 3);                         // dir2
    return hex(atom);
}
/**
 * Returns if atom as binary u16 number (Rust format)
 */
function ifo(vmElseDir: Dirs = Dirs.NO, ifDir: Dirs = Dirs.NO, thenDir: Dirs = Dirs.NO): string {
    let atom = head(TYPE_IF, vmElseDir);         // if type
    if (ifDir >= Dirs.LEFT_UP && ifDir <= Dirs.LEFT) {
        atom |= (ifDir << 6);                    // ifDir
        atom |= (1 << 2);                        // ifDir bit
    } else {
        atom &= 0b1111111111111011;              // ifDir bit
    }
    if (thenDir >= Dirs.LEFT_UP && thenDir <= Dirs.LEFT) {
        atom |= (thenDir << 3);                  // thenDir
        atom |= (1 << 1);                        // thenDir bit
    } else {
        atom &= 0b1111111111111101;              // thenDir bit
    }
    return hex(atom);
}
/**
 * Returns job atom as binary u16 number (Rust format)
 */
function job(jobDir: Dirs = Dirs.NO, vmDir: Dirs = Dirs.NO): string {
    let atom = head(TYPE_JOB, vmDir);            // job type
    if (jobDir < Dirs.LEFT_UP || jobDir > Dirs.LEFT) { throw 'Invalid "job" direction' }
    atom |= (jobDir << 6);
    return hex(atom);
}

log(mov(Dirs.RIGHT));
  • Debugger
  • Save/Load from JSON

Implement dynamic plugin system

Core should implement dynamic plugins (dll,so, files) system, which loading, initializing and running them. Think about trait of plugin with all needed functions (init, idle, destroy).

Learn rust

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.