Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webTAS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Florent Becker
webTAS
Commits
b1b0721b
Commit
b1b0721b
authored
Apr 09, 2026
by
Florent Becker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
draft: improved tracking of simulation time
parent
a33cf7d9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
93 deletions
+125
-93
index.html
index.html
+2
-1
simulator.mjs
src/simulator.mjs
+21
-9
tileblock.mjs
src/tileblock.mjs
+35
-18
tileworker.js
src/tileworker.js
+67
-65
No files found.
index.html
View file @
b1b0721b
...
...
@@ -312,12 +312,13 @@
<div
class=
"w3-bar-item bar-divider"
></div>
<button
id=
"select-mode-button"
class=
"w3-bar-item w3-button"
><span
class=
"material-icons"
>
highlight_alt
</span></button>
<button
id=
"place-mode-button"
class=
"w3-bar-item w3-button"
><span
class=
"material-icons"
>
edit
</span></button>
<button
id=
"zoom-out-button"
class=
"w3-bar-item w3-button w3-right"
><span
class=
"material-icons"
>
zoom_out
</span></button>
<button
id=
"zoom-in-button"
class=
"w3-bar-item w3-button w3-right"
><span
class=
"material-icons"
>
zoom_in
</span></button>
</div>
<div
id=
"simulator"
>
<canvas
id=
"sim-canvas"
></canvas>
<svg
id=
"sim-canvas"
width=
"100%"
height=
"100%"
></svg>
<svg
id=
"sim-canvas"
width=
"100%"
height=
"100%"
></svg>
</div>
<div
id=
"sim-info"
class=
"w3-small w3-light-grey"
>
Simulator
</div>
</div>
...
...
src/simulator.mjs
View file @
b1b0721b
...
...
@@ -120,12 +120,13 @@ export class Simulator {
if
(
keepSeed
)
{
this
.
tileWorker
.
postMessage
({
msg
:
'set-seed'
,
seed
:
this
.
seedTiles
});
this
.
tileBlockAtlas
.
add_many
(
this
.
seedTiles
);
for
(
const
tile
of
this
.
seedTiles
)
{
// this.addTile(tile.type, tile.coords);
// this.tileWorker.postMessage({ msg: 'add-tile', tid: tile.type.id, x: tile.coords.x, y: tile.coords.y});
this
.
tileBlockAtlas
.
add
(
tile
.
type
,
tile
.
coords
);
}
//
for (const tile of this.seedTiles) {
//
// this.addTile(tile.type, tile.coords);
//
// this.tileWorker.postMessage({ msg: 'add-tile', tid: tile.type.id, x: tile.coords.x, y: tile.coords.y});
//
this.tileBlockAtlas.add(tile.type, tile.coords);
//
}
Logger
.
log
(
Logger
.
INFO
,
"reset system to seed"
);
...
...
@@ -224,7 +225,7 @@ export class Simulator {
if
(
e
.
data
.
msg
===
"tile-added"
)
{
const
type
=
this
.
tileset
.
getTileTypeById
(
e
.
data
.
tid
);
const
coords
=
new
Vector2D
(
e
.
data
.
x
,
e
.
data
.
y
);
this
.
tileBlockAtlas
.
add
(
type
,
coords
);
this
.
tileBlockAtlas
.
add
_one
(
type
,
coords
);
this
.
renderUpdate
=
true
;
}
else
if
(
e
.
data
.
msg
===
"tiles-added"
)
{
const
fastForwardBuffer
=
e
.
data
.
buffer
;
...
...
@@ -382,8 +383,9 @@ export class Simulator {
this
.
renderer
.
render
(
this
.
scene
,
this
.
camera
);
}
this
.
selectedTile
.
render
();
let
infoStr
=
`Simulator:
${
this
.
tileBlockAtlas
.
numTiles
}
tiles`
;
this
.
selectedTile
.
render
();
let
time
=
this
.
tileBlockAtlas
.
history
.
length
;
let
infoStr
=
`Simulator:
${
this
.
tileBlockAtlas
.
numTiles
}
tiles, Simulation time:
${
time
}
`
;
if
(
this
.
mouseoverQuad
.
visible
)
{
infoStr
+=
` --- Mouse Coordinates: (
${
this
.
mouseoverQuad
.
position
.
x
}
,
${
this
.
mouseoverQuad
.
position
.
y
}
)`
}
...
...
@@ -527,7 +529,17 @@ export class Simulator {
}
else
if
(
this
.
simulation_mode
===
'SyncTAM'
)
{
this
.
tileWorker
.
postMessage
({
msg
:
'mode-SyncTAM'
});
}
this
.
tileWorker
.
postMessage
({
msg
:
'set-seed'
,
seed
:
this
.
seedTiles
});
console
.
log
(
this
.
seedTiles
.
length
);
if
(
this
.
seedTiles
.
length
==
0
)
{
let
ttypes
=
this
.
tileset
.
tileTypes
;
let
tile
=
ttypes
[
Math
.
floor
(
Math
.
random
()
*
ttypes
.
length
)];
let
origin
=
new
Vector2D
(
0
,
0
);
this
.
tileBlockAtlas
.
add
(
tile
,
origin
);
this
.
seedTiles
.
push
({
type
:
tile
,
coords
:
origin
});
}
this
.
tileWorker
.
postMessage
({
msg
:
'set-seed'
,
seed
:
this
.
seedTiles
});
Logger
.
log
(
Logger
.
INFO
,
`loaded
${
this
.
simulation_mode
}
system file "
${
data
.
tdp
.
name
}
" with a seed of size
${
this
.
seedTiles
.
length
}
`
);
...
...
src/tileblock.mjs
View file @
b1b0721b
...
...
@@ -246,32 +246,49 @@ export class TileBlockAtlas {
}
stepBackward
()
{
const
coords
=
this
.
history
.
pop
();
return
this
.
remove
(
coords
);
const
attachments
=
this
.
history
.
pop
();
for
(
let
coords
of
attachments
)
{
let
success
=
this
.
remove
(
coords
);
if
(
!
success
)
return
false
;
}
return
true
;
}
add
(
type
,
coords
)
{
const
blockIndex
=
this
.
getBlockIndex
(
coords
);
add
_inner
(
type
,
coords
)
{
const
blockIndex
=
this
.
getBlockIndex
(
coords
);
if
(
!
this
.
tileBlocks
.
has
(
blockIndex
.
y
))
this
.
tileBlocks
.
set
(
blockIndex
.
y
,
new
Map
());
if
(
!
this
.
tileBlocks
.
has
(
blockIndex
.
y
))
this
.
tileBlocks
.
set
(
blockIndex
.
y
,
new
Map
());
const
subMap
=
this
.
tileBlocks
.
get
(
blockIndex
.
y
);
if
(
!
subMap
.
has
(
blockIndex
.
x
))
{
const
tileBlock
=
new
TileBlock
(
blockIndex
.
mul
(
BLOCK_DIMS
));
const
subMap
=
this
.
tileBlocks
.
get
(
blockIndex
.
y
);
if
(
!
subMap
.
has
(
blockIndex
.
x
))
{
const
tileBlock
=
new
TileBlock
(
blockIndex
.
mul
(
BLOCK_DIMS
));
this
.
tileGroup
.
add
(
tileBlock
.
tileMesh
);
this
.
outlineGroup
.
add
(
tileBlock
.
outlineMesh
);
subMap
.
set
(
blockIndex
.
x
,
tileBlock
);
}
this
.
tileGroup
.
add
(
tileBlock
.
tileMesh
);
this
.
outlineGroup
.
add
(
tileBlock
.
outlineMesh
);
subMap
.
set
(
blockIndex
.
x
,
tileBlock
);
}
const
tileBlock
=
subMap
.
get
(
blockIndex
.
x
);
const
tileBlock
=
subMap
.
get
(
blockIndex
.
x
);
tileBlock
.
add
(
type
,
coords
);
tileBlock
.
add
(
type
,
coords
);
this
.
numTiles
++
;
}
add_one
(
type
,
coords
)
{
this
.
add_inner
(
type
,
coords
);
this
.
history
.
push
([
coords
]);
}
this
.
history
.
push
(
coords
);
this
.
numTiles
++
;
add_many
(
attachments
)
{
var
all_coords
=
[];
for
(
let
a
of
attachments
)
{
this
.
add_inner
(
a
.
type
,
a
.
coords
);
all_coords
.
push
(
a
.
coords
);
}
this
.
history
.
push
(
all_coords
);
}
remove
(
coords
)
{
...
...
src/tileworker.js
View file @
b1b0721b
...
...
@@ -589,86 +589,86 @@ function removeTile(x, y) {
function
stepForward
(
recursion_level
=
0
)
{
const
ret_list
=
Array
();
const
ret_list
=
Array
();
if
((
simulation_mode
===
'aTAM'
)
||
(
simulation_mode
===
'BlockTAM'
))
{
let
tid
;
if
((
simulation_mode
===
'aTAM'
)
||
(
simulation_mode
===
'BlockTAM'
))
{
let
tid
;
let
loc
;
while
(
tid
===
undefined
)
{
if
(
frontierMap
.
size
===
0
)
{
if
(
simulation_mode
===
'BlockTAM'
)
{
postMessage
({
msg
:
"frontier-empty"
});
if
(
setBlockTAMtemperature
()
===
true
)
{
if
(
recursion_level
<
temperatureList
.
length
)
{
recursion_level
+=
1
;
return
stepForward
(
recursion_level
);
}
}
}
return
null
;
// no more tiles can be added
}
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
const
key
=
frontierList
[
Math
.
floor
(
Math
.
random
()
*
frontierList
.
length
)];
const
sig
=
signatureMap
.
get
(
key
);
const
fitting
=
getFittingTileTypes
(
sig
);
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)];
loc
=
frontierMap
.
get
(
key
);
if
(
tid
===
undefined
)
{
postMessage
({
msg
:
'tid-undefined'
});
frontierMap
.
delete
(
key
);
while
(
tid
===
undefined
)
{
if
(
frontierMap
.
size
===
0
)
{
if
(
simulation_mode
===
'BlockTAM'
)
{
postMessage
({
msg
:
"frontier-empty"
});
if
(
setBlockTAMtemperature
()
===
true
)
{
if
(
recursion_level
<
temperatureList
.
length
)
{
recursion_level
+=
1
;
return
stepForward
(
recursion_level
);
}
}
}
return
null
;
// no more tiles can be added
}
addTile
(
tid
,
loc
[
0
],
loc
[
1
]);
history
.
push
({
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]});
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
const
key
=
frontierList
[
Math
.
floor
(
Math
.
random
()
*
frontierList
.
length
)];
const
sig
=
signatureMap
.
get
(
key
);
const
fitting
=
getFittingTileTypes
(
sig
);
}
else
{
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
()
);
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)];
loc
=
frontierMap
.
get
(
key
);
for
(
let
i
=
0
;
i
<
frontierList
.
length
;
i
++
)
{
let
tid
;
let
loc
;
if
(
tid
===
undefined
)
{
postMessage
({
msg
:
'tid-undefined'
});
frontierMap
.
delete
(
key
);
}
}
while
(
tid
===
undefined
)
{
if
(
i
===
frontierList
.
length
)
{
break
;
// no more tiles can be added
}
addTile
(
tid
,
loc
[
0
],
loc
[
1
]);
history
.
push
([{
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]}]);
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
const
key
=
frontierList
[
i
];
loc
=
frontierMap
.
get
(
key
);
}
else
{
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
var
history_step
=
[];
for
(
let
i
=
0
;
i
<
frontierList
.
length
;
i
++
)
{
let
tid
;
let
loc
;
const
sig
=
signatureMap
.
get
(
key
);
const
fitting
=
getFittingTileTypes
(
sig
);
if
((
fitting
.
length
>
1
)
&&
(
b_report_nondeterminism
===
true
))
{
const
type_list
=
Array
();
for
(
let
t
=
0
;
t
<
fitting
.
length
;
t
++
)
{
type_list
.
push
(
tileTypes
[
fitting
[
t
]].
name
);
}
postMessage
({
msg
:
'nondeterminism'
,
loc
:
loc
,
types
:
type_list
});
}
while
(
tid
===
undefined
)
{
if
(
i
===
frontierList
.
length
)
{
break
;
// no more tiles can be added
}
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)
];
if
(
tid
===
undefined
)
{
postMessage
({
msg
:
'tid-undefined'
});
i
++
;
}
}
if
(
tid
!==
undefined
)
{
addTile
(
tid
,
loc
[
0
],
loc
[
1
],
false
);
history
.
push
({
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]}
);
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
}
const
key
=
frontierList
[
i
];
loc
=
frontierMap
.
get
(
key
);
const
sig
=
signatureMap
.
get
(
key
)
;
const
fitting
=
getFittingTileTypes
(
sig
);
if
((
fitting
.
length
>
1
)
&&
(
b_report_nondeterminism
===
true
))
{
const
type_list
=
Array
();
for
(
let
t
=
0
;
t
<
fitting
.
length
;
t
++
)
{
type_list
.
push
(
tileTypes
[
fitting
[
t
]].
name
);
}
postMessage
({
msg
:
'nondeterminism'
,
loc
:
loc
,
types
:
type_list
});
}
for
(
let
r
=
0
;
r
<
ret_list
.
length
;
r
++
)
{
addNbrsToFrontier
(
ret_list
[
r
][
0
],
ret_list
[
r
][
1
],
ret_list
[
r
][
2
]);
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)];
if
(
tid
===
undefined
)
{
postMessage
({
msg
:
'tid-undefined'
});
i
++
;
}
}
if
(
tid
!==
undefined
)
{
addTile
(
tid
,
loc
[
0
],
loc
[
1
],
false
);
history_step
.
push
({
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]});
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
}
}
history
.
push
(
history_step
);
for
(
let
r
=
0
;
r
<
ret_list
.
length
;
r
++
)
{
addNbrsToFrontier
(
ret_list
[
r
][
0
],
ret_list
[
r
][
1
],
ret_list
[
r
][
2
]);
}
}
// console.log('tile added', history, seedSize);
...
...
@@ -681,7 +681,9 @@ function stepBackward() {
}
const
last
=
history
.
pop
();
removeTile
(
last
.
x
,
last
.
y
);
for
(
coords
of
last
)
{
removeTile
(
coords
.
x
,
coords
.
y
);
}
// console.log('tile removed', history, seedSize);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment