Skip to content

Commit

Permalink
add the unweighted value to the value prediction of the current QSO
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed May 30, 2024
1 parent bbb9f01 commit 9425031
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
1 change: 1 addition & 0 deletions core/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (c *Controller) Startup() {
c.Callinfo = callinfo.New(c.dxccFinder, c.scpFinder, c.callHistoryFinder, c.QSOList, c.Score, c.Entry)
c.Entry.SetCallinfo(c.Callinfo)
c.Bandmap.SetCallinfo(c.Callinfo)
c.Score.Notify(c.Callinfo)

c.Settings.Notify(c.Entry)
c.Settings.Notify(c.Workmode)
Expand Down
15 changes: 5 additions & 10 deletions core/bandmap/bandmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ type Callinfo interface {
}

var defaultWeights = core.BandmapWeights{
TotalPoints: 1,
TotalMultis: 1,
AgeSeconds: -0.001,
Spots: 0.001,
Source: 0,
Quality: 0.01,
AgeSeconds: -0.001,
Spots: 0.001,
Source: 0,
Quality: 0.01,
}

type Bandmap struct {
Expand Down Expand Up @@ -180,11 +178,8 @@ func (m *Bandmap) ContestChanged(contest core.Contest) {
}
}

func (m *Bandmap) ScoreUpdated(score core.Score) {
totalScore := score.Result()
func (m *Bandmap) ScoreUpdated(_ core.Score) {
m.do <- func() {
m.weights.TotalPoints = float64(totalScore.Points)
m.weights.TotalMultis = float64(totalScore.Multis)
m.update()
}
}
Expand Down
4 changes: 1 addition & 3 deletions core/bandmap/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ func (l *Entries) calculateWeightedValue(entry *Entry, now time.Time, weights co
return 0
}

points := float64(entry.Info.Points)
multis := float64(entry.Info.Multis)
value := (points * weights.TotalMultis) + (multis * weights.TotalPoints) + (points * multis)
value := float64(entry.Info.Value)

ageSeconds := now.Sub(entry.LastHeard).Seconds()
spots := float64(entry.SpotCount)
Expand Down
13 changes: 10 additions & 3 deletions core/callinfo/callinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func New(entities DXCCFinder, callsigns CallsignFinder, callHistory CallHistoryF
dupeChecker: dupeChecker,
valuer: valuer,
exchangeFilter: exchangeFilter,
totalScore: core.BandScore{Points: 1, Multis: 1},
}

return result
Expand All @@ -45,6 +46,7 @@ type Callinfo struct {
lastExchange []string
predictedExchange []string
theirExchangeFields []core.ExchangeField
totalScore core.BandScore

bestMatches []string
}
Expand Down Expand Up @@ -85,7 +87,7 @@ type ExchangeFilter interface {
type View interface {
SetBestMatchingCallsign(callsign core.AnnotatedCallsign)
SetDXCC(string, string, int, int, bool)
SetValue(points, multis int)
SetValue(points, multis, value int)
SetPredictedExchange(index int, text string)
SetPredictedExchangeFields(fields []core.ExchangeField)
SetUserInfo(string)
Expand Down Expand Up @@ -114,6 +116,10 @@ func (c *Callinfo) ContestChanged(contest core.Contest) {
c.view.SetPredictedExchangeFields(c.theirExchangeFields)
}

func (c *Callinfo) ScoreUpdated(score core.Score) {
c.totalScore = score.Result()
}

func (c *Callinfo) BestMatches() []string {
return c.bestMatches
}
Expand Down Expand Up @@ -151,6 +157,7 @@ func (c *Callinfo) GetInfo(call callsign.Callsign, band core.Band, mode core.Mod
result.ExchangeText = strings.Join(result.FilteredExchange, " ")

result.Points, result.Multis, result.MultiValues = c.valuer.Value(call, entity, band, mode, result.PredictedExchange)
result.Value = (result.Points * c.totalScore.Multis) + (result.Multis * c.totalScore.Points) + (result.Points * result.Multis)

return result
}
Expand Down Expand Up @@ -185,7 +192,7 @@ func (c *Callinfo) ShowInfo(call string, band core.Band, mode core.Mode, exchang
c.showDXCCEntity(entity)
c.view.SetBestMatchingCallsign(bestMatch)
c.view.SetUserInfo(callinfo.UserText)
c.view.SetValue(callinfo.Points, callinfo.Multis)
c.view.SetValue(callinfo.Points, callinfo.Multis, callinfo.Value)
for i := range c.theirExchangeFields {
text := ""
if i < len(callinfo.FilteredExchange) {
Expand Down Expand Up @@ -356,7 +363,7 @@ func (v *nullView) Show() {}
func (v *nullView) Hide() {}
func (v *nullView) SetBestMatchingCallsign(callsign core.AnnotatedCallsign) {}
func (v *nullView) SetDXCC(string, string, int, int, bool) {}
func (v *nullView) SetValue(int, int) {}
func (v *nullView) SetValue(int, int, int) {}
func (v *nullView) SetPredictedExchange(int, string) {}
func (v *nullView) SetPredictedExchangeFields(fields []core.ExchangeField) {}
func (v *nullView) SetUserInfo(string) {}
Expand Down
41 changes: 20 additions & 21 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,21 +896,6 @@ func (s *BandSummary) Multis() int {
return result
}

type BandmapEntry struct {
Index int
Label string
Call callsign.Callsign
Frequency Frequency
Band Band
Mode Mode
LastHeard time.Time
Source SpotType
SpotCount int
Quality SpotQuality

Info Callinfo
}

type Callinfo struct {
Call callsign.Callsign

Expand All @@ -929,6 +914,7 @@ type Callinfo struct {
Points int
Multis int
MultiValues map[conval.Property]string
Value int
WeightedValue float64
}

Expand All @@ -941,6 +927,21 @@ const spotFrequencyDeltaThreshold float64 = 300
// spots within at least this proximity will be considered "on frequency"
const spotOnFrequencyThreshold float64 = 1.0 - (spotFrequencyDeltaThreshold / spotFrequencyProximityThreshold)

type BandmapEntry struct {
Index int
Label string
Call callsign.Callsign
Frequency Frequency
Band Band
Mode Mode
LastHeard time.Time
Source SpotType
SpotCount int
Quality SpotQuality

Info Callinfo
}

// ProximityFactor increases the closer the given frequency is to this entry's frequency.
// 0.0 = not in proximity, 1.0 = exactly on frequency
// the sign indiciates if the entry's frequency is above (>0) or below (<0) the reference frequency
Expand Down Expand Up @@ -988,12 +989,10 @@ func BandmapByDescendingValue(a, b BandmapEntry) bool {
}

type BandmapWeights struct {
TotalPoints float64
TotalMultis float64
AgeSeconds float64
Spots float64
Source float64
Quality float64
AgeSeconds float64
Spots float64
Source float64
Quality float64
}

type VFO interface {
Expand Down
4 changes: 2 additions & 2 deletions ui/callinfoView.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (v *callinfoView) SetDXCC(dxccName, continent string, itu, cq int, arrlComp
v.dxccLabel.SetMarkup(text)
}

func (v *callinfoView) SetValue(points, multis int) {
func (v *callinfoView) SetValue(points int, multis int, value int) {
style.RemoveClass(&v.valueLabel.Widget, callinfoWorthlessClass)
style.RemoveClass(&v.valueLabel.Widget, callinfoMultiClass)

Expand All @@ -126,7 +126,7 @@ func (v *callinfoView) SetValue(points, multis int) {
style.AddClass(&v.valueLabel.Widget, callinfoMultiClass)
}

v.valueLabel.SetText(fmt.Sprintf("%dP %dM", points, multis))
v.valueLabel.SetText(fmt.Sprintf("%dP x %dM = %d", points, multis, value))
}

func (v *callinfoView) SetUserInfo(value string) {
Expand Down

0 comments on commit 9425031

Please sign in to comment.