src/main/java/ru/alphatech/icfpc/policy/AttackHelpPolicy.java
changeset 115 21f9fa7770cc
parent 108 4e9f892684f2
child 120 f8c080bbb572
equal deleted inserted replaced
114:56ba7b1ef026 115:21f9fa7770cc
    59 		
    59 		
    60 		retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), donorSlotIndex));
    60 		retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), donorSlotIndex));
    61 		retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex));
    61 		retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex));
    62 		retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(2), pointsSlotIndex));
    62 		retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(2), pointsSlotIndex));
    63 		
    63 		
    64 		retArray.addAll(BcombineForFunctWith3ParamsInRegister(getCard(), processingSlot));
    64 //		retArray.addAll(BcombineForFunctWith3ParamsInRegister(getCard(), processingSlot));
       
    65 		retArray.addAll(BcombineForFunctWith3ParamsInRegister2(getCard(), processingSlot));
    65 		
    66 		
    66 		return retArray;
    67 		return retArray;
    67 	}
    68 	}
    68 	
    69 	
    69 	public ICard getCard(){
    70 	public ICard getCard(){
    70 		return type == TYPE.ATTACK ? new Attack() : new Help();
    71 		return type == TYPE.ATTACK ? new Attack() : new Help();
    71 	}
    72 	}
    72 	
    73 	
       
    74 
       
    75 
       
    76 	/**
       
    77 	 * С корректировкой регистров
       
    78 	 * @param function
       
    79 	 * @param processingSlot
       
    80 	 * @return
       
    81 	 */
       
    82 	protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister2(ICard function, Slot processingSlot)
       
    83 	{
       
    84 		ArrayList<Batch> retArray = new ArrayList<Batch>();
       
    85 		
       
    86 		if(!(function instanceof Attack || function instanceof Help)){
       
    87 			throw new ICFPCException();
       
    88 		}
       
    89 				
       
    90 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
       
    91 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, function,  processingSlot));
       
    92 		
       
    93 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
       
    94 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
       
    95 		
       
    96 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
       
    97 		
       
    98 		retArray.addAll(correctRegister(0, processingSlot));
       
    99 		
       
   100 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
       
   101 		
       
   102 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
       
   103 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
       
   104 		
       
   105 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
       
   106 
       
   107 		retArray.addAll(correctRegister(1, processingSlot));
       
   108 		
       
   109 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
       
   110 		
       
   111 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
       
   112 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
       
   113 		
       
   114 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
       
   115 	
       
   116 		retArray.addAll(correctRegister(2, processingSlot));
       
   117 		
       
   118 		if(execute)
       
   119 			retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
       
   120 		
       
   121 		return retArray;
       
   122 	}
       
   123 	
       
   124 	/***
       
   125 	 * @deprecated
       
   126 	 * @param function
       
   127 	 * @param processingSlot
       
   128 	 * @return
       
   129 	 */
    73 	protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister(ICard function, Slot processingSlot)
   130 	protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister(ICard function, Slot processingSlot)
    74 	{
   131 	{
    75 		ArrayList<Batch> retArray = new ArrayList<Batch>();
   132 		ArrayList<Batch> retArray = new ArrayList<Batch>();
    76 		
   133 		
    77 		if(!(function instanceof Attack || function instanceof Help)){
   134 		if(!(function instanceof Attack || function instanceof Help)){
    78 			throw new ICFPCException();
   135 			throw new ICFPCException();
    79 		}
   136 		}
    80 		
       
    81 		//TODO Абстрагироваться от регистров
       
    82 		
   137 		
    83 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
   138 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
    84 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, function,  processingSlot));
   139 		retArray.add(new Batch(OperationType.SLOT_TO_CARD, function,  processingSlot));
    85 		
   140 		
    86 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   141 		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   120 		if(execute)
   175 		if(execute)
   121 			retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
   176 			retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
   122 		
   177 		
   123 		return retArray;
   178 		return retArray;
   124 	}
   179 	}
   125 
       
   126 
       
   127 }
   180 }