diff options
author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-03-06 08:44:43 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-03-06 08:44:43 -0700 |
commit | 958134419d7913dc7dda0d4cd1982c51d8bd1a23 (patch) | |
tree | d06b7f84be8d43db63e360efedf467fe3d803217 /src/engine/levels | |
parent | 78797aa175651d53df21d3f8d5c51a55649aaced (diff) | |
download | the-abstraction-engine-church-numerals.tar.gz the-abstraction-engine-church-numerals.zip |
checkpointchurch-numerals
Diffstat (limited to 'src/engine/levels')
-rw-r--r-- | src/engine/levels/CarCadr.ts | 2 | ||||
-rw-r--r-- | src/engine/levels/ChurchNumeralsOne.ts | 45 | ||||
-rw-r--r-- | src/engine/levels/LevelNames.ts | 1 | ||||
-rw-r--r-- | src/engine/levels/Tutorial.ts | 3 | ||||
-rw-r--r-- | src/engine/levels/index.ts | 3 |
5 files changed, 51 insertions, 3 deletions
diff --git a/src/engine/levels/CarCadr.ts b/src/engine/levels/CarCadr.ts index 10ff6d9..8875623 100644 --- a/src/engine/levels/CarCadr.ts +++ b/src/engine/levels/CarCadr.ts @@ -9,8 +9,6 @@ import { Player, Wall, } from "../entities"; -import { Piston } from "../entities/Piston"; -import { Direction } from "../interfaces"; import { Grid, SystemNames } from "../systems"; import { normalRandom } from "../utils"; diff --git a/src/engine/levels/ChurchNumeralsOne.ts b/src/engine/levels/ChurchNumeralsOne.ts new file mode 100644 index 0000000..2dbb6b5 --- /dev/null +++ b/src/engine/levels/ChurchNumeralsOne.ts @@ -0,0 +1,45 @@ +import { FunctionApplication, Grass, LambdaFactory, Player } from "../entities"; +import { Game } from "../Game"; +import { Grid, SystemNames } from "../systems"; +import { normalRandom } from "../utils"; +import { Level } from "./Level"; +import { LevelNames } from "./LevelNames"; + +export class ChurchNumeralsOne extends Level { + constructor() { + super(LevelNames.ChurchNumeralsOne); + } + + public init(game: Game) { + const grid = game.getSystem<Grid>(SystemNames.Grid); + const dimensions = grid.getGridDimensions(); + + const grasses = Array.from({ length: dimensions.width }) + .fill(0) + .map(() => { + // random grass + return new Grass({ + x: Math.floor( + normalRandom(dimensions.width / 2, dimensions.width / 4, 1.5), + ), + y: Math.floor( + normalRandom(dimensions.height / 2, dimensions.height / 4, 1.5), + ), + }); + }); + + [ + ...grasses, + new LambdaFactory({ x: 1, y: 1 }, "(\\ (f) . (\\ (x) . (f f x)))", 1), + new FunctionApplication( + { x: 2, y: 2 }, + "(_INPUT ((_SPAWN _RIGHT) _KEY))", + ), + new FunctionApplication( + { x: 3, y: 3 }, + "(_INPUT _EMPTY)", + ), + new Player({ x: 0, y: 0 }), + ].forEach((e) => game.addEntity(e)); + } +} diff --git a/src/engine/levels/LevelNames.ts b/src/engine/levels/LevelNames.ts index 7f3c4f1..c8182ab 100644 --- a/src/engine/levels/LevelNames.ts +++ b/src/engine/levels/LevelNames.ts @@ -1,5 +1,6 @@ export namespace LevelNames { export const Tutorial = "0"; export const CarCadr = "1"; + export const ChurchNumeralsOne = "2"; export const LevelSelection = "LevelSelection"; } diff --git a/src/engine/levels/Tutorial.ts b/src/engine/levels/Tutorial.ts index 97a6826..fc927da 100644 --- a/src/engine/levels/Tutorial.ts +++ b/src/engine/levels/Tutorial.ts @@ -36,6 +36,7 @@ export class Tutorial extends Level { }); }); + // TODO: new level which adds introductory syntax const entities = [ ...grasses, new Sign( @@ -51,7 +52,7 @@ export class Tutorial extends Level { new Wall({ x: 11, y: 10 }), new Curry({ x: 10, y: 10 }), new LockedDoor({ x: 9, y: 10 }), - new LambdaFactory({ x: 6, y: 3 }, "// TODO: Remove line\n(λ (x) . x)", 3), + new LambdaFactory({ x: 6, y: 3 }, "// TODO: Remove this comment\n(λ (x) . x)", 3), new FunctionApplication({ x: 6, y: 6 }, "(_INPUT _KEY)"), new Player({ x: 2, y: 2 }), ]; diff --git a/src/engine/levels/index.ts b/src/engine/levels/index.ts index 216453c..f47000b 100644 --- a/src/engine/levels/index.ts +++ b/src/engine/levels/index.ts @@ -6,13 +6,16 @@ export * from "./CarCadr"; import { LevelNames } from "."; import { CarCadr, LevelSelection, Tutorial, Level } from "."; +import { ChurchNumeralsOne } from "./ChurchNumeralsOne"; export const LEVELS: Level[] = [ new LevelSelection(), new Tutorial(), new CarCadr(), + new ChurchNumeralsOne(), ]; export const LEVEL_PROGRESSION: Record<string, string[]> = { [LevelNames.LevelSelection]: [LevelNames.Tutorial], [LevelNames.Tutorial]: [LevelNames.CarCadr], + [LevelNames.CarCadr]: [LevelNames.ChurchNumeralsOne], }; |