How to use closeToMin method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

math.ts

Source:math.ts Github

copy

Full Screen

1import type { Has } from '@principia/base/Has'2import * as I from '@principia/base/IO'3import { Random } from '@principia/base/Random'4/** @internal */5export const MIN_VALUE_32 = 2 ** -126 * 2 ** -236/** @internal */7export const MAX_VALUE_32 = 2 ** 127 * (1 + (2 ** 23 - 1) / 2 ** 23)8/** @internal */9export const EPSILON_32 = 2 ** -2310/** @internal */11const INDEX_POSITIVE_INFINITY_32 = 2139095040 // floatToIndex(MAX_VALUE_32) + 1;12/** @internal */13const INDEX_NEGATIVE_INFINITY_32 = -2139095041 // floatToIndex(-MAX_VALUE_32) - 114export function safeFloatToIndex(f: number, label: string): I.IO<unknown, never, number> {15 const conversionTrick = 'you can convert any double to a 32-bit float by using `new Float32Array([myDouble])[0]`'16 const errorMessage = 'fc.floatNext constraints.' + label + ' must be a 32-bit float - ' + conversionTrick17 if (Number.isNaN(f) || (Number.isFinite(f) && (f < -MAX_VALUE_32 || f > MAX_VALUE_32))) {18 return I.halt(new Error(errorMessage))19 }20 const index = floatToIndex(f)21 if (!Number.isInteger(index)) {22 return I.halt(new Error(errorMessage))23 }24 return I.succeed(index)25}26export function decomposeFloat(f: number): { exponent: number, significand: number } {27 // 1 => significand 0b1 - exponent 1 (will be preferred)28 // => significand 0b0.1 - exponent 229 const maxSignificand = 1 + (2 ** 23 - 1) / 2 ** 2330 for (let exponent = -126; exponent !== 128; ++exponent) {31 const powExponent = 2 ** exponent32 const maxForExponent = maxSignificand * powExponent33 if (Math.abs(f) <= maxForExponent) {34 return { exponent, significand: f / powExponent }35 }36 }37 return { exponent: Number.NaN, significand: Number.NaN }38}39export function floatToIndex(f: number): number {40 if (f === Number.POSITIVE_INFINITY) {41 return INDEX_POSITIVE_INFINITY_3242 }43 if (f === Number.NEGATIVE_INFINITY) {44 return INDEX_NEGATIVE_INFINITY_3245 }46 const { exponent, significand } = decomposeFloat(f)47 if (Number.isNaN(exponent) || Number.isNaN(significand) || !Number.isInteger(significand * 0x800000)) {48 return Number.NaN49 }50 if (f > 0 || (f === 0 && 1 / f === Number.POSITIVE_INFINITY)) {51 return indexInFloatFromDecomp(exponent, significand)52 } else {53 return -indexInFloatFromDecomp(exponent, -significand) - 154 }55}56/** @internal */57export function indexInFloatFromDecomp(exponent: number, significand: number) {58 // WARNING: significand >= 059 // By construct of significand in decomposeFloat,60 // significand is always max-ed.61 // The float close to zero are the only one having a significand <1, they also have an exponent of -126.62 // They are in range: [2**(-126) * 2**(-23), 2**(-126) * (2 - 2 ** 23)]63 // In other words there are 2**24 elements in that range if we include zero.64 // All other ranges (other exponents) have a length of 2**23 elements.65 if (exponent === -126) {66 return significand * 0x800000 // significand * 2**2367 }68 // Offset due to exp = -126 + Offset of previous exp (excl. -126) + Offset in current exp69 // 2**24 + (exponent - (-126) -1) * 2**23 + (significand - 1) * 2**2370 return (exponent + 127) * 0x800000 + (significand - 1) * 0x80000071}72/**73 * Compute the 32-bit floating point number corresponding to the provided indexes74 *75 * @param n - index of the float76 *77 * @internal78 */79export function indexToFloat(index: number): number {80 if (index < 0) {81 return -indexToFloat(-index - 1)82 }83 if (index === INDEX_POSITIVE_INFINITY_32) {84 return Number.POSITIVE_INFINITY85 }86 if (index < 0x1000000) {87 // The first 2**24 elements correspond to values having88 // exponent = -126 and significand = index * 2**(-23)89 return index * 2 ** -14990 }91 const postIndex = index - 0x100000092 // Math.floor(postIndex / 0x800000) = Math.floor(postIndex / 2**23) = (postIndex >> 23)93 const exponent = -125 + (postIndex >> 23)94 // (postIndex % 0x800000) / 0x800000 = (postIndex & 0x7fffff) / 0x80000095 const significand = 1 + (postIndex & 0x7fffff) / 0x80000096 return significand * 2 ** exponent97}98/** @internal */99export type ArrayInt64 = { sign: 1 | -1, data: [number, number] }100/** @internal */101export const Zero64: ArrayInt64 = { sign: 1, data: [0, 0] }102/** @internal */103export const Unit64: ArrayInt64 = { sign: 1, data: [0, 1] }104/** @internal */105export function isZero64(a: ArrayInt64): boolean {106 return a.data[0] === 0 && a.data[1] === 0107}108/** @internal */109export function isStrictlyNegative64(a: ArrayInt64): boolean {110 return a.sign === -1 && !isZero64(a)111}112/** @internal */113export function isStrictlyPositive64(a: ArrayInt64): boolean {114 return a.sign === 1 && !isZero64(a)115}116/** @internal */117export function isEqual64(a: ArrayInt64, b: ArrayInt64): boolean {118 if (a.data[0] === b.data[0] && a.data[1] === b.data[1]) {119 return a.sign === b.sign || (a.data[0] === 0 && a.data[1] === 0) // either the same or both zero120 }121 return false122}123/** @internal */124function isStrictlySmaller64Internal(a: ArrayInt64['data'], b: ArrayInt64['data']): boolean {125 return a[0] < b[0] || (a[0] === b[0] && a[1] < b[1])126}127/** @internal */128export function isStrictlySmaller64(a: ArrayInt64, b: ArrayInt64): boolean {129 if (a.sign === b.sign) {130 return a.sign === 1131 ? isStrictlySmaller64Internal(a.data, b.data) // a.sign = +1, b.sign = +1132 : isStrictlySmaller64Internal(b.data, a.data) // a.sign = -1, b.sign = -1133 }134 // a.sign = +1, b.sign = -1 is always false135 return a.sign === -1 && (!isZero64(a) || !isZero64(b)) // a.sign = -1, b.sign = +1136}137/** @internal */138export function clone64(a: ArrayInt64): ArrayInt64 {139 return { sign: a.sign, data: [a.data[0], a.data[1]] }140}141/** @internal */142function substract64DataInternal(a: ArrayInt64['data'], b: ArrayInt64['data']): ArrayInt64['data'] {143 let reminderLow = 0144 let low = a[1] - b[1]145 if (low < 0) {146 reminderLow = 1147 low = low >>> 0148 }149 return [a[0] - b[0] - reminderLow, low]150}151/**152 * Expects a >= b153 * @internal154 */155function substract64Internal(a: ArrayInt64, b: ArrayInt64): ArrayInt64 {156 if (a.sign === 1 && b.sign === -1) {157 // Operation is a simple sum of a + abs(b)158 const low = a.data[1] + b.data[1]159 const high = a.data[0] + b.data[0] + (low > 0xffffffff ? 1 : 0)160 return { sign: 1, data: [high >>> 0, low >>> 0] }161 }162 // a.sign === -1 with b.sign === 1 is impossible given: a - b >= 0, except for a = 0 and b = 0163 // Operation is a substraction164 return {165 sign: 1,166 data: a.sign === 1 ? substract64DataInternal(a.data, b.data) : substract64DataInternal(b.data, a.data)167 }168}169/**170 * Substract two ArrayInt64171 * @returns When result is zero always with sign=1172 * @internal173 */174export function substract64(arrayIntA: ArrayInt64, arrayIntB: ArrayInt64): ArrayInt64 {175 if (isStrictlySmaller64(arrayIntA, arrayIntB)) {176 const out = substract64Internal(arrayIntB, arrayIntA)177 out.sign = -1178 return out179 }180 return substract64Internal(arrayIntA, arrayIntB)181}182/**183 * Negative version of an ArrayInt64184 * @internal185 */186export function negative64(arrayIntA: ArrayInt64): ArrayInt64 {187 return {188 sign: -arrayIntA.sign as -1 | 1,189 data: [arrayIntA.data[0], arrayIntA.data[1]]190 }191}192/**193 * Add two ArrayInt64194 * @returns When result is zero always with sign=1195 * @internal196 */197export function add64(arrayIntA: ArrayInt64, arrayIntB: ArrayInt64): ArrayInt64 {198 if (isZero64(arrayIntB)) {199 if (isZero64(arrayIntA)) {200 return clone64(Zero64)201 }202 return clone64(arrayIntA)203 }204 return substract64(arrayIntA, negative64(arrayIntB))205}206/**207 * Halve an ArrayInt64208 * @internal209 */210export function halve64(a: ArrayInt64): ArrayInt64 {211 return {212 sign: a.sign,213 data: [Math.floor(a.data[0] / 2), (a.data[0] % 2 === 1 ? 0x80000000 : 0) + Math.floor(a.data[1] / 2)]214 }215}216/**217 * Apply log2 to an ArrayInt64 (preserve sign)218 * @internal219 */220export function logLike64(a: ArrayInt64): ArrayInt64 {221 // Math.floor(Math.log(hi * 2**32 + low) / Math.log(2)) <= Math.floor(Math.log(2**64) / Math.log(2)) = 64222 return {223 sign: a.sign,224 data: [0, Math.floor(Math.log(a.data[0] * 0x100000000 + a.data[1]) / Math.log(2))]225 }226}227/** @internal */228const INDEX_POSITIVE_INFINITY: ArrayInt64 = { sign: 1, data: [2146435072, 0] } // doubleToIndex(Number.MAX_VALUE) + 1;229/** @internal */230const INDEX_NEGATIVE_INFINITY: ArrayInt64 = { sign: -1, data: [2146435072, 1] } // doubleToIndex(-Number.MAX_VALUE) - 1231/**232 * Decompose a 64-bit floating point number into a significand and exponent233 * such that:234 * - significand over 53 bits including sign (also referred as fraction)235 * - exponent over 11 bits including sign236 * - whenever there are multiple possibilities we take the one having the highest significand (in abs)237 * - Number.MAX_VALUE = 2**1023 * (1 + (2**52-1)/2**52)238 * = 2**1023 * (2 - Number.EPSILON)239 * - Number.MIN_VALUE = 2**(-1022) * 2**(-52)240 * - Number.EPSILON = 2**(-52)241 *242 * @param d - 64-bit floating point number to be decomposed into (significand, exponent)243 *244 * @internal245 */246export function decomposeDouble(d: number): { exponent: number, significand: number } {247 // 1 => significand 0b1 - exponent 1 (will be preferred)248 // => significand 0b0.1 - exponent 2249 const maxSignificand = 2 - Number.EPSILON250 for (let exponent = -1022; exponent !== 1024; ++exponent) {251 const powExponent = 2 ** exponent252 const maxForExponent = maxSignificand * powExponent253 if (Math.abs(d) <= maxForExponent) {254 return { exponent, significand: d / powExponent }255 }256 }257 return { exponent: Number.NaN, significand: Number.NaN }258}259/** @internal */260function positiveNumberToInt64(n: number): ArrayInt64['data'] {261 return [~~(n / 0x100000000), n >>> 0]262}263/** @internal */264function indexInDoubleFromDecomp(exponent: number, significand: number): ArrayInt64['data'] {265 // WARNING: significand >= 0266 // By construct of significand in decomposeDouble,267 // significand is always max-ed.268 // The double close to zero are the only one having a significand <1, they also have an exponent of -1022.269 // They are in range: [2**(-1022) * 2**(-52), 2**(-1022) * (2 - 2 ** 52)]270 // In other words there are 2**53 elements in that range if we include zero.271 // All other ranges (other exponents) have a length of 2**52 elements.272 if (exponent === -1022) {273 // We want the significand to be an integer value (like an index)274 const rescaledSignificand = significand * 2 ** 52 // significand * 2**52275 return positiveNumberToInt64(rescaledSignificand)276 }277 // Offset due to exp = -1022 + Offset of previous exp (excl. -1022) + Offset in current exp278 // 2**53 + (exponent - (-1022) -1) * 2**52 + (significand - 1) * 2**52279 // (exponent + 1023) * 2**52 + (significand - 1) * 2**52280 const rescaledSignificand = (significand - 1) * 2 ** 52 // (significand-1) * 2**52281 const exponentOnlyHigh = (exponent + 1023) * 2 ** 20 // (exponent + 1023) * 2**52 => [high: (exponent + 1023) * 2**20, low: 0]282 const index = positiveNumberToInt64(rescaledSignificand)283 index[0] += exponentOnlyHigh284 return index285}286/**287 * Compute the index of d relative to other available 64-bit floating point numbers288 * Rq: Produces negative indexes for negative doubles289 *290 * @param d - 64-bit floating point number, anything except NaN291 *292 * @internal293 */294export function doubleToIndex(d: number): ArrayInt64 {295 if (d === Number.POSITIVE_INFINITY) {296 return clone64(INDEX_POSITIVE_INFINITY)297 }298 if (d === Number.NEGATIVE_INFINITY) {299 return clone64(INDEX_NEGATIVE_INFINITY)300 }301 const decomp = decomposeDouble(d)302 const exponent = decomp.exponent303 const significand = decomp.significand304 if (d > 0 || (d === 0 && 1 / d === Number.POSITIVE_INFINITY)) {305 return { sign: 1, data: indexInDoubleFromDecomp(exponent, significand) }306 } else {307 const indexOpposite = indexInDoubleFromDecomp(exponent, -significand)308 if (indexOpposite[1] === 0xffffffff) {309 indexOpposite[0] += 1310 indexOpposite[1] = 0311 } else {312 indexOpposite[1] += 1313 }314 return { sign: -1, data: indexOpposite } // -indexInDoubleFromDecomp(exponent, -significand) - 1315 }316}317/**318 * Compute the 64-bit floating point number corresponding to the provided indexes319 *320 * @param n - index of the double321 *322 * @internal323 */324export function indexToDouble(index: ArrayInt64): number {325 if (index.sign === -1) {326 const indexOpposite: ArrayInt64 = { sign: 1, data: [index.data[0], index.data[1]] }327 if (indexOpposite.data[1] === 0) {328 indexOpposite.data[0] -= 1329 indexOpposite.data[1] = 0xffffffff330 } else {331 indexOpposite.data[1] -= 1332 }333 return -indexToDouble(indexOpposite) // -indexToDouble(-index - 1);334 }335 if (isEqual64(index, INDEX_POSITIVE_INFINITY)) {336 return Number.POSITIVE_INFINITY337 }338 if (index.data[0] < 0x200000) {339 // if: index < 2 ** 53 <--> index[0] < 2 ** (53-32) = 0x20_0000340 // The first 2**53 elements correspond to values having341 // exponent = -1022 and significand = index * Number.EPSILON342 // double value = index * 2 ** -1022 * Number.EPSILON343 // = index * 2 ** -1022 * 2 ** -52344 // = index * 2 ** -1074345 return (index.data[0] * 0x100000000 + index.data[1]) * 2 ** -1074346 }347 const postIndexHigh = index.data[0] - 0x200000 // postIndex = index - 2 ** 53348 // exponent = -1021 + Math.floor(postIndex / 2**52)349 // = -1021 + Math.floor(postIndexHigh / 2**(52-32))350 // = -1021 + Math.floor(postIndexHigh / 2**20)351 // = -1021 + (postIndexHigh >> 20)352 const exponent = -1021 + (postIndexHigh >> 20)353 // significand = 1 + (postIndex % 2**52) / 2**52354 // = 1 + ((postIndexHigh * 2**32 + postIndexLow) % 2**52) / 2**52355 // = 1 + ((postIndexHigh % 2**20) * 2**32 + postIndexLow) / 2**52356 // = 1 + ((postIndexHigh & 0xfffff) * 2**32 + postIndexLow) / 2**52357 // = 1 + ((postIndexHigh & 0xfffff) * 2**32 + postIndexLow) * Number.EPSILON358 const significand = 1 + ((postIndexHigh & 0xfffff) * 2 ** 32 + index.data[1]) * Number.EPSILON359 return significand * 2 ** exponent360}361/**362 * Same as {@link doubleToIndex} except it throws in case of invalid double363 *364 * @internal365 */366export function safeDoubleToIndex(d: number, label: string): I.IO<unknown, never, ArrayInt64> {367 if (Number.isNaN(d)) {368 // Number.NaN does not have any associated index in the current implementation369 return I.halt(new Error('fc.doubleNext constraints.' + label + ' must be a 32-bit float'))370 }371 return I.succeed(doubleToIndex(d))372}373let EPSILON = Math.pow(2, -52)374let MAX_VALUE = (2 - EPSILON) * Math.pow(2, 1023)375let MIN_VALUE = Math.pow(2, -1022)376export function nextUp(x: number) {377 if (x !== x) {378 return x379 }380 if (x === -1 / 0) {381 return -MAX_VALUE382 }383 if (x === +1 / 0) {384 return +1 / 0385 }386 if (x === +MAX_VALUE) {387 return +1 / 0388 }389 let y = x * (x < 0 ? 1 - EPSILON / 2 : 1 + EPSILON)390 if (y === x) {391 y = MIN_VALUE * EPSILON > 0 ? x + MIN_VALUE * EPSILON : x + MIN_VALUE392 }393 if (y === +1 / 0) {394 y = +MAX_VALUE395 }396 let b = x + (y - x) / 2397 if (x < b && b < y) {398 y = b399 }400 let c = (y + x) / 2401 if (x < c && c < y) {402 y = c403 }404 return y === 0 ? -0 : y405}406export function nextAfter(x: number, y: number) {407 return y < x ? -nextUp(-x) : y > x ? nextUp(x) : x !== x ? x : y408}409export function computeBiasedRanges(410 min: ArrayInt64,411 max: ArrayInt64,412 biasedRanges?: { min: ArrayInt64, max: ArrayInt64 }[]413): { min: ArrayInt64, max: ArrayInt64 }[] {414 if (biasedRanges != null) {415 return biasedRanges416 }417 if (isEqual64(min, max)) {418 return [{ min, max }]419 }420 const minStrictlySmallerThanZero = isStrictlyNegative64(min)421 const maxStrictlyGreaterThanZero = isStrictlyPositive64(max)422 if (minStrictlySmallerThanZero && maxStrictlyGreaterThanZero) {423 const logMin = logLike64(min)424 const logMax = logLike64(max)425 return [426 { min: logMin, max: logMax },427 { min: substract64(max, logMax), max },428 { min, max: substract64(min, logMin) }429 ]430 } else {431 const logGap = logLike64(substract64(max, min))432 const closeToMin = { min, max: add64(min, logGap) }433 const closeToMax = { min: substract64(max, logGap), max }434 return minStrictlySmallerThanZero ? [closeToMax, closeToMin] : [closeToMin, closeToMax]435 }436}437export function computeArrayInt64GenerateRange(438 min: ArrayInt64,439 max: ArrayInt64,440 biasFactor: number | undefined,441 biasedRanges: { min: ArrayInt64, max: ArrayInt64 }[] | undefined442): I.URIO<Has<Random>, { min: ArrayInt64, max: ArrayInt64 }> {443 return I.gen(function* (_) {444 if (biasFactor === undefined || (yield* _(Random.nextIntBetween(1, biasFactor))) !== 1) {445 return { min, max }446 }447 const ranges = computeBiasedRanges(min, max, biasedRanges)448 if (ranges.length === 1) {449 return ranges[0]450 }451 const id = yield* _(Random.nextIntBetween(-2 * (ranges.length - 1), ranges.length - 2))452 return id < 0 ? ranges[0] : ranges[id + 1]453 })454}455export function clamp(n: number, min: number, max: number): number {456 return n < min ? min : n > max ? max : n...

Full Screen

Full Screen

keeper.guard2.js

Source:keeper.guard2.js Github

copy

Full Screen

1// Designed to kill sourcekeepers - lvl is high for this guy. 2// needed for this is : 4.140K3var classLevels = [4 [MOVE, MOVE, MOVE, MOVE, MOVE,5 MOVE, MOVE, MOVE, MOVE, MOVE,6 MOVE, MOVE, MOVE, MOVE, MOVE,7 MOVE, MOVE, MOVE, MOVE, MOVE,8 MOVE, MOVE, MOVE, MOVE, ATTACK,9 ATTACK, ATTACK, ATTACK, ATTACK, ATTACK,10 ATTACK, ATTACK, ATTACK, ATTACK, ATTACK,11 ATTACK, ATTACK, ATTACK, ATTACK, ATTACK,12 ATTACK, ATTACK, ATTACK, ATTACK, HEAL,13 HEAL, HEAL, HEAL, MOVE, HEAL14 ],15 [MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE,16 ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK,17 HEAL, RANGED_ATTACK, RANGED_ATTACK, RANGED_ATTACK, HEAL, HEAL, HEAL, MOVE, HEAL18 ], //431019 {20 body: [MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE,21 ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK,22 HEAL, RANGED_ATTACK, RANGED_ATTACK, RANGED_ATTACK, HEAL, HEAL, HEAL, MOVE, HEAL23 ], //431024 boost: ['LO'],25 },26 {27 body: [TOUGH, TOUGH, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE, MOVE,28 ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK, ATTACK,29 RANGED_ATTACK, RANGED_ATTACK, RANGED_ATTACK, HEAL, HEAL, MOVE, HEAL30 ], //431031 boost: ['GO', 'KO'],32 },33];34var boost = [];35var roleParent = require('role.parent');36var movement = require('commands.toMove');37function getHostiles(creep, range) {38 if (creep.room.name !== creep.partyFlag.pos.roomName || creep.memory.keeperLair === undefined || creep.memory.keeperLair.length === 1) {39 range = 3;40 }41 let invader = creep.room.invaders;42 if (invader.length) {43 creep.say('inv');44 return invader;45 }46 let tgt = Game.getObjectById(creep.memory.playerTargetId);47 if (tgt !== null && tgt.owner.username !== 'Invader') {48 return [tgt];49 } else if (tgt !== null && tgt.owner.username === 'Invader') {50 // let bads = creep.pos.inRangeTo(creep.room.invaders, 3);51 // if (bads.length > 0) return bads;52 return [tgt];53 } else {54 creep.memory.playerTargetId = undefined;55 }56 /* let player = creep.room.enemies; // NPC57 if (player.length > 0) {58 creep.memory.playerTargetId = player[0].id;59 return player;60 }*/61 let bads = creep.room.notAllies;62 if (bads.length && range === undefined) {63 let close = creep.pos.findClosestByPath(bads);64 if (close && close.owner.username !== 'Invader') {65 creep.memory.playerTargetId = close.id;66 }67 return [close];68 } else if (range !== undefined) {69 let close = creep.pos.findClosestByPath(bads);70 if (close !== null && creep.pos.inRangeTo(close, range)) {71 return [close];72 } else {73 return [];74 }75 }76 return bads;77}78function attackCreep(creep, bads) {79 creep.memory.goTo = undefined;80 let enemy = creep.pos.findClosestByRange(bads);81 let distance = creep.pos.getRangeTo(enemy);82 // creep.say('attk' + bads.length, ":", distance);83 // if (enemy === null) return;84 /* if (creep.hits < 400 && enemy.owner.username != 'Source Keeper' && distance === 1) {85 creep.selfHeal();86 return;87 }*/88 /*if (distance === 4 && enemy.hits === 5000 && creep.ticksToLive < 11) {89 creep.suicide();90 return;91 }*/92 if (distance <= 1) {93 // creep.memory.walkingTo = undefined;94 if (enemy.owner.username !== 'Source Keeper' || enemy.hits <= 100) {95 creep.attack(enemy);96 creep.rangedMassAttack();97 if (enemy.owner.username === 'Invader') {98 creep.tacticalMove2(bads);99 }100 return;101 } else {102 // if (creep.hits > 2600) {103 if (enemy.getActiveBodyparts(ATTACK) > creep.getActiveBodyparts(ATTACK)) {104 if (creep.hits === creep.hitsMax) {105 creep.attack(enemy);106 }107 } else {108 creep.attack(enemy);109 }110 if (enemy.fatigue === 0) {111 creep.move(enemy);112 }113 if (Game.cpu.bucket > 5000) creep.rangedMassAttack();114 // } else {115 // creep.rangedMassAttack();116 // creep.selfHeal();117 // }118 }119 } else if (distance < 4) {120 var heals = _.filter(bads, function(o) {121 return o.getActiveBodyparts(HEAL) > 0 && o.pos.inRangeTo(creep, 4);122 });123 if (heals.length > 0) {124 creep.rangedMassAttack();125 creep.say('!!');126 } else {127 creep.rangedAttack(enemy);128 creep.say('!!2');129 }130 creep.selfHeal();131 if (enemy.owner.username === 'Invader') {132 creep.tacticalMove2(bads);133 } else {134 creep.moveMe(enemy, { ignoreCreeps: true, maxRooms: 1 });135 }136 return;137 } else if (distance >= 4) {138 if (creep.hits !== creep.hitsMax) creep.selfHeal();139 if (enemy.owner.username === 'Source Keeper') {140 if (creep.hits == creep.hitsMax || distance > 6) {141 creep.chaseTo(enemy, { ignoreCreeps: true, maxRooms: 1, maxOpts: 200, reusePath: 50 });142 }143 } else {144 creep.moveMe(enemy, { ignoreCreeps: true, maxRooms: 1, reusePath: 50 });145 //creep.smartMove(bads);146 }147 }148}149function analyzeSourceKeeper(creep) {150 let keepers = creep.memory.keeperLair;151 let targetID;152 let lowest = 301;153 var e = keepers.length;154 while (e--) {155 let keeperTarget;156 if (keepers[e] !== null) keeperTarget = Game.getObjectById(keepers[e]);157 if (keeperTarget !== null && keeperTarget !== undefined) {158 if ( keeperTarget.ticksToSpawn === undefined){159 targetID = e;160 break;161 }else162 if (keeperTarget.ticksToSpawn < lowest) {163 lowest = keeperTarget.ticksToSpawn;164 targetID = e;165 }166 }167 }168 return targetID;169}170function moveToSK(creep) {171 // So moveToSK only needs to worry about movement to a sourceKeeper. 172 if (creep.memory.goTo === undefined) {173 creep.memory.goTo = analyzeSourceKeeper(creep);174 }175 if (creep.memory.dontMove === true) {176 // This is used with controlGuard flag to stay in one place.177 return false;178 }179 let gota = Game.getObjectById(creep.memory.keeperLair[creep.memory.goTo]);180 if (gota !== null) {181 if (!creep.pos.isNearTo(gota)) {182 var ctn = 2;183 if (creep.room.name === gota.pos.roomName) {184 ctn = 1;185 }186 // if(creep.memory.keeperLair[creep.memory.goTo] === '5982ff77b097071b4adc2b20'){187 // gota = new RoomPosistion(new RoomPosition(26,36,"E13S17"))188 // }189 creep.moveMe(gota, {190 reusePath: 50,191 ignoreCreeps: true,192 maxRooms: ctn,193 visualizePathStyle: {194 fill: 'transparent',195 stroke: '#bf0FF',196 lineStyle: 'dotted',197 strokeWidth: 0.15,198 opacity: 0.5199 }200 });201 } else {202 if (gota.ticksToSpawn !== undefined && gota.ticksToSpawn - 1 > 0 && gota.ticksToSpawn < 200 && creep.hits === creep.hitsMax) {203 /*if(gota.ticksToSpawn creep.ticksToLive < 200){204 let amnt = 200 - creep.ticksToLive;205 creep.sleep(amnt);206 } else {*/207 creep.sleep(gota.ticksToSpawn + Game.time - 1);208 //}209 }210 }211 }212}213function doMineralFlag(creep) {214 let bads = creep.pos.findInRange(creep.room.notAllies, 5);215 // this.say(bads.length + "x");216 if (bads.length > 0) {217 if (creep.pos.isNearTo(bads[0])) {218 creep.attack(bads[0]);219 } else {220 creep.moveTo(bads[0]);221 }222 return true;223 }224 let didHeal = creep.smartHeal();225 if (didHeal && creep.hits < creep.hitsMax) {226 creep.say('waiting');227 return true;228 }229 let slpTimer;230 if (creep.partyFlag.color === COLOR_WHITE || creep.partyFlag.color === COLOR_BROWN) {231 creep.memory.reportDeath = true;232 }233 if (!creep.pos.isEqualTo(creep.partyFlag)) {234 if (creep.memory.keeperLair === undefined && creep.atFlagRoom) {235 let lairs = creep.room.find(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_KEEPER_LAIR } });236 let mineral = creep.room.find(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_EXTRACTOR } });237 if (lairs.length !== 0 && mineral.length !== 0) {238 let closeToMin = _.min(lairs, o => o.pos.getRangeTo(mineral[0]));239 if (closeToMin !== undefined) {240 creep.memory.keeperLair = [closeToMin.id];241 }242 }243 creep.say('zFlag');244 }245 creep.moveMe(creep.partyFlag, { reusePath: 50 }); //, useSKPathing: true 246 } else if (creep.hits === creep.hitsMax) {247 if (creep.memory !== undefined && creep.memory.keeperLair !== undefined && creep.memory.keeperLair.length === 1) {248 let gota = Game.getObjectById(creep.memory.keeperLair[0]);249 if (gota !== null) {250 if (!didHeal) {251 slpTimer = gota.ticksToSpawn + Game.time - 1;252 creep.sleep(slpTimer);253 }254 }255 }256 } else if (creep.memory.keeperLair !== undefined) {257 let gota = Game.getObjectById(creep.memory.keeperLair[0]);258 if (gota !== null && gota.ticksToSpawn !== undefined) {259 if (creep.ticksToLive < gota.ticksToSpawn) {260 creep.suicide();261 }262 }263 }264 return;265}266class roleGuard extends roleParent {267 static levels(level, roomName) {268 if(roomName){269 var strongholdTime = require('commands.toDefense').strongholdDefeated(roomName);270 if (Game.time < strongholdTime) {271 return classLevels[0];272 } 273 }274 if (level > classLevels.length - 1) level = classLevels.length - 1;275 if (_.isArray(classLevels[level])) {276 return classLevels[level];277 }278 if (_.isObject(classLevels[level])) {279 return classLevels[level].body;280 } else {281 return classLevels[level];282 }283 }284 static boosts(level) {285 if (!Memory.empireSettings.boost.guard) return [];286 if (_.isObject(classLevels[level])) {287 return classLevels[level].boost;288 }289 var boost = [];290 return _.uniq(boost);291 }292 static clothe() {293 return '#h#A#R';294 }295 static run(creep) {296 super.rebirth(creep);297 if (super.boosted(creep)) {298 return;299 }300 if (creep.isHome && super.rallyFirst(creep)) {301 return;302 }303 // if(creep.partyFlag && creep.partyFlag.setColor(COLOR_YELLOW)){304 // }305 if (creep.ticksToLive === 1499 && !super.movement.strongholdDefeatedCheck(creep) && creep.memory.boostNeeded && creep.memory.boostNeeded.length === 0 && creep.memory.isBoosted === undefined && creep.memory.level === 1 && Memory.empireSettings.boost.guard) {306 creep.memory.boostNeeded = [];307 if (Memory.stats.totalMinerals.KO > 20000) {308 creep.memory.boostNeeded.push('KO');309 }310 if (Memory.stats.totalMinerals.LO > 20000) {311 creep.memory.boostNeeded.push('LO');312 }313 } else if (creep.ticksToLive === 1499) {314 creep.memory.boostNeeded = [];315 }316 creep.partyFlag.memory.guard = true;317 creep.partyFlag.memory.musterType = 'guard';318 creep.partyFlag.memory.removeFlagCount = false;319 creep.partyFlag.memory.rallyCreateCount = 10;320 if (creep.partyFlag.memory.mineral) {321 doMineralFlag(creep);322 return;323 }324 // console.log(creep.isHome , creep.partyFlag.memory.spawningSettings.gameTimeSiege );325 if (creep.isHome && creep.partyFlag.memory.spawningSettings.gameTimeSiege > Game.time) {326 creep.memory.death = true;327 }328 if (creep.room.invaderCore) {329 let effect = creep.room.invaderCore.isEffected(EFFECT_COLLAPSE_TIMER);330 if (effect || !creep.room.invaderCore.ticksToDeploy || creep.room.invaderCore.ticksToDeploy < 100) {331 creep.partyFlag.setColor(COLOR_WHITE, COLOR_WHITE);332 creep.partyFlag.memory.spawningSettings.spawnCounter = 1;333 creep.partyFlag.memory.spawningSettings.gameTimeSiege = Game.time + effect.ticksRemaining;334 let homeSpawn = Game.getObjectById(creep.memory.parent);335 if (homeSpawn) {336 for (let i in homeSpawn.memory.roadsTo) {337 let remote = homeSpawn.memory.roadsTo[i];338 if (remote.sourcePos === creep.room.name) {339 remote.stopRemote = Game.time + effect.ticksRemaining;340 }341 }342 }343 }344 creep.memory.death = true;345 }346 if (!creep.atFlagRoom) {347 creep.countDistance();348 creep.moveMe(creep.partyFlag, { reusePath: 50 });349 if (creep.hits < creep.hitsMax) creep.selfHeal();350 return;351 } else {352 /*353 if (!creep.memory.didCheck) {354 let tgt = Game.getObjectById(creep.memory.containsID);355 if (!tgt) {356 let contains = _.filter(creep.room.find(FIND_STRUCTURES), function(o) {357 return o.structureType === STRUCTURE_CONTAINER && o.isEffected(EFFECT_COLLAPSE_TIMER);358 });359 if (contains.length > 0) {360 tgt = contains[0];361 creep.memory.containsID = tgt.id;362 } else {363 creep.memory.didCheck = true;364// return;365 }366 } 367 if(tgt) {368 if (creep.pos.isNearTo(tgt)) {369 creep.attack(tgt);370 } else {371 creep.moveMe(tgt);372 }373 creep.selfHeal();374 return;375 }376 }*/377 }378 let bads;379 bads = getHostiles(creep,8);380 if (bads !== undefined && bads.length > 0) {381 attackCreep(creep, bads);382 creep.memory.goTo = undefined;383 return;384 } else if (creep.hits < creep.hitsMax) {385 //creep.selfHeal();386 var hurtz = _.filter(creep.room.find(FIND_MY_CREEPS), function(o) {387 return o.hits !== o.hitsMax && o.id !== creep.id && creep.pos.isNearTo(o) && !o.isAtEdge;388 });389 if (hurtz.length > 0) {390 if (creep.pos.isNearTo(hurtz[0])) {391 creep.heal(hurtz[0]);392 } else {393 if (creep.hits < creep.hitsMax) {394 creep.selfHeal();395 } else {396 creep.rangedHeal(hurtz[0]);397 }398 creep.moveTo(hurtz[0]);399 }400 return;401 } else {402 creep.smartHeal();403 }404 }405 if (creep.memory.keeperLair === undefined) {406 if (creep.room.name === 'E25S26') {407 creep.memory.keeperLair = ['5982ff77b097071b4adc2b21', '5982ff77b097071b4adc2b1d', '5982ff77b097071b4adc2b20', '5982ff77b097071b4adc2b24'];408 } else {409 creep.memory.keeperLair = [];410 var lairs = creep.room.find(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_KEEPER_LAIR } });411 for (var e in lairs) {412 creep.memory.keeperLair.push(lairs[e].id);413 }414 }415 } else if (creep.memory.keeperLair && creep.atFlagRoom) {416 moveToSK(creep);417 }418 }419}...

Full Screen

Full Screen

BiasNumericRange.spec.ts

Source:BiasNumericRange.spec.ts Github

copy

Full Screen

1import * as fc from 'fast-check';2import {3 biasNumericRange,4 bigIntLogLike,5 integerLogLike,6} from '../../../../../src/arbitrary/_internals/helpers/BiasNumericRange';7describe('biasNumericRange', () => {8 it('should bias close to extreme values and zero if min and max have opposite signs', () =>9 fc.assert(10 fc.property(11 fc.integer({ min: Number.MIN_SAFE_INTEGER, max: -1 }),12 fc.integer({ min: 1, max: Number.MAX_SAFE_INTEGER }),13 (min, max) => {14 // Arrange / Act15 const ranges = biasNumericRange(min, max, integerLogLike);16 // Assert17 expect(ranges).toHaveLength(3);18 expect(ranges).toEqual([19 { min: expect.toBeWithinRange(min, 0), max: expect.toBeWithinRange(0, max) }, // close to zero20 { min: expect.toBeWithinRange(0, max), max: max }, // close to max21 { min: min, max: expect.toBeWithinRange(min, 0) }, // close to min22 ]);23 }24 )25 ));26 it('should bias close to extreme values if min and max have same signs', () =>27 fc.assert(28 fc.property(29 fc.constantFrom(1, -1),30 fc.integer({ min: 0, max: Number.MAX_SAFE_INTEGER }),31 fc.integer({ min: 0, max: Number.MAX_SAFE_INTEGER }),32 (sign, minRaw, maxRaw) => {33 // Arrange34 fc.pre(minRaw !== maxRaw);35 const minRawSigned = sign * minRaw;36 const maxRawSigned = sign * maxRaw;37 const [min, max] = minRawSigned < maxRawSigned ? [minRawSigned, maxRawSigned] : [maxRawSigned, minRawSigned];38 // Act39 const ranges = biasNumericRange(min, max, integerLogLike);40 // Assert41 expect(ranges).toHaveLength(2);42 const closeToMin = { min: expect.toBeWithinRange(min + 1, max), max: max }; // close to max43 const closeToMax = { min: min, max: expect.toBeWithinRange(min, max - 1) }; // close to min44 if (sign > 0) expect(ranges).toEqual([closeToMax, closeToMin]);45 else expect(ranges).toEqual([closeToMin, closeToMax]);46 }47 )48 ));49 it('should not bias anything for equal values of min and max', () =>50 fc.assert(51 fc.property(fc.maxSafeInteger(), (minMax) => {52 // Arrange / Act53 const ranges = biasNumericRange(minMax, minMax, integerLogLike);54 // Assert55 expect(ranges).toHaveLength(1);56 expect(ranges).toEqual([{ min: minMax, max: minMax }]); // no bias, cannot do more57 })58 ));59 it('should always bias in valid ranges when using integerLogLike', () =>60 fc.assert(61 fc.property(fc.maxSafeInteger(), fc.maxSafeInteger(), (a, b) => {62 // Arrange63 const min = a < b ? a : b;64 const max = a < b ? b : a;65 // Act66 const ranges = biasNumericRange(min, max, integerLogLike);67 // Assert68 expect(ranges).not.toHaveLength(0);69 for (const range of ranges) {70 expect(range.max).toBeGreaterThanOrEqual(range.min);71 expect(min).toBeLessThanOrEqual(range.max);72 expect(max).toBeGreaterThanOrEqual(range.max);73 expect(min).toBeLessThanOrEqual(range.min);74 expect(max).toBeGreaterThanOrEqual(range.min);75 }76 })77 ));78 if (typeof BigInt !== 'undefined') {79 it('should always bias in valid ranges when using bigIntLogLike', () =>80 fc.assert(81 fc.property(fc.bigInt(), fc.bigInt(), (a, b) => {82 // Arrange83 const min = a < b ? a : b;84 const max = a < b ? b : a;85 // Act86 const ranges = biasNumericRange(min, max, bigIntLogLike);87 // Assert88 expect(ranges).not.toHaveLength(0);89 for (const range of ranges) {90 expect(range.max).toBeGreaterThanOrEqual(range.min);91 expect(min).toBeLessThanOrEqual(range.max);92 expect(max).toBeGreaterThanOrEqual(range.max);93 expect(min).toBeLessThanOrEqual(range.min);94 expect(max).toBeGreaterThanOrEqual(range.min);95 }96 })97 ));98 }99});100// Helpers101expect.extend({102 toBeWithinRange(received, floor, ceiling): jest.CustomMatcherResult {103 const pass = received >= floor && received <= ceiling && !Number.isNaN(received);104 return {105 message: () => `expected ${received} ${pass ? 'not ' : ''} to be within range ${floor} - ${ceiling}`,106 pass,107 };108 },109});110declare global {111 // eslint-disable-next-line @typescript-eslint/no-namespace112 namespace jest {113 interface Expect {114 toBeWithinRange(a: number, b: number): CustomMatcherResult;115 }116 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { closeToMin } = require('fast-check-monorepo');3fc.assert(4 fc.property(fc.integer(), fc.integer(), (a, b) => {5 return closeToMin(a, b);6 })7);8const { closeToMin } = require('./closeToMin');9module.exports = {10};11const closeToMin = (a, b) => {12 return a <= b;13};14module.exports = {15};16const { closeToMin } = require('./closeToMin');17module.exports = {18};19const closeToMin = require('./closeToMin');20module.exports = {21};22const closeToMin = require('./closeToMin');23module.exports = closeToMin;24const closeToMin = require('./closeToMin');25module.exports = closeToMin;26const closeToMin = require('./closeToMin');27module.exports = closeToMin;28const closeToMin = require('./closeToMin');29module.exports = closeToMin;30const closeToMin = require('./closeToMin');31module.exports = closeToMin;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { closeToMin } = require('fast-check');2const { closeTo } = require('fast-check');3const { double } = require('fast-check');4const { integer } = require('fast-check');5describe('closeTo', () => {6 it('should work', () => {7 fc.assert(fc.property(double(), double(), double(), (a, b, c) => {8 const min = Math.min(a, b, c);9 const max = Math.max(a, b, c);10 const middle = a + b + c - min - max;11 return closeToMin(middle, min, max);12 }));13 });14});15const { closeToMin } = require('fast-check');16const { closeTo } = require('fast-check');17const { double } = require('fast-check');18const { integer } = require('fast-check');19describe('closeTo', () => {20 it('should work', () => {21 fc.assert(fc.property(double(), double(), double(), (a, b, c) => {22 const min = Math.min(a, b, c);23 const max = Math.max(a, b, c);24 const middle = a + b + c - min - max;25 return closeToMin(middle, min, max);26 }));27 });28});29const { closeToMin } = require('fast-check');30const { closeTo } = require('fast-check');31const { double } = require('fast-check');32const { integer } = require('fast-check');33describe('closeTo', () => {34 it('should work', () => {35 fc.assert(fc.property(double(), double(), double(), (a, b, c) => {36 const min = Math.min(a, b, c);37 const max = Math.max(a, b, c);38 const middle = a + b + c - min - max;39 return closeToMin(middle, min, max);40 }));41 });42});43const { closeToMin }

Full Screen

Using AI Code Generation

copy

Full Screen

1import { closeToMin } from 'fast-check-monorepo'2import { closeTo } from 'fast-check'3import { closeTo } from 'fast-check'4const closeToMin = (min: number, max: number) => closeTo(min, max - min)5describe('closeToMin', () => {6 it('should generate values close to the min', () => {7 fc.assert(8 fc.property(fc.integer(), fc.integer(), (min, max) => {9 fc.assert(10 fc.property(closeToMin(min, max), (value) => {11 expect(value).toBeGreaterThanOrEqual(min)12 expect(value).toBeLessThanOrEqual(max)13 })14 })15 })16})17describe('closeTo', () => {18 it('should generate values close to the min', () => {19 fc.assert(20 fc.property(fc.integer(), fc.integer(), (min, max) => {21 fc.assert(22 fc.property(closeTo(min, max), (value) => {23 expect(value).toBeGreaterThanOrEqual(min)24 expect(value).toBeLessThanOrEqual(max)25 })26 })27 })28})29describe('closeToMin', () => {30 it('should generate values close to the min', () => {31 fc.assert(32 fc.property(fc.integer(), fc.integer(), (min, max) => {33 fc.assert(34 fc.property(closeToMin(min, max), (value) => {35 expect(value).toBeGreaterThanOrEqual(min)36 expect(value).toBeLessThanOrEqual(max)37 })38 })39 })40})41describe('closeTo', () => {42 it('should generate values close to the min', () => {43 fc.assert(44 fc.property(fc.integer(), fc.integer(), (min, max) => {45 fc.assert(46 fc.property(closeTo(min, max), (value) => {47 expect(value).toBeGreaterThanOrEqual(min)48 expect(value).toBeLessThanOrEqual(max)49 })50 })51 })52})53describe('closeToMin', () => {54 it('should generate values close to the min', () => {55 fc.assert(56 fc.property(fc.integer(), fc.integer(), (min, max) => {57 fc.assert(58 fc.property(closeToMin(min, max), (value) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { closeToMin } = require('fast-check-monorepo');2const { closeTo } = require('fast-check');3const result = closeTo(0, 0.1).sample();4const result2 = closeToMin(0.1).sample();5console.log(result);6console.log(result2);7{8 "scripts": {9 },10 "dependencies": {11 }12}13exports.closeToMin = closeToMin;14exports.closeToMin = closeToMin;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { closeToMin } = require('fast-check-monorepo');2const { check, property } = require('fast-check');3const { closeToMin } = require('fast-check-monorepo');4const { check, property } = require('fast-check');5const { closeToMin } = require('fast-check-monorepo');6const { check, property } = require('fast-check');7const { closeToMin } = require('fast-check-monorepo');8const { check, property } = require('fast-check');9const { closeToMin } = require('fast-check-monorepo');10const { check, property } = require('fast-check');11const { closeToMin } = require('fast-check-monorepo');12const { check, property } = require('fast-check');13const { closeToMin } = require('fast-check-monorepo');14const { check, property } = require('fast-check');15const { closeToMin } = require('fast-check-monorepo');16const { check, property } = require('fast-check');17const { closeToMin } = require('fast-check-monorepo');18const { check, property } = require('fast-check');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { closeToMin } = require('fast-check-monorepo');2const { min } = require('lodash');3const { array } = require('fast-check');4const data = array(array(nat())).noShrink().noBias().generate(mrng(), { seed: 42 });5const minOfMin = min(data.map(min));6const minOfMin2 = closeToMin(data);7console.log(`minOfMin = ${minOfMin}`);8console.log(`minOfMin2 = ${minOfMin2}`);9console.log(`minOfMin === minOfMin2 ? ${minOfMin === minOfMin2}`);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { closeToMin } from 'fast-check';2const min = 0;3const max = 100;4const range = max - min;5const target = 50;6const tolerance = 0.2;7const targetWithTolerance = target * (1 + tolerance);8const random = closeToMin(min, max, targetWithTolerance);9const random2 = closeToMin(min, targetWithTolerance, targetWithTolerance);10const random3 = closeToMin(targetWithTolerance, max, targetWithTolerance);11const random4 = closeToMin(targetWithTolerance, targetWithTolerance, targetWithTolerance);12const random5 = closeToMin(min, min, targetWithTolerance);13const random6 = closeToMin(max, max, targetWithTolerance);14const random7 = closeToMin(target, target, targetWithTolerance);15const random8 = closeToMin(targetWithTolerance, targetWithTolerance, targetWithTolerance);16const random9 = closeToMin(target, target, targetWithTolerance);17const random10 = closeToMin(min, target, targetWithTolerance);18const random11 = closeToMin(target, max, targetWithTolerance);19const random12 = closeToMin(min, targetWithTolerance, targetWithTolerance);20const random13 = closeToMin(targetWithTolerance, max, targetWithTolerance);21const random14 = closeToMin(min, targetWithTolerance, targetWithTolerance);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful