Created
June 28, 2017 12:45
-
-
Save ttencate/eee9b56186c118d592eb83fbd2b11f15 to your computer and use it in GitHub Desktop.
Test cases for https://www.reddit.com/r/gamedev/comments/6ikumc/discrete_physics_on_a_2d_grid_how_hard_can_it_be/
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
@Test | |
fun forceMovesObject() = physicsTest { | |
- " " | |
- " A " | |
- " " | |
A isPushed right | |
A shouldMove right | |
} | |
@Test | |
fun objectPushesObject() = physicsTest { | |
- " " | |
- " AB " | |
- " " | |
A isPushed right | |
A shouldMove right | |
B shouldMove right | |
} | |
@Test | |
fun objectBlockedByWall() = physicsTest { | |
- " " | |
- " A# " | |
- " " | |
A isPushed right | |
A shouldMove nowhere | |
} | |
@Test | |
fun forcesCancel() = physicsTest { | |
- " " | |
- " AB " | |
- " " | |
A isPushed right | |
B isPushed left | |
A shouldMove nowhere | |
B shouldMove nowhere | |
} | |
@Test | |
fun bothPushed() = physicsTest { | |
- " " | |
- " AB " | |
- " " | |
A isPushed right | |
B isPushed right | |
A shouldMove right | |
B shouldMove right | |
} | |
@Test | |
fun forcesAddUp() = physicsTest { | |
- " " | |
- " ABC " | |
- " " | |
A isPushed right | |
B isPushed right | |
C isPushed left | |
A shouldMove right | |
B shouldMove right | |
C shouldMove right | |
} | |
@Test | |
fun forceTransferredToMultipleObjects() = physicsTest { | |
- " " | |
- " B D " | |
- " ABCD " | |
- " D " | |
- " " | |
A isPushed right | |
A shouldMove right | |
B shouldMove right | |
C shouldMove right | |
D shouldMove right | |
} | |
@Test | |
fun multipleObjectsBlockedByWall() = physicsTest { | |
- " " | |
- " B#D " | |
- " ABCD " | |
- " D " | |
- " " | |
A isPushed right | |
A shouldMove nowhere | |
B shouldMove nowhere | |
C shouldMove nowhere | |
D shouldMove nowhere | |
} | |
@Test | |
fun longObject() = physicsTest { | |
- " " | |
- " BBBB " | |
- " A " | |
- " " | |
A isPushed up | |
A shouldMove up | |
B shouldMove up | |
} | |
@Test | |
fun interlocked() = physicsTest { | |
- " " | |
- " BBB " | |
- " ABCBC " | |
- " CCC " | |
- " " | |
A isPushed right | |
A shouldMove right | |
B shouldMove right | |
C shouldMove right | |
} | |
@Test | |
fun blockedHalfway() = physicsTest { | |
- " " | |
- " B# " | |
- " ABC " | |
- " " | |
A isPushed right | |
A shouldMove nowhere | |
B shouldMove nowhere | |
C shouldMove nowhere | |
} | |
@Test | |
fun parallelPushers() = physicsTest { | |
- " " | |
- " AB " | |
- " B " | |
- " CB " | |
- " " | |
A isPushed right | |
C isPushed right | |
A shouldMove right | |
B shouldMove right | |
C shouldMove right | |
} | |
@Test | |
fun multipleForces() = physicsTest { | |
- " " | |
- " ABC " | |
- " " | |
A isPushed right | |
A isPushed right | |
A shouldMove right | |
B shouldMove right | |
C shouldMove right | |
} | |
@Test | |
fun orthogonalForces() = physicsTest { | |
- " " | |
- " AB " | |
- " C " | |
- " D " | |
- " " | |
A isPushed right | |
C isPushed up | |
D isPushed up | |
A shouldMove nowhere | |
B shouldMove up | |
C shouldMove up | |
D shouldMove up | |
} | |
@Test | |
fun noPulling() = physicsTest { | |
- " " | |
- " ZAB " | |
- " B " | |
- " CBD " | |
- " " | |
Z isPushed right | |
A isPushed right | |
C isPushed left | |
D isPushed left | |
Z shouldMove right | |
A shouldMove right | |
B shouldMove right | |
C shouldMove left | |
D shouldMove right | |
} | |
@Test | |
fun pushIntoTwoWalls() = physicsTest { | |
- " " | |
- " #A " | |
- " A " | |
- " %A " | |
- " " | |
A isPushed left | |
A shouldMove nowhere | |
} | |
@Test | |
fun pushIntoWallIndirectly() = physicsTest { | |
- " " | |
- " #BA " | |
- " ##A " | |
- " " | |
A isPushed left | |
A shouldMove nowhere | |
B shouldMove nowhere | |
} | |
@Test | |
fun wallForceZero() = physicsTest { | |
- " " | |
- " AB " | |
- " A# " | |
- " " | |
A isPushed right | |
B isPushed left | |
A shouldMove nowhere | |
B shouldMove nowhere | |
} | |
@Test | |
fun noWallPulling() = physicsTest { | |
- " " | |
- " ABC " | |
- " A# " | |
- " " | |
A isPushed right | |
B isPushed left | |
C isPushed left | |
A shouldMove left | |
B shouldMove left | |
C shouldMove left | |
} | |
@Test | |
fun cancelWithThirdBlock() = physicsTest { | |
- " " | |
- " AB " | |
- " AC " | |
- " " | |
A isPushed right | |
C isPushed left | |
A shouldMove nowhere | |
B shouldMove nowhere | |
C shouldMove nowhere | |
} | |
@Test | |
fun noDiagonalOverlap() = physicsTest { | |
- " " | |
- " AB " | |
- " " | |
A isPushed right | |
B isPushed up | |
either { | |
A shouldMove right | |
B shouldMove right | |
} | |
or { | |
A shouldMove nowhere | |
B shouldMove up | |
} | |
} | |
@Test | |
fun horizontalVerticalAmbiguity() = physicsTest { | |
- " " | |
- " " | |
- " AB " | |
- " C " | |
- " " | |
A isPushed right | |
C isPushed up | |
either { | |
A shouldMove right | |
B shouldMove right | |
C shouldMove nowhere | |
} | |
or { | |
A shouldMove nowhere | |
B shouldMove up | |
C shouldMove up | |
} | |
} | |
@Test | |
fun sameDestinationAmbiguity() = physicsTest { | |
- " " | |
- " A B " | |
- " " | |
A isPushed right | |
B isPushed left | |
either { | |
A shouldMove right | |
B shouldMove nowhere | |
} | |
or { | |
A shouldMove nowhere | |
B shouldMove left | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment