Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Racer tests #28

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Racer tests #28

wants to merge 14 commits into from

Conversation

tarrencev
Copy link

No description provided.

@whatthedev-eth
Copy link

Calculations for tests are in spreadsheet here. I put link in Telegram for editable version where you can play with the numbers in pink at the upper left and see how the plot (picture of racer+rays, enemies, between walls) changes. There are a few tabs at the bottom.

Notes by commit:

  • "add to tests in rays.cairo"

    • In test_raystrait_new, I had to reduce precision down to 1e-04 in some cases (theta, cos_theta, sin_theta). I'm not sure why theta needed that, but cos_theta and sin_theta might make sense due to the fast trig functions. Had to lower precision to 1e-03 or 1e-02 for p.x, p.y, q.x, and q.y, I think because of propagation of error from sin_theta and cos_theta. Is 1e-02 ok for functionality?
    • I got the error below, which I worked around by commenting out part of test_raytrait_intersects and then all uncommented tests pass. Then I uncommented these lines and commented out other part of test_raytrait_intersects and all these uncommented tests pass. So all the tests pass, just not all at once now. Still not sure how to solve this one. The error:
      Failed setting up runner.
      
      Caused by:
          #16187->#16188: Got 'Offset overflow' error while moving [210].
      
  • "add method vertices_scaled"

    • This was to fix a u128_mul overflow error when running test_closest_position from racer.cairo. This line passes scaled values but enemy PositionTrait vertices accepted only unscaled Position values, then used them to make array of scaled Fixed type. The source of the error was here because self.x and self.y were already scaled.
    • The fix is in enemy.cairo, a new method vertices_scaled which accepts scaled Position values (not sure if best name). Now other files call only vertices_scaled.
    • I left method vertices as-is in case ever needed for unscaled values inside enemy.cairo. (If so, we may want it to return a 2d vector with unscaled members, instead of Vec2.) Before this change, we used vertices method only for scaled values (called only from racer.cairo closest_position and collision_check). Method vertices is not currently called in enemy.cairo using unscaled Position values.
  • "add test_closest_position"

    • The test results here are probably close enough for good functionality but not super precise, so i used Option::Some(184467440737095000) // 1e-02 in assert_precise to get the tests to pass.
  • "fix fn move"

    • Prior to this fix, two tests, test_move_without_respawn and test_move_through_execute, were failing. This fix causes the tests to pass. I am pretty sure that line was the issue. However there are parts of move and test_move_through_execute I'm still trying to understand fully, so I am not 100% confident that this was the issue.
    • Tangential issue: Wierdly, one of the racer tests that previously passed was now running out of gas, so I made the available gas 10x and it now seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants