Skip to content

Commit

Permalink
Improve handling of partial callsign matches
Browse files Browse the repository at this point in the history
- Report both callsign and exchange errors in QSO log.
- Add argument to IsMyCall to enable random result for lids.
  • Loading branch information
w7sst committed May 31, 2024
1 parent 27a82ab commit 71643c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Contest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ function TContest.GetAudio: TSingleArray;
for i:=Stations.Count-1 downto 0 do
if Stations[i] is TDxStation then
with Stations[i] as TDxStation do
if (Oper.State = osDone) and (QsoList <> nil) and (MyCall = QsoList[High(QsoList)].Call) then begin
if (Oper.State = osDone) and (QsoList <> nil) and
((MyCall = QsoList[High(QsoList)].Call) or
(Oper.IsMyCall(QsoList[High(QsoList)].Call, False) = mcAlmost)) then begin
// grab Qso's "True" data (e.g. TrueCall, TrueExch1, TrueExch2)
DataToLastQso; // deletes this TDxStation from Stations[]

Expand Down
18 changes: 11 additions & 7 deletions DxOper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ interface

TDxOperator = class
private
R1: Single; // holds a Random number; used in IsMyCall
procedure DecPatience;
procedure MorePatience(AValue: integer = 0);
function IsMyCall: TCallCheckResult;
public
Call: string;
Skills: integer;
Expand All @@ -105,6 +105,7 @@ TDxOperator = class
procedure MsgReceived(AMsg: TStationMessages);
procedure SetState(AState: TOperatorState);
function GetReply: TStationMessage;
function IsMyCall(const ACall: string; ARandomResult: boolean): TCallCheckResult;
end;


Expand All @@ -118,6 +119,7 @@ implementation

constructor TDxOperator.Create(const ACall: string; AState: TOperatorState);
begin
R1 := Random; // a random value assigned at creation provides consistency
Call := ACall;
Skills := 1 + Random(3); //1..3
Patience := 0;
Expand Down Expand Up @@ -317,7 +319,8 @@ procedure TDxOperator.SetState(AState: TOperatorState);
end;


function TDxOperator.IsMyCall: TCallCheckResult;
function TDxOperator.IsMyCall(const ACall: string;
ARandomResult: boolean): TCallCheckResult;
const
W_X = 1; W_Y = 1; W_D = 1;
var
Expand All @@ -329,7 +332,7 @@ function TDxOperator.IsMyCall: TCallCheckResult;
P: integer;
begin
C0 := Call;
C := Tst.Me.HisCall;
C := ACall;

SetLength(M, Length(C)+1, Length(C0)+1);

Expand Down Expand Up @@ -383,10 +386,10 @@ function TDxOperator.IsMyCall: TCallCheckResult;
if Length(StringReplace(C, '?', '', [rfReplaceAll])) < 2 then Result := mcNo;

//accept a wrong call, or reject the correct one
if Ini.Lids and (Length(C) > 3) then
if ARandomResult and Ini.Lids and (Length(C) > 3) then
case Result of
mcYes: if Random < 0.01 then Result := mcAlmost;
mcAlmost: if Random < 0.04 then Result := mcYes;
mcYes: if R1 < 0.01 then Result := mcAlmost;
mcAlmost: if R1 < 0.04 then Result := mcYes;
end;
end;

Expand Down Expand Up @@ -417,7 +420,7 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages);
end;

if msgHisCall in AMsg then
case IsMyCall of
case IsMyCall(Tst.Me.HisCall, True) of
mcYes:
if State in [osNeedPrevEnd, osNeedQso] then SetState(osNeedNr)
else if State = osNeedCallNr then SetState(osNeedNr)
Expand All @@ -426,6 +429,7 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages);

mcAlmost:
if State in [osNeedPrevEnd, osNeedQso] then SetState(osNeedCallNr)
else if State = osNeedCallNr then MorePatience
else if State = osNeedNr then SetState(osNeedCallNr)
else if State = osNeedEnd then SetState(osNeedCall);

Expand Down
11 changes: 5 additions & 6 deletions Log.pas
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ procedure SaveQso;
for i:=Tst.Stations.Count-1 downto 0 do
if Tst.Stations[i] is TDxStation then
with Tst.Stations[i] as TDxStation do
if (MyCall = Qso.Call) then
if ((MyCall = Qso.Call) or (Oper.IsMyCall(Qso.Call, False) = mcAlmost)) then
begin
Qso.TrueWpm := WpmAsText();
Break;
Expand All @@ -770,7 +770,8 @@ procedure SaveQso;
for i:=Tst.Stations.Count-1 downto 0 do
if Tst.Stations[i] is TDxStation then
with Tst.Stations[i] as TDxStation do
if (Oper.State = osDone) and (MyCall = Qso.Call) then
if (Oper.State = osDone) and
((MyCall = Qso.Call) or (Oper.IsMyCall(Qso.Call, False) = mcAlmost)) then
begin
DataToLastQso; //grab "True" data and delete this dx station!
Break;
Expand Down Expand Up @@ -995,12 +996,10 @@ procedure CheckErr;
else if Dupe and not Log.ShowCorrections then
ExchError := leDUP
else
begin
ExchError := leNONE;

// find exchange errors for the current Qso
Tst.FindQsoErrors(QsoList[High(QsoList)], Corrections);
end;
// find exchange errors for the current Qso
Tst.FindQsoErrors(QsoList[High(QsoList)], Corrections);

CallColumnColor := clBlack;
Exch1ColumnColor := clBlack;
Expand Down

0 comments on commit 71643c2

Please sign in to comment.