aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-03-28 00:15:44 +1100
committerTerry Truong <terry06890@gmail.com>2022-03-28 00:54:28 +1100
commit567b5b605bf57f305197621d0ddc5f2b8c23ed64 (patch)
tree74ce01db58883d3ee660568ecdc37b5555e42989
parente31a74ff9a71e59eb0cd87c13a38c0934965404c (diff)
Make auto-mode move-across/down prioritise higher dCount
-rw-r--r--src/App.vue9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/App.vue b/src/App.vue
index 725f630..295bceb 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -98,7 +98,7 @@ function getReverseAction(action: Action): Action | null {
case 'expand to view':
return 'expand parent bar';
case 'expand parent bar':
- return 'expand';
+ return 'expand to view';
}
}
@@ -430,11 +430,12 @@ export default defineComponent({
switch (action){
case 'move across':
let siblings = node.parent!.children.filter(n => n != node);
- this.setLastFocused(siblings[Math.floor(Math.random() * siblings.length)]);
+ let siblingWeights = siblings.map(n => n.dCount + 1);
+ this.setLastFocused(siblings[randWeightedChoice(siblingWeights)]);
break;
case 'move down':
- let idx = Math.floor(Math.random() * node.children.length);
- this.setLastFocused(node.children[idx]);
+ let childWeights = node.children.map(n => n.dCount + 1);
+ this.setLastFocused(node.children[randWeightedChoice(childWeights)]);
break;
case 'move up':
this.setLastFocused(node.parent!);