Logic3.adb

-- Returns move depending on other players
-- last 10 moves. When in doubt cooperate.

function Logic3 return Move is
   NDef: Integer;
begin
   if MN > 10 then
      NDef:=0;
      for I in MN-10..MN-1 loop
         if(OppMoves(I)=Defect) then NDef:=NDef+1; end if;
      end loop;
      case NDef is
         when 9..10 => return Defect;
         when 6..8 =>
            if OppMoves(MN-1)=Defect then
               return Defect;
            else return Cooperate;
            end if;
         when 3..5 =>
            if ((OppMoves(MN-1)=Cooperate)
                and (OppMoves(MN-2)=Cooperate)) then
               return Cooperate;
            else return Cooperate;
            end if;
         when others => return Cooperate;
      end case;
   else
      return Cooperate;
   end if;
end Logic3;

Tillbaka till huvudsidan