File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11export default {
22 WORLD : { // section, where the world config leaves
3- width : 2048 , // world width in pixels
3+ width : 2000 , // world width in pixels
44 height : 2000 , // world height in pixels
55 zoom : 0.1 // zoom speed coefficient
66 } ,
@@ -14,8 +14,8 @@ export default {
1414 percent : .5 , // amount of VMs from amount of atoms. if atoms.length === 10 & percent === .2 => VMs === 2
1515 } ,
1616 ATOM : {
17- seed : 3 , // seed for all random numbers in a system
18- stackBufSize : 128 , // stack size for mov atom (amount of moved atoms)
17+ seed : 1 , // seed for all random numbers in a system
18+ stackBufSize : 1024 , // stack size for mov atom (amount of moved atoms)
1919 percent : .15 , // affects to amount of atoms in the world
2020 moveTries : 5 , // amount of near atoms "mov" atom will move per one call
2121 NRG : {
Original file line number Diff line number Diff line change 22< html >
33 < head >
44 < title > irma5 - ALife digital organisms simulator</ title >
5+ < style >
6+ @font-face {
7+ font-family : 'JetBrainsMono' ;
8+ src : url ('/JetBrainsMono-Medium.woff2' ) format ('woff2' );
9+ }
10+ </ style >
511 </ head >
612 < body >
713 < canvas id ="irma5 "> </ canvas >
Original file line number Diff line number Diff line change @@ -89,7 +89,6 @@ function run() {
8989// Create instances of the world, plugins, atoms & VMs
9090//
9191const w = World ( ) // 2D world
92- const plugins = [ Title ( w ) , Buttons ( w ) ] // plugins of the world
9392let atoms = createAtoms ( w ) // array of atoms [{x, y, a},...]
9493let vmOffs = createVMs ( w , atoms ) // array of virtual machines by coordinates + energies
9594//let atoms = [{x: 3, y: 3, a: 0x21bf}]
@@ -102,6 +101,7 @@ const vms = VMs(w) // VMs instance
102101addAtoms ( w , atoms )
103102addVMs ( vms , vmOffs )
104103atoms = vmOffs = undefined // we have to remove global vars manually
104+ const plugins = [ Title ( w , vms ) , Buttons ( w ) ] // plugins of the world
105105//
106106// Run infinite loop of the simulator
107107//
Original file line number Diff line number Diff line change 11import CFG from '../cfg.js'
22
3- export default function Title ( w ) {
3+ export default function Title ( w , vms ) {
44 const $ = document . querySelector . bind ( document )
55 return {
66 w,
7+ vms,
78 title : '' ,
89 titleEl : $ ( CFG . HTML . titleQuery ) ,
910 t : performance . now ( ) ,
11+ rps : 0 ,
1012 ticks : 0 ,
1113 update
1214 }
@@ -16,12 +18,21 @@ export function destroy(t) {
1618 t . w . title = null
1719}
1820
21+ function format ( n ) {
22+ if ( n >= 1_000_000_000_000 ) return ( n / 1_000_000_000_000 ) . toFixed ( 1 ) + 'T' ;
23+ if ( n >= 1_000_000_000 ) return ( n / 1_000_000_000 ) . toFixed ( 1 ) + 'B' ;
24+ if ( n >= 1_000_000 ) return ( n / 1_000_000 ) . toFixed ( 1 ) + 'M' ;
25+ if ( n >= 1_000 ) return ( n / 1_000 ) . toFixed ( 1 ) + 'K' ;
26+ return n . toString ( ) ;
27+ }
28+
1929function update ( t ) {
2030 const now = performance . now ( )
21- t . ticks ++
31+ t . rps ++
32+ t . ticks += CFG . rpi * t . vms . offs . i
2233 if ( now - t . t > 1000 ) {
2334 t . t = now
24- t . titleEl . textContent = t . ticks
25- t . ticks = 0
35+ t . titleEl . textContent = `rps: ${ t . rps } , tks: ${ format ( t . ticks ) } `
36+ t . rps = 0
2637 }
2738}
Original file line number Diff line number Diff line change 5252
5353.title {
5454 position : absolute;
55- top : 7 px ;
55+ top : 6 px ;
5656 left : 60px ;
5757 color : # fff ;
5858 font-size : 18px ;
59- font-family : Consolas ;
59+ font-family : JetBrainsMono ;
6060}
You can’t perform that action at this time.
0 commit comments