Fourth version of irma artificial life simulator on rust
tmptrash / irma4 Goto Github PK
View Code? Open in Web Editor NEWFourth version of irma artificial life simulator on rust
License: MIT License
Fourth version of irma artificial life simulator on rust
License: MIT License
We should run:
Do the same like we had for irma project. I mean meaningful description, all available commands. Links to documentation and so on.
It should support commands:
Levels: error, warn, info, debug, trace.
See this for details: https://doc.rust-lang.org/rustdoc/
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.
For now atom.rs uses functions to manipulate bits in atoms. We have to rewrite them into macroses to increase speed
It should visualize all the data in a world
Add stuff:
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.Should work like a container for different applications like:
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));
Lectures:
https://www.youtube.com/watch?v=bR4nGWmfzTk&list=PLVhhUNGAUIQScqB26DdUq4n1Y2n3auM7X
Exersices:
https://www.educative.io/courses/learn-rust-from-scratch
Docs:
file:///C:/Users/slackline/.rustup/toolchains/stable-x86_64-pc-windows-msvc/share/doc/rust/html/reference/introduction.html
https://www.rust-lang.org/ru/learn
https://doc.rust-lang.org/stable/rust-by-example/
Books
https://www.manning.com/books/rust-in-action
https://www.mn.uio.no/ifi/english/research/groups/psy/completedmasters/2020/ringdal/thesis-ringdal.pdf
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).
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.
In the release build we have to remove all dbg!()
macroses
Create initial skeleton of application
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.