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

Add score computation #144

Closed
wants to merge 18 commits into from
Closed

Conversation

flyingtof
Copy link
Collaborator

No description provided.

vicb

This comment was marked as outdated.

Copy link
Owner

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some quick comments.

Could you please describe what's working, what needs to be improved, what is not working.

Merci!

apps/fxc-front/src/app/components/2d/planner-element.ts Outdated Show resolved Hide resolved
apps/fxc-front/src/app/components/2d/planner-element.ts Outdated Show resolved Hide resolved
apps/fxc-front/src/app/components/2d/planner-element.ts Outdated Show resolved Hide resolved
<div>
<div>${this.score.circuit}</div>
<div class="large">
${unsafeHTML(units.formatUnit(this.score.distance / 1000, this.units.distance, undefined, 'unit'))}
</div>
</div>
<div class="collapsible">
<div>Points = ${this.getMultiplier()}</div>
<div>Points = ${this.getMultiplier()} <br/>${this.league}</div>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move the league to it's own div below and hide it on mobile

Copy link
Collaborator Author

@flyingtof flyingtof Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved into a div.
Is there a standard way to hide a div on mobile?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<div class="collapsible"> should do the trick.

You can test the mobile view with the Chrome developper tools

image
(second icon from the left on the top bar)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding collapsible class is not sufficient. The collapse button on the bottom is not visible on mobile devices.
I added a another class and the league information will not be visible on devices with less than a minimum height (767px)

apps/fxc-front/src/app/components/ui/main-menu.ts Outdated Show resolved Hide resolved
apps/fxc-front/src/app/logic/score/improvedScorer.ts Outdated Show resolved Hide resolved
apps/fxc-front/src/app/logic/score/improvedScorer.ts Outdated Show resolved Hide resolved
apps/fxc-front/src/app/logic/score/league.ts Outdated Show resolved Hide resolved
@@ -27,6 +28,7 @@ abstract class CZXCBase {

export class CzechLocal extends CZXCBase {
name = 'Czech (ČPP local)';
code: LeagueCode = 'czl';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a better way to do this - see how it's done for the tracker at https://github.com/vicb/flyxc/blob/2b869f5bc06ce845e5b58f84642ab3e7cd2f044b/libs/common/src/lib/live-track.ts#L37 and up

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it is the same thing... or may be I dont understand. I added some comments in code. Tell me if it's ok or if I am missing something.

apps/fxc-front/src/app/logic/score/scorer.ts Outdated Show resolved Hide resolved
@christophe-taret-zenika christophe-taret-zenika force-pushed the add-score-computation branch 4 times, most recently from abcef4d to 1f2e3cf Compare October 10, 2023 05:31
@flyingtof
Copy link
Collaborator Author

There are some issues not resolved yet.
The solution is working, according to my personal tests.
There is still an issue when you compute the score twice on the same track (the distance displayed becomes incorrect), but I think that this was an already existing issue.

@vicb
Copy link
Owner

vicb commented Oct 10, 2023

There are some issues not resolved yet. The solution is working, according to my personal tests. There is still an issue when you compute the score twice on the same track (the distance displayed becomes incorrect),

Do you mean that it's correct the first time and become wrong the second time?

but I think that this was an already existing issue.

How would the issue be triggered with the current code?

Copy link
Owner

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple comments.
I'll take a close look in the coming days.
Thanks!

<div>
<div>${this.score.circuit}</div>
<div class="large">
${unsafeHTML(units.formatUnit(this.score.distance / 1000, this.units.distance, undefined, 'unit'))}
</div>
</div>
<div class="collapsible">
<div>Points = ${this.getMultiplier()}</div>
<div>Points = ${this.getMultiplier()} <br/>${this.league}</div>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<div class="collapsible"> should do the trick.

You can test the mobile view with the Chrome developper tools

image
(second icon from the left on the top bar)

@flyingtof
Copy link
Collaborator Author

There are some issues not resolved yet. The solution is working, according to my personal tests. There is still an issue when you compute the score twice on the same track (the distance displayed becomes incorrect),

Do you mean that it's correct the first time and become wrong the second time?

exactly

but I think that this was an already existing issue.

How would the issue be triggered with the current code?

I meant that I had this issue with my code from the beginning.

After re-reading the code, I think I found the cause : It is a problem of units (meters vs kilometers).
In improvedScorer.ts
If I replace

function toScore(solution: Solution): Score {
  return new Score({
    distance: solution.scoreInfo?.distance,
...

by

function toScore(solution: Solution): Score {
  return new Score({
    distance: (solution.scoreInfo?.distance || 0) * 1000,
...

The problem is over.

But I can't explain for sure why it was working the first time you compute the score and not the second time. I would suspect that a state somewhere is not cleaned / initialized properly.

@flyingtof
Copy link
Collaborator Author

flyingtof commented Oct 10, 2023

There is still sometimes a little difference between score computed the first time and the second time on the same track.
It depends on the track you use in your test. If you want to see that, you can use the test files in igc-xc-score lib
The difference is visible with this file : trifai-xcontest-189.65.igc.

An improvement could be to use the igc-xc-score solver in the League subclasses.
Another way to improve the solution could be to re-design the planner mechanisms.

CONTRIBUTING.md Outdated
- `gcloud components install cloud-datastore-emulator`

***run:***
- `gcloud beta emulators datastore start`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://cloud.google.com/sdk/gcloud/reference/beta/emulators/datastore

I think it's good to specify a --data-dir inside the project then it's easy to delete this folder to start with a fresh DB.

You can also use eval $(gcloud beta emulators datastore env-init --data-dir=DATA-DIR) for setting the env vars

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. Documentation fixed

flyingtof and others added 14 commits May 3, 2024 00:37
- also add a first step for using docker containers for development
- use igc-xc-score
- first implementation with quick and dirty UI for scoring
- no result visible in UI
- may be not the best solution as other computations are performed by
  the existing code
…core solver

- display planner menu after loading a track
- close main menu after loading a track
- 'compute score' menu item displayed when there is a current track
- show current league in planner menu
- also keep dependencies of igx-xc-score only in improvedScorer.ts
- Add more info (class, type, activity)
- Max zoom is now 10 instead of 12
- use igc-xc-score
- first implementation with quick and dirty UI for scoring
- no result visible in UI
- may be not the best solution as other computations are performed by
  the existing code
on mobile devices, the planner menu can be too high, and it can't
be hidden (hide button is hidden by the speed/altitude/vario pannel)
use values returned by the scorer to compute the mean speed
@flyingtof flyingtof marked this pull request as ready for review May 2, 2024 22:50
@flyingtof
Copy link
Collaborator Author

I think I have replied to your remarks.

  • The only one I did not catch is this one: Add score computation #144 (comment).
  • FYI, I've just added the computation of the mean speed using data computed from track, instead of using the default value (20km/h). I find this more useful for the user.
  • I had some issues when rebasing... this branch is quite old now :-/

@vicb
Copy link
Owner

vicb commented May 5, 2024

@flyingtof it would be easier to split this work into multiples CLs.

A possible split would be:

First CL:

Create a solver function taking a (flyxc) track and a contest (and options). It would return an object with an optimize method that optimize the track sync.

There should be an enum with all the contests currently supported.

This lib should probably lives in a libs/optimizer folder (use nx create ...) to bootstrap the library.

This lib is only a wrapper around the solver function from igc-xc-score, should be quite thin.

There should be tests:

  • a track with 2 points,
  • 3 points: free flight, triangle, FAI
  • I think we should tests all the rules for the French CFD and XContest
  • We can also test a few real tracks for all of the supported contests.

Second CL

Add a getGenerator({maxCycleTimeMs: number}) to the return object of the solver function.

This function should be called mutliple time to optimize a track (as should the solver function from igc-xc-score)

Update the test to also test this API.

Third CL

Replace the current scorer with this new API - note that it is only used to optimize route, not track.

Fourth CL

Add the ability to score track - as you have implemented in the current CL.

I think you should drive each CL to completion/merge before working on the next one. It will be much easier to review this way. The best way could be to leave this CL as is and start new CLs based on master.

After that we should add the ability to score live tracks too.

What do you think ?

@flyingtof
Copy link
Collaborator Author

I agree. We can consider this pr as a prototype and rebuild features step by step

@flyingtof flyingtof marked this pull request as draft May 17, 2024 15:38
@flyingtof flyingtof closed this Jun 4, 2024
@flyingtof flyingtof deleted the add-score-computation branch June 4, 2024 17:30
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