-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/5 puddles can overflow (#10)
* make findClosestDrop start with list instead of single point * small addition to averagePoint test * refactor puddle code, clean * use sensible puddle size and annotate with color (Debugging) * refactor puddle.ts surface collection, broken rn * proper flooding re-achieved * ponds find escape point * refactor findPondOutflow * rivers can overflow puddles trying to reach level 62 and then stop * add seenset to current river+pond generation * add ignoreSet to puddle surface collection that is passed down from river pathing * fix seenSet issue in layer generation * fix backflow into existing ponds? * refactor puddle layer generation trying to ignore existing ponds * add coverage report to jest config * add unit test with z mock * clean up tests that mock dimension * refactor pathToDrop and test * add move-across-flat unit test for river pathToDrop add move-across-flat unit test for river pathToDrop * add more test to pathToDrop * add first simple unit tests for pond escaping * fix river pathing test * allow escaping ponds deeper than 15 blocks (256 new value) * add (still failing) test for river flooding puddles and puddles swalling eachother * finally fixes ponds eating up eachother while flowing upwards * program respects user defined max surface for ponds * prepare unit test for finding escape-to-pond and refactor river findClosesDrop * add river running from pond bottom to escape point * catch undefined pondBottom-to-escape path * remvoe debug loging * remove obsolete function * github workflow for jest test * apply rivers only on non-puddle-points, add dirty fix to embedded ponds having different waterlevels * optimize inital search for starting points. ignore tiles without annotation * add regression test for path-to-escape bug * fix rounding error bug where a point thinks its a pond-bottom but isnt part of that pond surface * apply pond even if no espcae point was found * refactor user parameters to simply quickly prototying on map
- Loading branch information
Showing
19 changed files
with
815 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Unit Test | ||
|
||
on: push | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Node.js and NPM | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "latest" | ||
|
||
- name: "install dependencies" | ||
run: npm ci | ||
|
||
- name: full build and deploy | ||
run: npm run test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
// verbose: true, | ||
testEnvironment: 'node', | ||
// ... other Jest configuration options | ||
collectCoverage: true, | ||
coverageDirectory: 'coverage', | ||
coverageReporters: ["json", "html"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { point as Point } from "../point"; | ||
|
||
export type SeenSet = { | ||
add: (p: Point) => void; | ||
has: (p: Point) => boolean; | ||
hasNot: (p: Point) => boolean; | ||
}; | ||
|
||
export type SeenSetReadOnly = Omit<SeenSet,"add"> | ||
|
||
|
||
export const makeSet = (): SeenSet => { | ||
const set = new Set(); | ||
return { | ||
add: (point) => set.add(JSON.stringify(point)), | ||
has: (point) => set.has(JSON.stringify(point)), | ||
hasNot: (point) => !set.has(JSON.stringify(point)) | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Your tests that use the getZ function | ||
import {minFilter} from "./postprocessing"; | ||
import {point} from "../point"; | ||
|
||
describe('min filter', () => { | ||
beforeAll(() => { | ||
(global as any).dimension = { | ||
getLowestX: () => 0, | ||
getLowestY: () => 0, | ||
getHighestX: () => 10, | ||
getHighestY: () => 10, | ||
getHeightAt: (x: number, y: number) => x | ||
} | ||
}) | ||
|
||
afterAll(() => { | ||
(global as any).dimension = undefined; | ||
}); | ||
|
||
test('min filter returns min z neighbour', () => { | ||
const point: point = {x: 5, y: 5}; | ||
const minNeighbour = minFilter(point) | ||
expect(minNeighbour.z).toEqual(4); | ||
}) | ||
}) |
Oops, something went wrong.