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
Show 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,6 +312,7 @@
...
@@ -312,6 +312,7 @@
<div
class=
"w3-bar-item bar-divider"
></div>
<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=
"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=
"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-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>
<button
id=
"zoom-in-button"
class=
"w3-bar-item w3-button w3-right"
><span
class=
"material-icons"
>
zoom_in
</span></button>
</div>
</div>
...
...
src/simulator.mjs
View file @
b1b0721b
...
@@ -120,12 +120,13 @@ export class Simulator {
...
@@ -120,12 +120,13 @@ export class Simulator {
if
(
keepSeed
)
{
if
(
keepSeed
)
{
this
.
tileWorker
.
postMessage
({
msg
:
'set-seed'
,
seed
:
this
.
seedTiles
});
this
.
tileWorker
.
postMessage
({
msg
:
'set-seed'
,
seed
:
this
.
seedTiles
});
this
.
tileBlockAtlas
.
add_many
(
this
.
seedTiles
);
for
(
const
tile
of
this
.
seedTiles
)
{
//
for (const tile of this.seedTiles) {
// this.addTile(tile.type, tile.coords);
//
// 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.tileWorker.postMessage({ msg: 'add-tile', tid: tile.type.id, x: tile.coords.x, y: tile.coords.y});
this
.
tileBlockAtlas
.
add
(
tile
.
type
,
tile
.
coords
);
//
this.tileBlockAtlas.add(tile.type, tile.coords);
}
//
}
Logger
.
log
(
Logger
.
INFO
,
"reset system to seed"
);
Logger
.
log
(
Logger
.
INFO
,
"reset system to seed"
);
...
@@ -224,7 +225,7 @@ export class Simulator {
...
@@ -224,7 +225,7 @@ export class Simulator {
if
(
e
.
data
.
msg
===
"tile-added"
)
{
if
(
e
.
data
.
msg
===
"tile-added"
)
{
const
type
=
this
.
tileset
.
getTileTypeById
(
e
.
data
.
tid
);
const
type
=
this
.
tileset
.
getTileTypeById
(
e
.
data
.
tid
);
const
coords
=
new
Vector2D
(
e
.
data
.
x
,
e
.
data
.
y
);
const
coords
=
new
Vector2D
(
e
.
data
.
x
,
e
.
data
.
y
);
this
.
tileBlockAtlas
.
add
(
type
,
coords
);
this
.
tileBlockAtlas
.
add
_one
(
type
,
coords
);
this
.
renderUpdate
=
true
;
this
.
renderUpdate
=
true
;
}
else
if
(
e
.
data
.
msg
===
"tiles-added"
)
{
}
else
if
(
e
.
data
.
msg
===
"tiles-added"
)
{
const
fastForwardBuffer
=
e
.
data
.
buffer
;
const
fastForwardBuffer
=
e
.
data
.
buffer
;
...
@@ -383,7 +384,8 @@ export class Simulator {
...
@@ -383,7 +384,8 @@ export class Simulator {
}
}
this
.
selectedTile
.
render
();
this
.
selectedTile
.
render
();
let
infoStr
=
`Simulator:
${
this
.
tileBlockAtlas
.
numTiles
}
tiles`
;
let
time
=
this
.
tileBlockAtlas
.
history
.
length
;
let
infoStr
=
`Simulator:
${
this
.
tileBlockAtlas
.
numTiles
}
tiles, Simulation time:
${
time
}
`
;
if
(
this
.
mouseoverQuad
.
visible
)
{
if
(
this
.
mouseoverQuad
.
visible
)
{
infoStr
+=
` --- Mouse Coordinates: (
${
this
.
mouseoverQuad
.
position
.
x
}
,
${
this
.
mouseoverQuad
.
position
.
y
}
)`
infoStr
+=
` --- Mouse Coordinates: (
${
this
.
mouseoverQuad
.
position
.
x
}
,
${
this
.
mouseoverQuad
.
position
.
y
}
)`
}
}
...
@@ -527,8 +529,18 @@ export class Simulator {
...
@@ -527,8 +529,18 @@ export class Simulator {
}
else
if
(
this
.
simulation_mode
===
'SyncTAM'
)
{
}
else
if
(
this
.
simulation_mode
===
'SyncTAM'
)
{
this
.
tileWorker
.
postMessage
({
msg
:
'mode-SyncTAM'
});
this
.
tileWorker
.
postMessage
({
msg
:
'mode-SyncTAM'
});
}
}
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
});
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
}
`
);
Logger
.
log
(
Logger
.
INFO
,
`loaded
${
this
.
simulation_mode
}
system file "
${
data
.
tdp
.
name
}
" with a seed of size
${
this
.
seedTiles
.
length
}
`
);
// Determine if we're in v1 or v2. V1 should use this.blockerDict and v2 should use this.tileset.tileGlueBlockers
// Determine if we're in v1 or v2. V1 should use this.blockerDict and v2 should use this.tileset.tileGlueBlockers
...
...
src/tileblock.mjs
View file @
b1b0721b
...
@@ -246,11 +246,15 @@ export class TileBlockAtlas {
...
@@ -246,11 +246,15 @@ export class TileBlockAtlas {
}
}
stepBackward
()
{
stepBackward
()
{
const
coords
=
this
.
history
.
pop
();
const
attachments
=
this
.
history
.
pop
();
return
this
.
remove
(
coords
);
for
(
let
coords
of
attachments
)
{
let
success
=
this
.
remove
(
coords
);
if
(
!
success
)
return
false
;
}
return
true
;
}
}
add
(
type
,
coords
)
{
add
_inner
(
type
,
coords
)
{
const
blockIndex
=
this
.
getBlockIndex
(
coords
);
const
blockIndex
=
this
.
getBlockIndex
(
coords
);
if
(
!
this
.
tileBlocks
.
has
(
blockIndex
.
y
))
if
(
!
this
.
tileBlocks
.
has
(
blockIndex
.
y
))
...
@@ -270,10 +274,23 @@ export class TileBlockAtlas {
...
@@ -270,10 +274,23 @@ export class TileBlockAtlas {
tileBlock
.
add
(
type
,
coords
);
tileBlock
.
add
(
type
,
coords
);
this
.
history
.
push
(
coords
);
this
.
numTiles
++
;
this
.
numTiles
++
;
}
}
add_one
(
type
,
coords
)
{
this
.
add_inner
(
type
,
coords
);
this
.
history
.
push
([
coords
]);
}
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
)
{
remove
(
coords
)
{
const
blockIndex
=
this
.
getBlockIndex
(
coords
);
const
blockIndex
=
this
.
getBlockIndex
(
coords
);
...
...
src/tileworker.js
View file @
b1b0721b
...
@@ -624,12 +624,12 @@ function stepForward(recursion_level = 0) {
...
@@ -624,12 +624,12 @@ function stepForward(recursion_level = 0) {
}
}
addTile
(
tid
,
loc
[
0
],
loc
[
1
]);
addTile
(
tid
,
loc
[
0
],
loc
[
1
]);
history
.
push
({
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]}
);
history
.
push
([{
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]}]
);
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
}
else
{
}
else
{
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
var
history_step
=
[];
for
(
let
i
=
0
;
i
<
frontierList
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
frontierList
.
length
;
i
++
)
{
let
tid
;
let
tid
;
let
loc
;
let
loc
;
...
@@ -660,11 +660,11 @@ function stepForward(recursion_level = 0) {
...
@@ -660,11 +660,11 @@ function stepForward(recursion_level = 0) {
}
}
if
(
tid
!==
undefined
)
{
if
(
tid
!==
undefined
)
{
addTile
(
tid
,
loc
[
0
],
loc
[
1
],
false
);
addTile
(
tid
,
loc
[
0
],
loc
[
1
],
false
);
history
.
push
({
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]});
history_step
.
push
({
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]});
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
}
}
}
}
history
.
push
(
history_step
);
for
(
let
r
=
0
;
r
<
ret_list
.
length
;
r
++
)
{
for
(
let
r
=
0
;
r
<
ret_list
.
length
;
r
++
)
{
addNbrsToFrontier
(
ret_list
[
r
][
0
],
ret_list
[
r
][
1
],
ret_list
[
r
][
2
]);
addNbrsToFrontier
(
ret_list
[
r
][
0
],
ret_list
[
r
][
1
],
ret_list
[
r
][
2
]);
}
}
...
@@ -681,7 +681,9 @@ function stepBackward() {
...
@@ -681,7 +681,9 @@ function stepBackward() {
}
}
const
last
=
history
.
pop
();
const
last
=
history
.
pop
();
removeTile
(
last
.
x
,
last
.
y
);
for
(
coords
of
last
)
{
removeTile
(
coords
.
x
,
coords
.
y
);
}
// console.log('tile removed', history, seedSize);
// 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