Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
e4aa3254
Commit
e4aa3254
authored
1 year ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Actually write the universe to a file.
Also, prevent unreachable and unleavable sectors.
parent
c0f84de7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xtrn/tw2/bang.js
+78
-0
78 additions, 0 deletions
xtrn/tw2/bang.js
with
78 additions
and
0 deletions
xtrn/tw2/bang.js
+
78
−
0
View file @
e4aa3254
...
...
@@ -44,6 +44,27 @@ function WarpDistance(other)
));
}
function
Closest
(
notsix
)
{
var
j
;
var
md
=
2
;
var
ms
=
-
1
;
var
td
;
for
(
j
in
universe
)
{
if
(
universe
[
j
].
X
===
this
.
X
&&
universe
[
j
].
X
===
this
.
X
&&
universe
[
j
].
X
===
this
.
X
)
continue
;
td
=
this
.
WDistance
(
universe
[
j
]);
if
(
td
<
md
)
{
if
(
notsix
==
false
||
universe
[
j
].
Warps
.
length
<
6
)
{
md
=
td
;
ms
=
j
;
}
}
}
return
ms
;
}
function
CubicSector
(
x
,
y
,
z
)
{
this
.
X
=
x
;
// -1 to 1
...
...
@@ -58,6 +79,7 @@ function CubicSector(x,y,z)
this
.
Al
=
Math
.
acos
(
this
.
Z
/
this
.
R
);
// Altitude from galactic plane (Radians)
this
.
Distance
=
SectorDistance
;
this
.
WDistance
=
WarpDistance
;
this
.
Closest
=
Closest
;
}
function
SphereSector
(
R
,
Al
,
Az
)
...
...
@@ -110,6 +132,8 @@ var totalwarps=0;
for
(
i
in
universe
)
{
universe
[
i
].
Warps
=
[];
for
(
j
in
universe
)
{
if
(
universe
[
i
].
Warps
.
length
>=
6
)
break
;
if
(
i
==
j
)
continue
;
if
(
universe
[
i
].
WDistance
(
universe
[
j
])
<=
wr
)
{
...
...
@@ -118,15 +142,69 @@ for(i in universe) {
}
}
}
// Fix unreachable sectors
var
closest
;
for
(
i
in
universe
)
{
var
found
=
false
;
for
(
j
in
universe
)
{
for
(
k
in
universe
[
j
].
Warps
)
{
if
(
universe
[
j
].
Warps
[
k
]
===
i
)
{
found
=
true
;
break
;
}
}
if
(
found
)
break
;
}
if
(
!
found
)
{
closest
=
universe
[
i
].
Closest
(
true
);
if
(
closest
!==
-
1
)
{
universe
[
closest
].
Warps
.
push
(
i
);
totalwarps
++
;
}
}
}
// Fix unleavable sectors
for
(
i
in
universe
)
{
if
(
universe
[
i
].
Warps
.
length
==
0
)
{
closest
=
universe
[
i
].
Closest
(
false
);
universe
[
i
].
Warps
.
push
(
closest
);
totalwarps
++
;
}
}
log
(
"
Average warps per sector:
"
+
(
totalwarps
/
sectors
));
log
(
"
Total Warps:
"
+
totalwarps
);
// Check for one-way warps
var
oneways
=
0
;
var
mostwarps
=
0
;
for
(
i
in
universe
)
{
for
(
j
in
universe
[
i
].
Warps
)
{
if
(
!
universe
[
universe
[
i
].
Warps
[
j
]].
Warps
.
some
(
function
(
a
,
b
,
c
)
{
return
(
a
==
i
)
}
))
oneways
++
;
}
if
(
universe
[
i
].
Warps
.
length
>
mostwarps
)
mostwarps
=
universe
[
i
].
Warps
.
length
;
}
log
(
"
One-way warps:
"
+
oneways
+
"
(
"
+
parseInt
(
oneways
/
totalwarps
*
100
)
+
"
%)
"
);
log
(
"
Most warps from a sector:
"
+
mostwarps
);
var
f
=
new
File
(
js
.
exec_dir
+
"
/new_sector_map.js
"
);
log
(
"
Writing to
"
+
f
.
name
);
if
(
f
.
open
(
"
w
"
))
{
f
.
writeln
(
"
var sector_map=[
"
);
for
(
i
in
universe
)
{
for
(
j
in
universe
[
i
].
Warps
)
universe
[
i
].
Warps
[
j
]
++
;
f
.
writeln
(
"
\t
{
"
);
f
.
writeln
(
"
\t\t
Sector:
"
+
(
parseInt
(
i
,
10
)
+
1
)
+
"
,
"
);
f
.
writeln
(
"
\t\t
Warps:[
"
+
universe
[
i
].
Warps
.
join
(
'
,
'
)
+
"
],
"
);
f
.
writeln
(
"
\t\t
X:
"
+
universe
[
i
].
X
+
"
, Y:
"
+
universe
[
i
].
Y
+
"
, Z:
"
+
universe
[
i
].
Z
);
f
.
writeln
(
"
\t
},
"
);
}
f
.
writeln
(
'
];
'
);
f
.
close
();
}
else
{
log
(
"
Unable to open file!
"
);
}
log
(
"
Done!
"
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment