balancing
This commit is contained in:
parent
38d77bcc7c
commit
43198a382b
|
@ -5,7 +5,7 @@ import { shuffle } from './utils'
|
||||||
type HistoryType = { a: number; b: number; op: OperatorType }[]
|
type HistoryType = { a: number; b: number; op: OperatorType }[]
|
||||||
|
|
||||||
export function isHardEnough(num: number): boolean {
|
export function isHardEnough(num: number): boolean {
|
||||||
return num % 100 > 0
|
return num % 100 > 0 && num % 50 > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOperationResultValid(op: Operation): boolean {
|
export function isOperationResultValid(op: Operation): boolean {
|
||||||
|
|
|
@ -12,14 +12,18 @@ function getSharingText(): string {
|
||||||
const endResult = operations[operations.length - 1].result?.value ?? 0
|
const endResult = operations[operations.length - 1].result?.value ?? 0
|
||||||
const success = result.value === endResult
|
const success = result.value === endResult
|
||||||
|
|
||||||
const allSymbols = ['🄰', '🄱', '🄲', '🄳', '🄴', '🄵', '🄶', '🄷', '🄸', '🄹']
|
// const allSymbols = ['𝙰', '𝙱', '𝙲', '𝙳', '𝙴', '𝙵', '𝚅', '𝚆', '𝚇', '𝚈', '𝚉']
|
||||||
|
const abcSymbols = ['𝚊', '𝚋', '𝚌', '𝚍', '𝚎', '𝚏']
|
||||||
|
const xyzSymbols = ['𝚟', '𝚠', '𝚡', '𝚢', '𝚣'].slice(-(operations.length - 1))
|
||||||
|
// const xyzSymbols = ["𝚊'", "𝚋'", "𝚌'", "𝚍'", "𝚎'", "𝚏'"]
|
||||||
|
// const xyzSymbols = ['𝚅', '𝚆', '𝚇', '𝚈', '𝚉']
|
||||||
const squares = ['🟦', '🟩', '🟨', '🟧', '🟥']
|
const squares = ['🟦', '🟩', '🟨', '🟧', '🟥']
|
||||||
|
|
||||||
const lines: string[] = []
|
const lines: string[] = []
|
||||||
for (const op of operations) {
|
for (const op of operations) {
|
||||||
op.left!.symbol = op.left!.symbol ?? allSymbols.shift()
|
op.left!.symbol = op.left!.symbol ?? abcSymbols.shift()
|
||||||
op.right!.symbol = op.right!.symbol ?? allSymbols.shift()
|
op.right!.symbol = op.right!.symbol ?? abcSymbols.shift()
|
||||||
op.result!.symbol = op.result!.symbol ?? allSymbols.shift()
|
op.result!.symbol = op.result!.symbol ?? xyzSymbols.shift()
|
||||||
|
|
||||||
let s = ''
|
let s = ''
|
||||||
switch (op.operator) {
|
switch (op.operator) {
|
||||||
|
@ -43,7 +47,9 @@ function getSharingText(): string {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return `N0mbers #${numberOfGamesSinceStart()} - ${isHardMode.value ? 'Advanced' : 'Normal'}
|
return `N0mbers #${numberOfGamesSinceStart()} - ${
|
||||||
|
isHardMode.value ? 'Advanced' : 'Normal'
|
||||||
|
}
|
||||||
${lines.join('\n')} ${success ? '✔' : '❌'}
|
${lines.join('\n')} ${success ? '✔' : '❌'}
|
||||||
https://n0mbers.scambier.xyz`
|
https://n0mbers.scambier.xyz`
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,10 @@ export const LSK_STATS = 'n0_stats'
|
||||||
|
|
||||||
export const operators = ['+', '-', '*', '/'] as const
|
export const operators = ['+', '-', '*', '/'] as const
|
||||||
|
|
||||||
export const normalPools = {
|
export const pools = {
|
||||||
1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50],
|
|
||||||
2: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
||||||
3: [5, 5, 5, 5, 5, 2, 2, 2, 2, 2],
|
|
||||||
4: [1, 1, 2, 3, 5, 8, 13, 21],
|
|
||||||
} as const
|
|
||||||
|
|
||||||
export const advancedPools = {
|
|
||||||
1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100],
|
1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100],
|
||||||
2: [2, 2, 3, 3, 5, 5, 7, 7, 11, 13, 17, 19, 23],
|
2: [2, 2, 3, 3, 5, 5, 7, 7, 11, 13, 17, 19, 23],
|
||||||
3: [5, 5, 5, 5, 5, 2, 2, 2, 2, 2],
|
3: [1, 1, 2, 3, 5, 8, 13, 21],
|
||||||
4: [1, 1, 2, 3, 5, 8, 13, 21],
|
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export enum GameStateType {
|
export enum GameStateType {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
advancedPools
|
|
||||||
<template>
|
<template>
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<!-- Number to find -->
|
<!-- Number to find -->
|
||||||
|
@ -112,12 +111,7 @@ import {
|
||||||
result,
|
result,
|
||||||
} from '@/composables/game-state'
|
} from '@/composables/game-state'
|
||||||
import * as sharing from '@/composables/sharing'
|
import * as sharing from '@/composables/sharing'
|
||||||
import {
|
import { GameDifficultyType, GameStateType, pools } from '@/globals'
|
||||||
advancedPools,
|
|
||||||
GameDifficultyType,
|
|
||||||
GameStateType,
|
|
||||||
normalPools,
|
|
||||||
} from '@/globals'
|
|
||||||
import { OperatorType, Plaquette } from '@/types'
|
import { OperatorType, Plaquette } from '@/types'
|
||||||
import { randItem, random, randRange, setDailyPRNG, setMathPRNG } from '@/utils'
|
import { randItem, random, randRange, setDailyPRNG, setMathPRNG } from '@/utils'
|
||||||
import IconReload from '~icons/ph/arrow-clockwise'
|
import IconReload from '~icons/ph/arrow-clockwise'
|
||||||
|
@ -129,7 +123,7 @@ const { t } = useI18n() // call `useI18n`, and spread `t` from `useI18n` return
|
||||||
* Computed & refs
|
* Computed & refs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const poolType = ref<1 | 2 | 3 | 4>(1)
|
const poolType = ref<1 | 2 | 3>(1)
|
||||||
const cmpPlaquettes = ref<InstanceType<typeof PlaquettesList> | null>(null)
|
const cmpPlaquettes = ref<InstanceType<typeof PlaquettesList> | null>(null)
|
||||||
|
|
||||||
const isPracticeMode = ref(false)
|
const isPracticeMode = ref(false)
|
||||||
|
@ -199,19 +193,17 @@ function selectOperator(o: OperatorType): void {
|
||||||
function reboot(): void {
|
function reboot(): void {
|
||||||
gameState.value = GameStateType.Playing
|
gameState.value = GameStateType.Playing
|
||||||
|
|
||||||
// The daily number is >= 500 to have a minimum challenge
|
const minValue = 101
|
||||||
const minValue = isHardMode.value && !isPracticeMode.value ? 500 : 101
|
|
||||||
const numPlaquettes = isHardMode.value || isPracticeMode.value ? 6 : 5
|
const numPlaquettes = isHardMode.value || isPracticeMode.value ? 6 : 5
|
||||||
do {
|
do {
|
||||||
// Find a problem
|
// Find a problem
|
||||||
poolType.value = randItem([1, 1, 1, 1, 1, 2, 2, 3, 4, 4])
|
poolType.value = randItem([1, 1, 1, 1, 1, 2, 3])
|
||||||
result.value = randRange(minValue, 1000)
|
result.value = randRange(minValue, 1000)
|
||||||
// Reset Operations list
|
// Reset Operations list
|
||||||
clearOperationsList()
|
clearOperationsList()
|
||||||
|
|
||||||
// Generate result and plaquettes
|
// Generate result and plaquettes
|
||||||
plaquettes.value = []
|
plaquettes.value = []
|
||||||
const pools = isHardMode.value ? advancedPools : normalPools
|
|
||||||
const poolCopy = [...pools[poolType.value]]
|
const poolCopy = [...pools[poolType.value]]
|
||||||
for (let i = 0; i < numPlaquettes; ++i) {
|
for (let i = 0; i < numPlaquettes; ++i) {
|
||||||
const rndItem = Math.floor(random() * poolCopy.length)
|
const rndItem = Math.floor(random() * poolCopy.length)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user