Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/MagicCube/tensorflow-rex-run
/ functions
Functions
146 in github.com/MagicCube/tensorflow-rex-run
⨍
Functions
146
◇
Types & classes
30
↓ 11 callers
Method
init
()
src/ai/models/Model.js:4
↓ 9 callers
Method
update
* Update the game frame and schedules the next one.
src/game/Runner.js:264
↓ 7 callers
Function
getImageSprite
()
src/game/ImageSprite.js:3
↓ 6 callers
Function
getRandomNum
(min, max)
src/game/utils.js:15
↓ 6 callers
Function
getTimeStamp
()
src/game/utils.js:5
↓ 6 callers
Method
update
* Set the animation status. * @param {!number} deltaTime * @param {Trex.status} status Optional status to switch to.
src/game/Trex.js:152
↓ 5 callers
Method
fit
(inputXs, inputYs, iterationCount = 100)
src/ai/models/Model.js:26
↓ 5 callers
Method
predictSingle
(inputX)
src/ai/models/Model.js:16
↓ 5 callers
Method
reset
* Reset the t-rex to running at start of game.
src/game/Trex.js:360
↓ 4 callers
Method
draw
* Draw the t-rex to a particular position. * @param {number} x * @param {number} y
src/game/Trex.js:195
↓ 4 callers
Function
getFPS
()
src/game/RuntimeConfig.js:3
↓ 4 callers
Function
random
()
src/ai/models/random/RandomModel.js:33
↓ 4 callers
Method
restart
()
src/game/Runner.js:442
↓ 4 callers
Method
setDuck
* @param {boolean} isDucking.
src/game/Trex.js:347
↓ 3 callers
Method
addCloud
* Add a new cloud to the horizon.
src/game/Horizon.js:224
↓ 3 callers
Method
clearCanvas
()
src/game/Runner.js:252
↓ 3 callers
Function
convertStateToVector
(state)
src/apps/nn.js:77
↓ 3 callers
Function
convertStateToVector
(state)
src/apps/nnm.js:82
↓ 3 callers
Function
convertStateToVector
(state)
src/apps/genetic-nn.js:97
↓ 3 callers
Method
draw
* Draw a digit to canvas. * @param {number} digitPos Position of the digit. * @param {number} value Digit value 0-9. * @param {boolean} highS
src/game/DistanceMeter.js:95
↓ 2 callers
Method
addNewObstacle
* Add a new obstacle. * @param {number} currentSpeed
src/game/Horizon.js:153
↓ 2 callers
Function
boxCompare
* Compare two collision boxes for a collision. * @param {CollisionBox} tRexBox * @param {CollisionBox} obstacleBox * @return {boolean} Whether the
src/game/Trex.js:451
↓ 2 callers
Method
calcXPos
* Calculate the xPos in the canvas. * @param {number} canvasWidth
src/game/DistanceMeter.js:83
↓ 2 callers
Function
createAdjustedCollisionBox
* Adjust the collision box. * @param {!CollisionBox} box The original box. * @param {!CollisionBox} adjustment Adjustment box. * @return {Collision
src/game/Trex.js:436
↓ 2 callers
Method
draw
* Draw the cloud.
src/game/Cloud.js:55
↓ 2 callers
Method
draw
* Draw the horizon line.
src/game/HorizonLine.js:64
↓ 2 callers
Method
draw
* Draw and crop based on size.
src/game/Obstacle.js:160
↓ 2 callers
Method
endJump
* Jump is complete, falling down.
src/game/Trex.js:288
↓ 2 callers
Method
getActualDistance
* Covert pixel distance to a 'real' distance. * @param {number} distance Pixel distance ran. * @return {number} The 'real' distance ran.
src/game/DistanceMeter.js:140
↓ 2 callers
Method
getChromosome
()
src/ai/models/genetic-nn/NNModel.js:5
↓ 2 callers
Method
isVisible
* Check if the cloud is visible on the stage. * @return {boolean}
src/game/Cloud.js:95
↓ 2 callers
Method
lives
()
src/game/TrexGroup.js:49
↓ 2 callers
Method
randomize
()
src/ai/models/random/RandomModel.js:25
↓ 2 callers
Method
setBlinkDelay
* Sets a random time for the blink to happen.
src/game/Trex.js:244
↓ 2 callers
Method
setChromosome
(chromosome)
src/ai/models/genetic-nn/NNModel.js:15
↓ 2 callers
Method
setSpeed
* Sets the game speed. Adjust the speed accordingly if on a smaller screen. * @param {number} speed
src/game/Runner.js:239
↓ 2 callers
Method
setSpeedDrop
* Set the speed drop. Immediately cancels the current jump.
src/game/Trex.js:339
↓ 2 callers
Method
startJump
* Initialise a jump. * @param {number} speed
src/game/Trex.js:271
↓ 2 callers
Method
stop
()
src/game/Runner.js:427
↓ 2 callers
Function
tensor
(obj)
src/ai/utils/index.js:7
↓ 2 callers
Method
train
(inputXs, inputYs)
src/ai/models/Model.js:20
↓ 2 callers
Method
update
* @param {number} deltaTime * @param {number} currentSpeed * @param {boolean} updateObstacles Used as an override to prevent * the obstac
src/game/Horizon.js:64
↓ 2 callers
Method
updateCanvasScaling
* Updates the canvas size taking into * account the backing store pixel ratio and * the device pixel ratio. * * See article by Paul Lewis:
src/game/Runner.js:482
↓ 2 callers
Method
updateXPos
* Update the x position of an indivdual piece of the line. * @param {number} pos Line position. * @param {number} increment
src/game/HorizonLine.js:95
↓ 1 callers
Method
adjustDimensions
* Adjust game space dimensions on resize.
src/game/Runner.js:200
↓ 1 callers
Method
blink
* Make t-rex blink at random intervals. * @param {number} time Current time in milliseconds.
src/game/Trex.js:252
↓ 1 callers
Function
checkForCollision
(obstacle, tRex)
src/game/Trex.js:381
↓ 1 callers
Method
checkForCollision
(obstacle)
src/game/TrexGroup.js:53
↓ 1 callers
Method
cloneCollisionBoxes
* Make a copy of the collision boxes, since these will change based on * obstacle type and size.
src/game/Obstacle.js:244
↓ 1 callers
Function
convertStateToVector
(state)
src/apps/random.js:50
↓ 1 callers
Function
convertStateToVector
(state)
src/apps/genetic.js:66
↓ 1 callers
Function
createCanvas
* Create canvas element. * @param {HTMLElement} container Element to append canvas to. * @param {number} width * @param {number} height * @param {
src/game/Runner.js:524
↓ 1 callers
Method
crossOver
(parents, chromosomes)
src/ai/models/genetic/GeneticModel.js:19
↓ 1 callers
Method
drawHighScore
* Draw the high score.
src/game/DistanceMeter.js:207
↓ 1 callers
Method
duplicateObstacleCheck
* Returns whether the previous two obstacles are the same as the next one. * Maximum duplication is set in config value MAX_OBSTACLE_DUPLICATION.
src/game/Horizon.js:192
↓ 1 callers
Method
gameOver
* Game over state.
src/game/Runner.js:406
↓ 1 callers
Method
getGap
* Calculate a random gap size. * - Minimum gap gets wider as speed increses * @param {number} gapCoefficient * @param {number} speed * @re
src/game/Obstacle.js:224
↓ 1 callers
Method
getRandomType
* Return the crop x position of a type.
src/game/HorizonLine.js:57
↓ 1 callers
Method
init
* Initialise the distance meter to '00000'. * @param {number} width Canvas width in px.
src/game/DistanceMeter.js:65
↓ 1 callers
Method
init
* Initialise the cloud. Sets the Cloud height.
src/game/Cloud.js:44
↓ 1 callers
Method
init
* T-rex player initaliser. * Sets the t-rex to blink at random intervals.
src/game/Trex.js:129
↓ 1 callers
Method
init
* Initialise the horizon. Just add the line and a cloud. No obstacles.
src/game/Horizon.js:52
↓ 1 callers
Method
init
(speed)
src/game/Obstacle.js:110
↓ 1 callers
Method
isRunning
* Whether the game is running. * @return {boolean}
src/game/Runner.js:399
↓ 1 callers
Method
isVisible
* Check if obstacle is visible. * @return {boolean} Whether the obstacle is in the game area.
src/game/Obstacle.js:236
↓ 1 callers
Function
loadImageSprite
()
src/game/ImageSprite.js:7
↓ 1 callers
Method
loss
(predictedYs, labels)
src/ai/models/Model.js:32
↓ 1 callers
Method
mutate
(chromosomes)
src/ai/models/genetic/GeneticModel.js:39
↓ 1 callers
Method
onKeyDown
* Process keydown. * @param {Event} e
src/game/Runner.js:345
↓ 1 callers
Method
onKeyUp
* Process key up. * @param {Event} e
src/game/Runner.js:369
↓ 1 callers
Method
predict
(inputXs)
src/ai/models/Model.js:10
↓ 1 callers
Method
predict
(inputXs)
src/ai/models/nn/NNModel.js:40
↓ 1 callers
Method
scheduleNextUpdate
* RequestAnimationFrame wrapper.
src/game/Runner.js:388
↓ 1 callers
Method
select
(chromosomes)
src/ai/models/genetic/GeneticModel.js:14
↓ 1 callers
Method
setHighScore
* Set the highscore as a array string. * Position of char in the sprite: H - 10, I - 11. * @param {number} distance Distance ran in pixels.
src/game/DistanceMeter.js:221
↓ 1 callers
Method
setSourceDimensions
* Set the source dimensions of the horizon line.
src/game/HorizonLine.js:43
↓ 1 callers
Method
startGame
* Update the game status to started.
src/game/Runner.js:246
↓ 1 callers
Method
startListening
* Bind relevant key
src/game/Runner.js:332
↓ 1 callers
Method
train
(chromosomes)
src/ai/models/genetic/GeneticModel.js:4
↓ 1 callers
Method
update
* Update the distance meter. * @param {number} distance * @param {number} deltaTime
src/game/DistanceMeter.js:149
↓ 1 callers
Method
updateClouds
* Update the cloud positions. * @param {number} deltaTime * @param {number} currentSpeed
src/game/Horizon.js:79
↓ 1 callers
Method
updateJump
* Update frame for a jump. * @param {number} deltaTime * @param {number} speed
src/game/Trex.js:302
↓ 1 callers
Method
updateObstacles
* Update the obstacle positions. * @param {number} deltaTime * @param {number} currentSpeed
src/game/Horizon.js:111
Method
constructor
(canvas, spritePos, canvasWidth)
src/game/DistanceMeter.js:36
Method
constructor
(canvas, spritePos, containerWidth)
src/game/Cloud.js:25
Method
constructor
(canvas, spritePos)
src/game/Trex.js:95
Method
constructor
(canvas, spritePos, dimensions, gapCoefficient)
src/game/Horizon.js:28
Method
constructor
(outerContainerId, options)
src/game/Runner.js:82
Method
constructor
(canvas, spritePos)
src/game/HorizonLine.js:22
Method
constructor
( canvasCtx, type, spriteImgPos, dimensions, gapCoefficient, speed, offset )
src/game/Obstacle.js:80
Method
constructor
(count, canvas, spriteDef)
src/game/TrexGroup.js:9
Method
constructor
(x, y, w, h)
src/game/CollisionBox.js:12
Method
constructor
({ inputSize = 3, hiddenLayerSize = inputSize * 2, outputSize = 2, learningRate = 0.1 } = {}
src/ai/models/nn/NNModel.js:13
Function
convertStateToVector
(state)
src/apps/template.js:35
Method
debounceResize
* Debounce the resize event.
src/game/Runner.js:191
Method
draw
(x, y)
src/game/TrexGroup.js:26
Method
fit
(chromosomes)
src/ai/models/genetic/GeneticModel.js:10
Method
getChromosome
()
src/ai/models/genetic/RandomModel.js:4
Function
handleCrash
({ tRex })
src/apps/nn.js:61
Function
handleCrash
({ tRex })
src/apps/nnm.js:68
next →
1–100 of 146, ranked by callers