public MainWindow() { _results = new Results(); _theory = new TheoreticalData(); _mapControl = new MapControl(); _mapInput = new MapInput(_mapControl); InitializeComponent(); _inputView.RunAlgorithm += RunAlgorithm; _inputView.StepAlgorithm += StepAlgorithm; _inputView.ResetAlgorithm += ResetAlgorithm; _inputView.PauseAlgorithm += PauseAlgorithm; //Algorithm a = new Algorithm(); //a.Execute(); //var map = this.FindResource("MapViewGrid") as Grid; //map. //sbLevel.Begin(); MapConfigGrid.Children.Add(_mapInput); MapViewGrid.Children.Add(_mapControl); MapViewGrid.Width = _mapControl.Width; ConfigGrid.Children.Add(_inputView); ConfigGrid.Width = _inputView.Width; TheoryGrid.Children.Add(_theory); TheoryGrid.Width = _theory.Width; ResultsGrid.Children.Add(_results); }
public void TestAStar() { Map map = new Map(); map.LoadMap(Path.Combine("Resources/Maps", "small.map")); Simulation sim = new ClientSimulation(map); Unit u = new UnitTrooper(new ObjectID(1, 1), GlobalSettings.Wrapper.Troopers[0], new Position(0, 0), map, sim); map.Units[0, 1].AddFirst(u); map.Units[1, 1].AddFirst(u); map.Units[2, 1].AddFirst(u); map.Units[3, 0].AddFirst(u); map.Units[4, 1].AddFirst(u); map.Units[3, 2].AddFirst(u); map.Units[4, 2].AddFirst(u); map.Units[3, 3].AddFirst(u); MapInput mi = new MapInput(map); mi.IsMoveable += new MapInput.MoveCheckDelegate(IsMoveable); mi.Start = new Position(0, 0); mi.Goal = new Position(15, 17); Queue <Position> path = AStar.Search <Position>(mi); if (path.Count != 0) { Console.WriteLine("OK"); } }
public async Task <ResultDto> Add(MapInput item) { var result = new ResultDto { Message = "" }; try { var map = _mapper.Map <MapEntity>(item); await _mapDomainService.Add(map); await _operatorLogDomainService.AddSuccess(new OperatorLogEntity { Type = OperatorLogType.添加地图, Content = JsonConvert.SerializeObject(item) }); await Commit(); result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; await _operatorLogDomainService.AddError(new OperatorLogEntity { Type = OperatorLogType.添加地图, Content = $"Data={JsonConvert.SerializeObject(item)},ErrorMessage={result.Message}" }); await Commit(); } return(result); }
public Unit(ObjectID id, short typeID, String ammo, BoardObjectClass boc, Position pos, Map map, Simulation sim, short ammoDamageRange, short damageDestroyRange, short damageDestroy, short ammoSpeed) : base(id, boc, pos) { this._typeID = typeID; this._map = map; this._simulation = sim; this._lastPosition = pos; this._direction = Direction.North; this._currentPath = new Queue <Position>(); this._damageDestroy = damageDestroy; this.damageDestroyRange = damageDestroyRange; this.ammoDamageRange = ammoDamageRange; this._mapInput = new MapInput(sim.Map); this._mapInput.IsMoveable += new MapInput.MoveCheckDelegate(this.IsMoveable); this._ammoSpeed = ammoSpeed; if (ammo == "Bullet") { this._ammoType = AmmoType.Bullet; } else if (ammo == "Rocket") { this._ammoType = AmmoType.Rocket; } else if (ammo == "Sonic") { this._ammoType = AmmoType.Sonic; } else { this._ammoType = AmmoType.None; } }
/// <summary> /// 初始化會導致 Sensor 被呼叫,應該在 MainLoop 可以開始遊戲時再呼叫 /// </summary> public void Init(MapInput mapInput, ScoreBoard scoreBoard) { this.enableSensorInput = (enabled) => mapInput.enabled = enabled; this.updateDepotUI = (state) => scoreBoard.UpdateDepot(state); List <IBus> busQueue = InitBusQueue(); foreach (var bus in busQueue) { RecycleBus(bus); } }
void Awake() { this.input = this.GetComponent <MapInput> (); this.input.SelectStarted += this.OnStarted; this.input.SelectEnded += this.OnEnded; this.input.SelectProcessing += this.OnProcessing; var go = GameObject.Instantiate(this.linePrefab.gameObject, this.transform); go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; this.lineInstance = go.GetComponent <LineRenderer>(); }
public async Task <ResultDto> Update(int id, MapInput item) { var result = new ResultDto { Message = "" }; try { var map = await _mapDomainService.Get(id); if (map == null) { result.Message = $"地图 {id} 不存在!"; return(result); } var content = map.ComparisonTo(item); _mapper.Map(item, map); await _mapDomainService.Update(map); await _operatorLogDomainService.AddSuccess(new OperatorLogEntity { Type = OperatorLogType.修改地图, Content = $"Id = {id},Data = {content}" }); await Commit(); result.IsSuccess = true; } catch (Exception ex) { result.Message = ex.Message; await _operatorLogDomainService.AddError(new OperatorLogEntity { Type = OperatorLogType.修改地图, Content = $"Data={JsonConvert.SerializeObject(item)},ErrorMessage={result.Message}" }); await Commit(); } return(result); }
/// <summary> /// 向前传播,返回的是每个样本展开的一维数组值 /// </summary> /// <returns></returns> private double[,] neuralnetworkforward() { //获取样本的总数量 int sampleCount = MapInput.GetLength(0); //第一层进行卷积 var towValues = forward(MapInput, 0); var threeValues = forward(towValues, 1); var Values = forward(threeValues, 2); int CurDepth = Values.GetLength(1); CurRow = Values.GetLength(2); CurColumn = Values.GetLength(3); LMatrix inputFeature = new double[sampleCount, CurDepth *CurRow *CurColumn]; for (int index = 0; index < sampleCount; index++) { PercentTitle = "当前样本向前传播中"; inputFeature[index] = Values.GetNextDimVal2(index, CurDepth, CurRow, CurColumn).Flatten(); Percent = index / sampleCount; } return(inputFeature.Matrix); }
private void Reset() { this.map = this.GetComponentInChildren <Map> (); this.mapInput = this.GetComponentInChildren <MapInput> (); }