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
14a76a22
Commit
14a76a22
authored
Apr 09, 2026
by
Florent Becker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
draft: cancel ok in synctam
parent
b1b0721b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
108 deletions
+130
-108
simulator.mjs
src/simulator.mjs
+31
-27
tileworker.js
src/tileworker.js
+96
-80
tileworker_3D.js
src/tileworker_3D.js
+3
-1
No files found.
src/simulator.mjs
View file @
14a76a22
...
@@ -221,14 +221,19 @@ export class Simulator {
...
@@ -221,14 +221,19 @@ export class Simulator {
return
true
;
return
true
;
}
}
handleWorkerMessage
(
e
)
{
handleWorkerMessage
(
e
)
{
if
(
e
.
data
.
msg
===
"tile-added"
)
{
Logger
.
log
(
Logger
.
INFO
,
"got message"
+
e
.
data
.
msg
);
const
type
=
this
.
tileset
.
getTileTypeById
(
e
.
data
.
tid
);
if
(
e
.
data
.
msg
===
"tile-group-added"
)
{
const
coords
=
new
Vector2D
(
e
.
data
.
x
,
e
.
data
.
y
);
let
attachments
=
[];
this
.
tileBlockAtlas
.
add_one
(
type
,
coords
);
for
(
let
attachment
of
e
.
data
.
tiles
)
{
this
.
renderUpdate
=
true
;
const
type
=
this
.
tileset
.
getTileTypeById
(
attachment
.
tid
);
}
else
if
(
e
.
data
.
msg
===
"tiles-added"
)
{
const
coords
=
new
Vector2D
(
attachment
.
x
,
attachment
.
y
);
const
fastForwardBuffer
=
e
.
data
.
buffer
;
attachments
.
push
({
type
:
type
,
coords
:
coords
});
}
this
.
tileBlockAtlas
.
add_many
(
attachments
);
this
.
renderUpdate
=
true
;
}
else
if
(
e
.
data
.
msg
===
"tiles-added"
)
{
const
fastForwardBuffer
=
e
.
data
.
buffer
;
const
added
=
e
.
data
.
added
*
3
;
const
added
=
e
.
data
.
added
*
3
;
for
(
let
i
=
0
;
i
<
added
;
i
+=
3
)
{
for
(
let
i
=
0
;
i
<
added
;
i
+=
3
)
{
const
type
=
this
.
tileset
.
getTileTypeById
(
fastForwardBuffer
[
i
]);
const
type
=
this
.
tileset
.
getTileTypeById
(
fastForwardBuffer
[
i
]);
...
@@ -295,14 +300,15 @@ export class Simulator {
...
@@ -295,14 +300,15 @@ export class Simulator {
}
else
{
}
else
{
Logger
.
log
(
Logger
.
INFO
,
`no glues currently have blockers`
);
Logger
.
log
(
Logger
.
INFO
,
`no glues currently have blockers`
);
}
}
}
else
{
Logger
.
log
(
Logger
.
WARNING
,
`unknown message from worker:
${
e
.
data
.
msg
}
`
);
}
}
}
}
stepForward
()
{
stepForward
()
{
let
speed
=
this
.
ffSpeedInput
.
value
;
let
speed
=
this
.
ffSpeedInput
.
value
;
console
.
log
(
speed
);
this
.
tileWorker
.
postMessage
({
msg
:
"step-forward"
,
repeat
:
speed
});
this
.
tileWorker
.
postMessage
({
msg
:
"step-forward"
,
repeat
:
speed
});
}
}
stepBackward
()
{
stepBackward
()
{
this
.
tileWorker
.
postMessage
({
msg
:
"step-backward"
});
this
.
tileWorker
.
postMessage
({
msg
:
"step-backward"
});
...
@@ -507,20 +513,16 @@ export class Simulator {
...
@@ -507,20 +513,16 @@ export class Simulator {
}
else
if
(
line
.
toLowerCase
().
startsWith
(
"temperature"
))
{
}
else
if
(
line
.
toLowerCase
().
startsWith
(
"temperature"
))
{
temp
=
parseInt
(
line
.
split
(
"="
)[
1
].
trim
());
temp
=
parseInt
(
line
.
split
(
"="
)[
1
].
trim
());
}
else
if
(
line
.
length
>
0
)
{
}
else
if
(
line
.
length
>
0
)
{
const
data
=
line
.
split
(
" "
);
const
data
=
line
.
split
(
" "
);
if
(
data
.
length
>=
3
)
{
if
(
data
.
length
>=
3
&&
data
[
0
]
!=
"#"
)
{
const
name
=
data
[
0
].
trim
();
const
name
=
data
[
0
].
trim
();
const
x
=
parseInt
(
data
[
1
].
trim
());
const
x
=
parseInt
(
data
[
1
].
trim
());
const
y
=
parseInt
(
data
[
2
].
trim
());
const
y
=
parseInt
(
data
[
2
].
trim
());
const
type
=
this
.
tileset
.
getTileTypeByName
(
name
);
const
type
=
this
.
tileset
.
getTileTypeByName
(
name
);
const
coords
=
new
Vector2D
(
x
,
y
);
const
coords
=
new
Vector2D
(
x
,
y
);
this
.
seedTiles
.
push
({
type
:
type
,
coords
:
coords
});
// this.addTile(type, coords);
}
// this.tileWorker.postMessage({ msg: 'add-tile', tid: type.id, x: coords.x, y: coords.y});
this
.
tileBlockAtlas
.
add
(
type
,
coords
);
this
.
seedTiles
.
push
({
type
:
type
,
coords
:
coords
});
}
}
}
}
}
...
@@ -530,7 +532,9 @@ export class Simulator {
...
@@ -530,7 +532,9 @@ export class Simulator {
this
.
tileWorker
.
postMessage
({
msg
:
'mode-SyncTAM'
});
this
.
tileWorker
.
postMessage
({
msg
:
'mode-SyncTAM'
});
}
}
this
.
tileBlockAtlas
.
add_many
(
this
.
seedTiles
);
console
.
log
(
this
.
seedTiles
.
length
);
console
.
log
(
this
.
seedTiles
.
length
);
if
(
this
.
seedTiles
.
length
==
0
)
{
if
(
this
.
seedTiles
.
length
==
0
)
{
let
ttypes
=
this
.
tileset
.
tileTypes
;
let
ttypes
=
this
.
tileset
.
tileTypes
;
let
tile
=
ttypes
[
Math
.
floor
(
Math
.
random
()
*
ttypes
.
length
)];
let
tile
=
ttypes
[
Math
.
floor
(
Math
.
random
()
*
ttypes
.
length
)];
...
...
src/tileworker.js
View file @
14a76a22
...
@@ -59,20 +59,16 @@ onmessage = function(e) {
...
@@ -59,20 +59,16 @@ onmessage = function(e) {
precomputeSignatures
();
precomputeSignatures
();
}
}
}
else
if
(
e
.
data
.
msg
===
"step-forward"
)
{
}
else
if
(
e
.
data
.
msg
===
"step-forward"
)
{
let
n_
tile
s
=
e
.
data
.
repeat
||
1
;
let
n_
step
s
=
e
.
data
.
repeat
||
1
;
for
(
i
=
0
;
i
<
n_
tile
s
;
i
++
)
{
for
(
i
=
0
;
i
<
n_
step
s
;
i
++
)
{
const
added_list
=
stepForward
();
const
added_list
=
stepForward
();
if
(
added_list
===
null
)
{
if
(
added_list
===
[]
)
{
postMessage
({
msg
:
"frontier-empty"
});
postMessage
({
msg
:
"frontier-empty"
});
}
else
{
}
else
{
for
(
let
i
=
0
;
i
<
added_list
.
length
;
i
++
)
{
postMessage
({
postMessage
({
msg
:
"tile-group-added"
,
msg
:
"tile-added"
,
tiles
:
added_list
tid
:
added_list
[
i
][
0
],
});
x
:
added_list
[
i
][
1
],
y
:
added_list
[
i
][
2
]
});
}
}
}
}
}
}
else
if
(
e
.
data
.
msg
===
"step-backward"
)
{
}
else
if
(
e
.
data
.
msg
===
"step-backward"
)
{
...
@@ -100,7 +96,7 @@ onmessage = function(e) {
...
@@ -100,7 +96,7 @@ onmessage = function(e) {
clear
(
e
.
data
.
temperature
);
clear
(
e
.
data
.
temperature
);
}
else
if
(
e
.
data
.
msg
===
'set-seed'
)
{
}
else
if
(
e
.
data
.
msg
===
'set-seed'
)
{
for
(
const
tile
of
e
.
data
.
seed
)
{
for
(
const
tile
of
e
.
data
.
seed
)
{
addTile
(
tile
.
type
.
id
,
tile
.
coords
.
x
,
tile
.
coords
.
y
,
b_add_to_frontier
=
true
,
b_seed_tile
=
true
);
addTile
(
tile
.
type
.
id
,
tile
.
coords
.
x
,
tile
.
coords
.
y
,
b_add_to_frontier
=
true
,
b_seed_tile
=
true
);
}
}
seedSize
=
e
.
data
.
seed
.
length
;
seedSize
=
e
.
data
.
seed
.
length
;
}
else
if
(
e
.
data
.
msg
===
'set-temperature'
)
{
}
else
if
(
e
.
data
.
msg
===
'set-temperature'
)
{
...
@@ -587,92 +583,112 @@ function removeTile(x, y) {
...
@@ -587,92 +583,112 @@ function removeTile(x, y) {
}
}
}
}
function
stepForward
(
recursion_level
=
0
)
{
function
blockTam_stepForward
(
recursion_level
)
{
const
ret_list
=
Array
();
const
ret_list
=
Array
();
let
tid
;
if
((
simulation_mode
===
'aTAM'
)
||
(
simulation_mode
===
'BlockTAM'
))
{
let
loc
;
let
tid
;
let
loc
;
while
(
tid
===
undefined
)
{
if
(
frontierMap
.
size
===
0
)
{
while
(
tid
===
undefined
)
{
if
(
simulation_mode
===
'BlockTAM'
)
{
if
(
frontierMap
.
size
===
0
)
{
postMessage
({
msg
:
"frontier-empty"
});
if
(
simulation_mode
===
'BlockTAM'
)
{
if
(
setBlockTAMtemperature
()
===
true
)
{
postMessage
({
msg
:
"frontier-empty"
});
if
(
recursion_level
<
temperatureList
.
length
)
{
if
(
setBlockTAMtemperature
()
===
true
)
{
recursion_level
+=
1
;
if
(
recursion_level
<
temperatureList
.
length
)
{
return
blockTame_stepForward
(
recursion_level
);
recursion_level
+=
1
;
return
stepForward
(
recursion_level
);
}
}
}
}
}
return
null
;
// no more tiles can be added
}
}
return
null
;
// no more tiles can be added
}
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
const
key
=
frontierList
[
Math
.
floor
(
Math
.
random
()
*
frontierList
.
length
)];
const
key
=
frontierList
[
Math
.
floor
(
Math
.
random
()
*
frontierList
.
length
)];
const
sig
=
signatureMap
.
get
(
key
);
const
sig
=
signatureMap
.
get
(
key
);
const
fitting
=
getFittingTileTypes
(
sig
);
const
fitting
=
getFittingTileTypes
(
sig
);
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)];
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)];
loc
=
frontierMap
.
get
(
key
);
loc
=
frontierMap
.
get
(
key
);
if
(
tid
===
undefined
)
{
if
(
tid
===
undefined
)
{
postMessage
({
msg
:
'tid-undefined'
});
postMessage
({
msg
:
'tid-undefined'
});
frontierMap
.
delete
(
key
);
frontierMap
.
delete
(
key
);
}
}
}
}
addTile
(
tid
,
loc
[
0
],
loc
[
1
]);
addTile
(
tid
,
loc
[
0
],
loc
[
1
]);
history
.
push
([{
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]}]);
let
attachment
=
{
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]};
ret_list
.
push
([
tid
,
loc
[
0
],
loc
[
1
]]);
history
.
push
([
attachment
]);
ret_list
.
push
([
attachment
]);
}
else
{
return
ret_list
;
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
}
var
history_step
=
[];
for
(
let
i
=
0
;
i
<
frontierList
.
length
;
i
++
)
{
let
tid
;
let
loc
;
while
(
tid
===
undefined
)
{
if
(
i
===
frontierList
.
length
)
{
break
;
// no more tiles can be added
}
const
key
=
frontierList
[
i
];
function
attachmentAt
(
key
,
b_add_to_frontier
)
{
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
});
}
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
});
}
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)];
const
tid
=
fitting
[
Math
.
floor
(
Math
.
random
()
*
fitting
.
length
)];
if
(
tid
===
undefined
)
{
const
loc
=
frontierMap
.
get
(
key
);
postMessage
({
msg
:
'tid-undefined'
});
i
++
;
if
(
tid
===
undefined
)
{
}
postMessage
({
msg
:
'tid-undefined'
});
}
frontierMap
.
delete
(
key
);
if
(
tid
!==
undefined
)
{
return
null
;
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
]]);
addTile
(
tid
,
loc
[
0
],
loc
[
1
],
b_add_to_frontier
=
b_add_to_frontier
);
return
{
tid
:
tid
,
x
:
loc
[
0
],
y
:
loc
[
1
]};
}
function
stepForward
()
{
if
(
simulation_mode
===
'blockTAM'
)
{
return
blockTAM_stepForward
(
0
);
}
if
(
simulation_mode
===
'aTAM'
)
{
let
attachment
=
null
;
while
(
attachment
===
null
)
{
if
(
frontierMap
.
size
===
0
)
{
return
[];
}
}
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
const
key
=
frontierList
[
Math
.
floor
(
Math
.
random
()
*
frontierList
.
length
)];
attachment
=
attachmentAt
(
key
,
true
);
}
}
history
.
push
(
history_step
);
for
(
let
r
=
0
;
r
<
ret_list
.
length
;
r
++
)
{
history
.
push
([
attachment
]);
addNbrsToFrontier
(
ret_list
[
r
][
0
],
ret_list
[
r
][
1
],
ret_list
[
r
][
2
])
;
return
[
attachment
]
;
}
}
}
// console.log('tile added', history, seedSize);
if
(
simulation_mode
===
'SyncTAM'
)
{
const
frontierList
=
Array
.
from
(
frontierMap
.
keys
());
let
attachments
=
[];
return
ret_list
;
for
(
let
key
of
frontierList
)
{
let
attachment
=
attachmentAt
(
key
,
false
);
if
(
attachment
!==
null
)
{
attachments
.
push
(
attachment
);
}
}
if
(
attachments
.
length
>
0
)
history
.
push
(
attachments
);
for
(
let
a
of
attachments
)
{
addNbrsToFrontier
(
a
.
tid
,
a
.
x
,
a
.
y
)
}
return
attachments
;
}
}
}
function
stepBackward
()
{
function
stepBackward
()
{
...
...
src/tileworker_3D.js
View file @
14a76a22
...
@@ -52,11 +52,13 @@ onmessage = function(e) {
...
@@ -52,11 +52,13 @@ onmessage = function(e) {
}
else
{
}
else
{
for
(
let
i
=
0
;
i
<
added_list
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
added_list
.
length
;
i
++
)
{
postMessage
({
postMessage
({
msg
:
"tile-added"
,
msg
:
"tile-group-added"
,
tiles
:
[{
tid
:
added_list
[
i
][
0
],
tid
:
added_list
[
i
][
0
],
x
:
added_list
[
i
][
1
],
x
:
added_list
[
i
][
1
],
y
:
added_list
[
i
][
2
],
y
:
added_list
[
i
][
2
],
z
:
added_list
[
i
][
3
]
z
:
added_list
[
i
][
3
]
}]
});
});
}
}
}
}
...
...
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