-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAgent.cs
97 lines (73 loc) · 2.26 KB
/
Agent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp3
{
class Agent
{
public double L1 { get; set; } // latitude
public double L2 { get; set; } // longitude
public string L1L2
{
get
{
string l1 = String.Format("{0:0000}", L1).Replace(',', '.');
string l2 = String.Format("{0:0000}", L2).Replace(',', '.');
return String.Format("[{0}:{1}]", l1, l2);
}
}
public List<int> Values;
public int ID { get; set; }
public int Index { get; set; }
public int Rank
{
get
{ return PreferenceList[0].PreferenceList.IndexOf(this); }
}
public List<Agent> PreferenceList;
public Agent()
{
Values = new List<int>();
PreferenceList = new List<Agent>();
}
public void Test(Agent agent)
{
double additionalSeconds = 600; // en az beş dakika
if (agent.Values[Index] + additionalSeconds < Values[Index]
&& Values[agent.Index] + additionalSeconds < agent.Values[agent.Index])
{
PreferenceList.Add(agent);
PreferenceList = PreferenceList.OrderBy(i => i.Values[Index]).ToList();
}
}
public Agent best;
public Agent Best
{
get { return best; }
set
{
if (best == null)
best = value;
else if (PreferenceList.IndexOf(best) > PreferenceList.IndexOf(value))
best = value;
}
}
public Agent FirstChoice
{
get { return PreferenceList[0]; }
}
public Agent SecondChoice
{
get { return PreferenceList[1]; }
}
public Agent LastChoice
{
get { return PreferenceList[PreferenceList.Count - 1]; }
}
public void Clean(Agent agent)
{
PreferenceList.Remove(agent);
agent.PreferenceList.Remove(this);
}
}
}