Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed May 2, 2024
1 parent a959142 commit 07ed978
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ const needRefill = computed((): boolean => {
randomTypesConfig.USE_FREQUENCY_BOUNDS;
});
const ignoreSubMatricesOnCross: Ref<boolean> = ref(false);
const ignoreSubMatricesOnCrossValue: Ref<number | undefined> = ref(3);
const useIgnoreSubMatricesBoundaryIndex: Ref<boolean> = ref(false);
const ignoreSubMatricesBoundaryIndex: Ref<number | undefined> = ref(3);
const randomizeTypesConfig = () => {
if (!confirm('Are you sure?')) {
return;
}
const crossValue = ignoreSubMatricesOnCross.value
? ignoreSubMatricesOnCrossValue.value
const crossValue = useIgnoreSubMatricesBoundaryIndex.value
? ignoreSubMatricesBoundaryIndex.value
: undefined;
if (needRefill.value) {
Expand Down Expand Up @@ -63,7 +63,7 @@ const randomizeTypesConfig = () => {
<input type="number" min="0" step="1" v-model="randomTypesConfig.TYPES_COUNT" />
</div>

<div v-show="!ignoreSubMatricesOnCross">
<div v-show="!useIgnoreSubMatricesBoundaryIndex">
<input-header
name="Radius"
tooltip="Radius of each type of particles."
Expand All @@ -80,7 +80,7 @@ const randomizeTypesConfig = () => {
</div>
</div>

<div v-show="!ignoreSubMatricesOnCross">
<div v-show="!useIgnoreSubMatricesBoundaryIndex">
<input-header
name="Frequencies"
tooltip="Ratio of the number of particles that will be generated on refill."
Expand Down Expand Up @@ -133,7 +133,7 @@ const randomizeTypesConfig = () => {
</div>
</div>

<div v-show="!ignoreSubMatricesOnCross">
<div v-show="!useIgnoreSubMatricesBoundaryIndex">
<input-header
name="Links Count"
tooltip="Connection limit map shows the maximum number of links for particles of each type."
Expand Down Expand Up @@ -202,13 +202,13 @@ const randomizeTypesConfig = () => {
</div>
<div>
<flag
title="Ignore submatrices on cross"
v-model="ignoreSubMatricesOnCross"
title="Leave submatrices unchanged on boundary index"
v-model="useIgnoreSubMatricesBoundaryIndex"
/>
<input
v-show="ignoreSubMatricesOnCross"
v-show="useIgnoreSubMatricesBoundaryIndex"
type="number"
v-model="ignoreSubMatricesOnCrossValue"
v-model="ignoreSubMatricesBoundaryIndex"
placeholder="Cross position"
/>
</div>
Expand Down
42 changes: 21 additions & 21 deletions src/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ export const useConfigStore = defineStore("config", () => {
copyFrom: unknown[][],
copyTo: unknown[][],
defaultValue: number,
skipSubMatricesOnCross?: number,
skipSubMatricesBoundaryIndex?: number,
) => {
for (let i=0; i<copyTo.length; ++i) {
for (let j=0; j<copyTo[i].length; ++j) {
if (skipSubMatricesOnCross !== undefined) {
if (i < skipSubMatricesOnCross && j >= skipSubMatricesOnCross) continue;
if (i >= skipSubMatricesOnCross && j < skipSubMatricesOnCross) continue;
if (skipSubMatricesBoundaryIndex !== undefined) {
if (i < skipSubMatricesBoundaryIndex && j >= skipSubMatricesBoundaryIndex) continue;
if (i >= skipSubMatricesBoundaryIndex && j < skipSubMatricesBoundaryIndex) continue;
}

if (copyFrom[i] === undefined) {
Expand All @@ -194,15 +194,15 @@ export const useConfigStore = defineStore("config", () => {
copyFrom: unknown[][][],
copyTo: unknown[][][],
defaultValue: number,
skipSubMatricesOnCross?: number,
skipSubMatricesBoundaryIndex?: number,
) => {
for (let i=0; i<copyTo.length; ++i) {
for (let j=0; j<copyTo[i].length; ++j) {
for (let k=0; k<copyTo[i][j].length; ++k) {
if (
skipSubMatricesOnCross !== undefined &&
!(i < skipSubMatricesOnCross && j < skipSubMatricesOnCross && k < skipSubMatricesOnCross) &&
!(i >= skipSubMatricesOnCross && j >= skipSubMatricesOnCross && k >= skipSubMatricesOnCross)
skipSubMatricesBoundaryIndex !== undefined &&
!(i < skipSubMatricesBoundaryIndex && j < skipSubMatricesBoundaryIndex && k < skipSubMatricesBoundaryIndex) &&
!(i >= skipSubMatricesBoundaryIndex && j >= skipSubMatricesBoundaryIndex && k >= skipSubMatricesBoundaryIndex)
) continue;
if (copyFrom[i] === undefined || copyFrom[i][j] === undefined) {
copyTo[i][j][k] = defaultValue;
Expand All @@ -214,55 +214,55 @@ export const useConfigStore = defineStore("config", () => {
}
}

const randomizeTypesConfig = (skipSubMatricesOnCross?: number) => {
const randomizeTypesConfig = (skipSubMatricesBoundaryIndex?: number) => {
const newConfig = createRandomTypesConfig(randomTypesConfig.value);

if (!randomTypesConfig.value.USE_FREQUENCY_BOUNDS || skipSubMatricesOnCross !== undefined) {
if (!randomTypesConfig.value.USE_FREQUENCY_BOUNDS || skipSubMatricesBoundaryIndex !== undefined) {
copyConfigListValue(typesConfigRaw.FREQUENCIES, newConfig.FREQUENCIES, 1);
}

if (!randomTypesConfig.value.USE_RADIUS_BOUNDS || skipSubMatricesOnCross !== undefined) {
if (!randomTypesConfig.value.USE_RADIUS_BOUNDS || skipSubMatricesBoundaryIndex !== undefined) {
copyConfigListValue(typesConfigRaw.RADIUS, newConfig.RADIUS, 1);
}

if (!randomTypesConfig.value.USE_LINK_BOUNDS || skipSubMatricesOnCross !== undefined) {
if (!randomTypesConfig.value.USE_LINK_BOUNDS || skipSubMatricesBoundaryIndex !== undefined) {
copyConfigListValue(typesConfigRaw.LINKS, newConfig.LINKS, 0);
}

if (!randomTypesConfig.value.USE_GRAVITY_BOUNDS) {
copyConfigMatrixValue(typesConfigRaw.GRAVITY, newConfig.GRAVITY, 0);
} else if (skipSubMatricesOnCross !== undefined) {
copyConfigMatrixValue(typesConfigRaw.GRAVITY, newConfig.GRAVITY, 0, skipSubMatricesOnCross);
} else if (skipSubMatricesBoundaryIndex !== undefined) {
copyConfigMatrixValue(typesConfigRaw.GRAVITY, newConfig.GRAVITY, 0, skipSubMatricesBoundaryIndex);
}

if (!randomTypesConfig.value.USE_LINK_GRAVITY_BOUNDS) {
copyConfigMatrixValue(typesConfigRaw.LINK_GRAVITY, newConfig.LINK_GRAVITY, 0);
} else if (skipSubMatricesOnCross !== undefined) {
copyConfigMatrixValue(typesConfigRaw.LINK_GRAVITY, newConfig.LINK_GRAVITY, 0, skipSubMatricesOnCross);
} else if (skipSubMatricesBoundaryIndex !== undefined) {
copyConfigMatrixValue(typesConfigRaw.LINK_GRAVITY, newConfig.LINK_GRAVITY, 0, skipSubMatricesBoundaryIndex);
}

if (!randomTypesConfig.value.USE_LINK_TYPE_BOUNDS) {
copyConfigMatrixValue(typesConfigRaw.TYPE_LINKS, newConfig.TYPE_LINKS, 0);
} else if (skipSubMatricesOnCross !== undefined) {
copyConfigMatrixValue(typesConfigRaw.TYPE_LINKS, newConfig.TYPE_LINKS, 0, skipSubMatricesOnCross);
} else if (skipSubMatricesBoundaryIndex !== undefined) {
copyConfigMatrixValue(typesConfigRaw.TYPE_LINKS, newConfig.TYPE_LINKS, 0, skipSubMatricesBoundaryIndex);
}

if (!randomTypesConfig.value.USE_LINK_FACTOR_DISTANCE_BOUNDS) {
copyConfigMatrixValue(typesConfigRaw.LINK_FACTOR_DISTANCE, newConfig.LINK_FACTOR_DISTANCE, 1);
copyConfigTensorValue(typesConfigRaw.LINK_FACTOR_DISTANCE_EXTENDED, newConfig.LINK_FACTOR_DISTANCE_EXTENDED, 1);
newConfig.LINK_FACTOR_DISTANCE_USE_EXTENDED = typesConfigRaw.LINK_FACTOR_DISTANCE_USE_EXTENDED;
} else if (skipSubMatricesOnCross !== undefined) {
} else if (skipSubMatricesBoundaryIndex !== undefined) {
copyConfigMatrixValue(
typesConfigRaw.LINK_FACTOR_DISTANCE,
newConfig.LINK_FACTOR_DISTANCE,
1,
skipSubMatricesOnCross,
skipSubMatricesBoundaryIndex,
);
copyConfigTensorValue(
typesConfigRaw.LINK_FACTOR_DISTANCE_EXTENDED,
newConfig.LINK_FACTOR_DISTANCE_EXTENDED,
1,
skipSubMatricesOnCross,
skipSubMatricesBoundaryIndex,
);
}

Expand Down

0 comments on commit 07ed978

Please sign in to comment.