{$R+}
Unit Stromovk;
Interface
Const MaxAgents = 100;
Type TAgentID = Integer;
TColor = (Red, Green, Yellow);
TTicketIndex = 1 .. 5;
{ Zavolejte pred prvnim pouzitim unity Stromovka }
Procedure StromovkaInit;
{ Zavolejte po poslednim pouziti unity Stromovka }
Procedure StromovkaDone;
{ Pocet agentu ve Stromovce, maji ID 1 .. AgentCount,
hodnota je vzdy mensi nebo rovna MaxAgents. }
Function AgentCount : Integer;
{ Jmeno agenta, jen pro potreby ladeni }
Function AgentName(A : TAgentID) : String;
{ ID agenta, jehoz jmeno je na vizitce barvy C ziskane od agenta A. }
Function NextAgent(A : TAgentID; C : TColor) : TAgentID;
{ Do X, Y nastavi pozici zadaneho agenta A. }
Procedure AgentPosition(A : TAgentID; Var X, Y : Real);
{ Pocatecni pozice tymu. }
Procedure TeamPosition(Var X, Y : Real);
{ Pozice sprateleneho (hlavniho) agenta, cilem je ziskat listky
tri barev, s jeho jmenem a donest je k nemu. }
Function FriendAgent : TAgentID;
{ Vraci ID agentu jejichz jmena jsou napocatecnich peti listcich,
parametr i nabyva hodnot 1 .. 5. }
Function InitialTickets(i : TTicketIndex) : TAgentID;
Implementation
Type TPosition = Record
x, y : Real;
End;
TAgent = Record
Pozice : TPosition;
Vizitky : Array[TColor] Of TAgentID;
Jmeno : String[30];
End;
Var AgentCnt : Integer;
FAgent : TAgentID; { Friend agent ID }
Agents : Array[1 .. MaxAgents] Of TAgent;
Tickets : Array[TTicketIndex] Of TAgentID;
Team : TPosition;
Procedure StromovkaInit;
Var F : Text;
I : TTicketIndex;
J : Integer;
A : TAgentID;
C : TColor;
Begin
Assign(F, 'vstup.txt');
Reset(F);
{ komentare }
For J := 1 To 3 Do ReadLn(F);
{ ctvrty radek }
Read(F, AgentCnt, Team.X, Team.Y);
For I := 1 To 5 Do Read(F, Tickets[I]);
Readln(F);
For A := 1 To AgentCnt Do With Agents[A] Do
Begin
Readln(F, Jmeno);
Read(F, J, Pozice.X, Pozice.Y);
If J = 1 Then FAgent := A;
For C := Red To Yellow Do Read(F, Vizitky[C]);
Readln(F);
End;
Close(F);
End;
Procedure StromovkaDone;
Begin
End;
Function AgentCount : Integer;
Begin
AgentCount := AgentCnt;
End;
Function AgentName(A : TAgentID) : String;
Begin
If A > AgentCnt Then RunError(201);
AgentName := Agents[A].Jmeno;
End;
Function NextAgent(A : TAgentID; C : TColor) : TAgentID;
Begin
If A > AgentCnt Then RunError(201);
NextAgent := Agents[A].Vizitky[C];
End;
Procedure AgentPosition(A : TAgentID; Var X, Y : Real);
Begin
If A > AgentCnt Then RunError(201);
X := Agents[A].Pozice.X;
Y := Agents[A].Pozice.Y;
End;
Procedure TeamPosition(Var X, Y : Real);
Begin
X := Team.X;
Y := Team.Y;
End;
Function FriendAgent : TAgentID;
Begin
FriendAgent := FAgent;
End;
Function InitialTickets(i : TTicketIndex) : TAgentID;
Begin
InitialTickets := Tickets[i];
End;
End.