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) histories.push(history)
if (!found) { if (!found) {
found = true found = true
console.log(`1e solution trouvée en ${Date.now() - start}ms`) console.log(`1st solution found in ${Date.now() - start}ms`)
} }
return return
} }
@ -138,12 +138,12 @@ export function isSolvable(result: number, plaquettes: number[]): boolean {
loopOperations(plaquettes, []) loopOperations(plaquettes, [])
if (found) { if (found) {
console.log( console.log(
`Réussite : ${Date.now() - start}ms et ${numberOfIterations} iterations`, `Success : ${Date.now() - start}ms and ${numberOfIterations} iterations`,
) )
} }
else { else {
console.log( 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 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], 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: [5, 5, 5, 5, 5, 2, 2, 2, 2, 2],
4: [1, 1, 2, 3, 5, 8, 13, 21],
} as const } as const
export enum GameStateType { export enum GameStateType {

View File

@ -1,3 +1,4 @@
advancedPools
<template> <template>
<div class="w-full"> <div class="w-full">
<!-- Number to find --> <!-- Number to find -->
@ -111,17 +112,14 @@ import {
result, result,
} from '@/composables/game-state' } from '@/composables/game-state'
import * as sharing from '@/composables/sharing' import * as sharing from '@/composables/sharing'
import { hasPlayed } from '@/composables/statistics'
import { GameDifficultyType, GameStateType, pools } from '@/globals'
import { OperatorType, Plaquette } from '@/types'
import { import {
getCurrentSessionKey, advancedPools,
randItem, GameDifficultyType,
random, GameStateType,
randRange, normalPools,
setDailyPRNG, } from '@/globals'
setMathPRNG, import { OperatorType, Plaquette } from '@/types'
} from '@/utils' import { randItem, random, randRange, setDailyPRNG, setMathPRNG } from '@/utils'
import IconReload from '~icons/ph/arrow-clockwise' import IconReload from '~icons/ph/arrow-clockwise'
import IconShare from '~icons/ph/share-network' import IconShare from '~icons/ph/share-network'
@ -131,7 +129,7 @@ const { t } = useI18n() // call `useI18n`, and spread `t` from `useI18n` return
* Computed & refs * 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 cmpPlaquettes = ref<InstanceType<typeof PlaquettesList> | null>(null)
const isPracticeMode = ref(false) const isPracticeMode = ref(false)
@ -206,13 +204,14 @@ function reboot(): void {
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, 3]) poolType.value = randItem([1, 1, 1, 1, 1, 2, 2, 3, 4, 4])
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)