public BeingCharacteristics Construct(ulong step, float ci) { //При создании существа вызывается этот метод. В нём стоит определить, какие характеристики должны быть у существа. var being = new BeingCharacteristics((ci - 13.0f) / 0.8f, 3.0f, 4); //Стоимость получения характеристик смотри в правилах игры. stepCost = being.MaxHealth / 100.0f; //В нём же можно инициализировать все свойства. return(being); }
public BeingCharacteristics Construct(ulong step, float ci) { BeingCharacteristics result = _intellect.Construct(step, ci); return(result); //Таким образом, вызываем метод Construct у проверяемой библиотеки, //с уже навешенной проверкой безопасности. }
/// <summary> /// This method is called on every being creation. Your intellect should distribute Ci to being abilities. /// </summary> /// <param name="step">Step of the match</param> /// <param name="ci">Ci available for the constructing being.</param> /// <returns>Desired characteristic of the future being.</returns> public BeingCharacteristics Construct(ulong step, float ci) { //Being characteristics may be different. It's you to decide. But remember about the cost. BeingCharacteristics newCharacteristics = new BeingCharacteristics((ci - 13.0f) / 0.8f, 3.0f, 4); stepCost = newCharacteristics.MaxHealth * newCharacteristics.MaxStep * 0.01f; return(newCharacteristics); }
public GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { //Каждый ход у каждого существа вызывается данный метод. Метод должен вернуть желаемое действие. if (characteristics.Health < characteristics.MaxHealth && characteristics.Ci > characteristics.MaxHealth * 0.6f) { return(selfHeal(characteristics)); } else if (characteristics.Ci > 13.0f + characteristics.MaxHealth * 0.8f) { return(new GameActionMakeOffspring(characteristics.Id, 13.0f + characteristics.MaxHealth * 0.8f)); } else { return(goEat(characteristics, area)); } }
/// <summary> /// Main function of the being. Here your code must make decision what the being shoud do. /// </summary> /// <param name="step">Current game step</param> /// <param name="characteristics">Currnet characteristics of this being.</param> /// <param name="area">Information about world in the visiable area.</param> /// <returns>GameAction that represents decision.</returns> public GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { // Here you can place a lot of decisions if (characteristics.Health < characteristics.MaxHealth && characteristics.Ci > characteristics.MaxHealth * 0.6f) { return(selfHeal(characteristics)); } else if (characteristics.Ci > 13.0f + characteristics.MaxHealth * 0.8f) { return(new GameActionMakeOffspring(characteristics.Id, 13.0f + characteristics.MaxHealth * 0.8f)); } else { return(goEat(characteristics, area)); } }
public GameEventBirth(Guid creator, BeingCharacteristics newborn) : base(creator) { EventType = EventTypes.GameEventBirth; Newborn = new BeingCharacteristics() { Ci = newborn.Ci, Health = newborn.Health, Id = newborn.Id, MaxHealth = newborn.MaxHealth, MaxSeeDistance = newborn.MaxSeeDistance, MaxStep = newborn.MaxStep, Team = newborn.Team, X = newborn.X, Y = newborn.Y, }; }
public GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { if (taskNumber == 9) { taskNumber = 1; } else { taskNumber++; } switch (taskNumber) { case 1: return(new GameActionMakeOffspring(characteristics.Id, 10.0f)); case 2: return(new GameActionEat(characteristics.Id)); case 3: return(new GameActionMove(characteristics.Id, 1, 0)); case 4: return(new GameActionMove(characteristics.Id, 0, 1)); case 5: return(new GameActionMove(characteristics.Id, -1, 0)); case 6: return(new GameActionMove(characteristics.Id, 0, -1)); case 7: return(new GameActionAttack(characteristics.Id, 0, 0, 1.0f)); case 8: return(new GameActionTreat(characteristics.Id, 0, 0, 3.0f)); case 9: return(new GameActionGiveCi(characteristics.Id, 0, 0, 1.0f)); } return(new GameActionEat(characteristics.Id)); }
/// <summary> /// Heal itself /// </summary> /// <param name="characteristics">Being characteristics</param> /// <returns>Return computed action</returns> private GameAction selfHeal(BeingCharacteristics characteristics) { float _ci = 0.0f; if (characteristics.Ci >= (characteristics.MaxHealth - characteristics.Health) * 3.0f) //Заметьте, он не проверяет, сколько энергии останется. А она нужна для того, чтобы жить. { //Heal itself fully if it can _ci = (characteristics.MaxHealth - characteristics.Health) * 3.0f; if (_ci > characteristics.Ci * 0.6f) { //If more than one permitted then reduces _ci = characteristics.Ci * 0.6f; } } else { _ci = Math.Abs(characteristics.Ci); } return(new GameActionTreat(characteristics.Id, 0, 0, _ci)); //In relative coordinates }
/// <summary> /// Лечит себя. /// </summary> /// <param name="characteristics">Характеристики существа</param> /// <returns>Возвращает рассчитанное действие</returns> private GameAction selfHeal(BeingCharacteristics characteristics) { float _ci = 0.0f; if (characteristics.Ci >= (characteristics.MaxHealth - characteristics.Health) * 3.0f) //Заметьте, он не проверяет, сколько энергии останется. А она нужна для того, чтобы жить. { //Если энергии хватает--лечит себя полностью. _ci = (characteristics.MaxHealth - characteristics.Health) * 3.0f; if (_ci > characteristics.Ci * 0.6f) { //Если получилось больше разрешённого (В лечение можно вливать <= 60% текущей энергии), уменьшает до разрешённого. _ci = characteristics.Ci * 0.6f; } } else { _ci = Math.Abs(characteristics.Ci); } return(new GameActionTreat(characteristics.Id, 0, 0, _ci)); //Лечение "бьёт" по относительным координатам. }
/// <summary> /// Moves to the most appetizing cell within reach /// </summary> /// <param name="characteristics">Being characteristics</param> /// <param name="area">Part of the world to looking-for</param> /// <returns>Return preferable action </returns> private GameAction goEat(BeingCharacteristics characteristics, WorldInfo area) { Vector _bestCell = new Vector(); float _bestCellScore = 0.0f; int _maxStep = (int)(characteristics.Ci / stepCost); if (_maxStep > characteristics.MaxStep) { _maxStep = (int)characteristics.MaxStep; } for (int i = -area.Distance; i < area.Distance; i++) { for (int j = -area.Distance; j < area.Distance; j++) { int _distance = Math.Abs(i) + Math.Abs(j); float _profit = area[i, j].Ci - stepCost * (float)(_distance); if (_profit > _bestCellScore && _distance <= _maxStep) { _bestCellScore = _profit; _bestCell.X = i; _bestCell.Y = j; } } } if (_bestCell.X == 0 && _bestCell.Y == 0) { return(new GameActionEat(characteristics.Id)); } else { return(new GameActionMove(characteristics.Id, _bestCell.X, _bestCell.Y)); } }
/// <summary> /// Calls think of custom being. /// </summary> /// <param name="turnNumber">Current time step</param> /// <param name="characteristics">Updated characteristics of the being.</param> /// <param name="area">Array of IWorldCell around the being describes visible part of the world. Array is (MaxSeeDistance*2+1)^2, with the being in central cell</param> /// <returns>Decided action of the being. May be NULL.</returns> public GameAction Think(ulong turnNumber, BeingCharacteristics characteristics, WorldInfo area) { // todo add here catch(){} return(Me.Think(turnNumber, characteristics, area)); }
public GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { return(new GameActionEat(characteristics.Id)); }
public Contracts.Intellect.Actions.GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { return(proxyIntellect.Think(0, characteristics, area)); }
public GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { float[,] MapOfInterest = new float[characteristics.MaxSeeDistance * 4 + 1, characteristics.MaxSeeDistance * 4 + 1];//Будем думать, куда лучше пойти. MapOfInterest.Initialize(); if ((PreX == -1) & (PreY == -1)) { PreX = characteristics.X; PreY = characteristics.Y; } MemoryUpdate(area, characteristics.X, characteristics.Y);//Обновляем карту памяти. if ((DesiredX != characteristics.X) | (DesiredY != characteristics.Y)) { PreX = characteristics.X; PreY = characteristics.Y; } /*План действий: * Если может, рожает. * Если дошёл, куда хотел, и есть, что поесть--ест. * Если и поесть нечего--ищет, куда бы пойти. * Иначе, если хотел куда-то идти--идёт туда.*/ #region 1.Рожает, если может if ((Semental == true) & (characteristics.Ci >= characteristics.MaxHealth * 0.97f)) { DesiredX = characteristics.X; DesiredY = characteristics.Y; return(new GameActionMakeOffspring(characteristics.Id, characteristics.MaxHealth * 0.95f)); } else if ((Semental == false) & (characteristics.Ci >= characteristics.MaxHealth * 0.6f)) { DesiredX = characteristics.X; DesiredY = characteristics.Y; return(new GameActionMakeOffspring(characteristics.Id, characteristics.MaxHealth * 0.5f)); } #endregion #region 2.Если дошёл, и есть, что поесть--ест. else if ((DesiredX == characteristics.X) & (DesiredY == characteristics.Y) & (area[0, 0].Ci != 0)) { return(new GameActionEat(characteristics.Id)); } #endregion #region 3.Обновление карты интереса. Поиск самой интересной точки. else if ((DesiredX == characteristics.X) & (DesiredY == characteristics.Y)) { for (int a = 0; a < characteristics.MaxSeeDistance * 4 + 1; a++) { float _maxInterest = 0; for (int b = 0; b < characteristics.MaxSeeDistance * 4 + 1; b++) { //Считаем проффит: энергия в клетке - трудозатраты на достижение клетки. MapOfInterest[a, b] = MemorizedArea[a, b] - characteristics.MaxStep * characteristics.MaxHealth / 100 * (Math.Abs(a - (characteristics.MaxSeeDistance * 2 + 1)) + Math.Abs(b - (characteristics.MaxSeeDistance * 2 + 1))); //Расстояние считается до центральной клетки. if (MapOfInterest[a, b] > _maxInterest) { _maxInterest = MapOfInterest[a, b]; DesiredX = a - (characteristics.MaxSeeDistance * 2 + 1) + characteristics.X;//Куда хочется пойти. DesiredY = b - (characteristics.MaxSeeDistance * 2 + 1) + characteristics.Y; } } } } #endregion #region 4.Идёт к интересной точке PreX = characteristics.X; PreY = characteristics.Y; //Если Х совпадает, идёт по Y. Если нет, пытается по обоим. Не получается--идёт по Y. Если совсем всё плохо--ест. if ((DesiredX == characteristics.X) & (characteristics.MaxStep >= 1) & (characteristics.Ci > characteristics.MaxHealth * 0.01f)) { return(new GameActionMove(characteristics.Id, 0, Math.Sign(DesiredY - characteristics.Y))); } else if ((characteristics.MaxStep >= 2) & (characteristics.Ci > 2.0f * characteristics.MaxHealth * 0.01f)) { return(new GameActionMove(characteristics.Id, Math.Sign(DesiredX - characteristics.X), Math.Sign(DesiredY - characteristics.Y))); } else if ((characteristics.MaxStep >= 1) & (characteristics.Ci > characteristics.MaxHealth * 0.01f)) { return(new GameActionMove(characteristics.Id, Math.Sign(DesiredX - characteristics.X), 0)); } else { return(new GameActionMove(characteristics.Id, 1, 1)); //return new GameActionEat(characteristics.Id); } #endregion }
public GameAction Think(ulong step, BeingCharacteristics characteristics, WorldInfo area) { return(_reference.Think(step, characteristics, area)); }