Tweaked difficulty

This commit is contained in:
Simon Cambier 2022-03-23 21:36:44 +01:00
parent bbb7460723
commit 38d77bcc7c
3 changed files with 23 additions and 16 deletions

View File

@ -117,7 +117,7 @@ export function isSolvable(result: number, plaquettes: number[]): boolean {
histories.push(history)
if (!found) {
found = true
console.log(`1e solution trouvée en ${Date.now() - start}ms`)
console.log(`1st solution found in ${Date.now() - start}ms`)
}
return
}
@ -138,12 +138,12 @@ export function isSolvable(result: number, plaquettes: number[]): boolean {
loopOperations(plaquettes, [])
if (found) {
console.log(
`Réussite : ${Date.now() - start}ms et ${numberOfIterations} iterations`,
`Success : ${Date.now() - start}ms and ${numberOfIterations} iterations`,
)
}
else {
console.log(
`Echec : ${Date.now() - start}ms et ${numberOfIterations} iterations`,
`Failure : ${Date.now() - start}ms and ${numberOfIterations} iterations`,
)
}

View File

@ -7,10 +7,18 @@ export const LSK_STATS = 'n0_stats'
export const operators = ['+', '-', '*', '/'] as const
export const pools = {
export const normalPools = {
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],
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],
4: [1, 1, 2, 3, 5, 8, 13, 21],
} as const
export enum GameStateType {

View File

@ -1,3 +1,4 @@
advancedPools
<template>
<div class="w-full">
<!-- Number to find -->
@ -111,17 +112,14 @@ import {
result,
} from '@/composables/game-state'
import * as sharing from '@/composables/sharing'
import { hasPlayed } from '@/composables/statistics'
import { GameDifficultyType, GameStateType, pools } from '@/globals'
import { OperatorType, Plaquette } from '@/types'
import {
getCurrentSessionKey,
randItem,
random,
randRange,
setDailyPRNG,
setMathPRNG,
} from '@/utils'
advancedPools,
GameDifficultyType,
GameStateType,
normalPools,
} from '@/globals'
import { OperatorType, Plaquette } from '@/types'
import { randItem, random, randRange, setDailyPRNG, setMathPRNG } from '@/utils'
import IconReload from '~icons/ph/arrow-clockwise'
import IconShare from '~icons/ph/share-network'
@ -131,7 +129,7 @@ const { t } = useI18n() // call `useI18n`, and spread `t` from `useI18n` return
* Computed & refs
*/
const poolType = ref<1 | 2 | 3>(1)
const poolType = ref<1 | 2 | 3 | 4>(1)
const cmpPlaquettes = ref<InstanceType<typeof PlaquettesList> | null>(null)
const isPracticeMode = ref(false)
@ -206,13 +204,14 @@ function reboot(): void {
const numPlaquettes = isHardMode.value || isPracticeMode.value ? 6 : 5
do {
// Find a problem
poolType.value = randItem([1, 1, 1, 1, 1, 2, 3])
poolType.value = randItem([1, 1, 1, 1, 1, 2, 2, 3, 4, 4])
result.value = randRange(minValue, 1000)
// Reset Operations list
clearOperationsList()
// Generate result and plaquettes
plaquettes.value = []
const pools = isHardMode.value ? advancedPools : normalPools
const poolCopy = [...pools[poolType.value]]
for (let i = 0; i < numPlaquettes; ++i) {
const rndItem = Math.floor(random() * poolCopy.length)