//下一步棋 protected virtual void Step() { //随机一点 List <int> posList = new List <int>(); for (int i = 0; i < _target.map.map.Length; i++) { for (int j = 0; j < _target.map.map[i].Length; j++) { if (_target.map.map[i][j] == 0) { posList.Add(i * 15 + j); } } } if (posList.Count > 0) { int pos = posList[UnityEngine.Random.Range(0, posList.Count)]; int x = pos / 15 + 1; int y = pos % 15 + 1; Map.Cmd cmd = new Map.Cmd(); cmd.camp = _target.camp; cmd.x = x; cmd.y = y; _target.map.Do(cmd); } else { Debug.Log("无地可下"); } }
public void Do(Map.Cmd c) { if (c.camp == Camp.White) { c.chessObject = GameObject.Instantiate <GameObject>(chessPrefabWhite.gameObject, chessRoot); } else { c.chessObject = GameObject.Instantiate <GameObject>(chessPrefabBlack.gameObject, chessRoot); } RectTransform rc = c.chessObject.transform as RectTransform; rc.anchoredPosition = GetChessWorldPos(c.x, c.y); }
protected override void Step() { Map.Cmd Cmd = Net.Update(_target.map); if (Cmd != null) { _target.map.Do(Cmd); ////增加适应性分数 //if (Cmd.EatedHistory != null) //{ // double changed = 0; // switch (Cmd.EatedHistory.chessType) // { // case EChessType.Bing: // changed += 20; // break; // case EChessType.Ju: // changed += 50; // break; // case EChessType.Ma: // changed += 30; // break; // case EChessType.Pao: // changed += 30; // break; // case EChessType.Shi: // changed += 30; // break; // case EChessType.Xiang: // changed += 30; // break; // case EChessType.Shuai: // changed += 100; // break; // default: // changed -= 1; // break; // } if (_target.map.gameOver) { Fitness += 10; } Fitness = Mathf.Max((float)Fitness, 0); //} } }
public Map.Cmd Update(Map inputs) { //List<Map.Cmd> CmdList = GetCommandList(inputs); //if (CmdList.Count == 0) //{ // return null; //} _outputNode.SetInputPos(GetInputsRate(inputs)); double[] outputs = Update(GetInputs(inputs)); int index = Mathf.FloorToInt((float)(outputs[0])); Map.Cmd cmd = new Map.Cmd(); cmd.x = index / 15 + 1; cmd.y = index % 15 + 1; cmd.camp = inputs.currentCamp; return(cmd); }
List <Map.Cmd> GetCommandList(Map input) { List <Map.Cmd> R = new List <Map.Cmd>(); for (int i = 0; i < input.map.Length; i++) { for (int j = 0; j < input.map[i].Length; j++) { if (input.map[i][j] == 0) { Map.Cmd cmd = new Map.Cmd(); cmd.x = i + 1; cmd.y = j + 1; cmd.camp = input.currentCamp; R.Add(cmd); } } } return(R); }
public override void Update(float deltaTime) { base.Update(deltaTime); //选择棋子 if (Input.GetMouseButtonDown(0)) { RectTransform rt = UIChessboard.Instance.chessRoot as RectTransform; Vector2 pos; if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rt, (Input.mousePosition), uiCamera, out pos)) { Map.Cmd cmd = new Map.Cmd(); int x, y; UIChessboard.Instance.GetChessPos(pos, out x, out y); cmd.x = x; cmd.y = y; cmd.camp = _target.camp; _target.map.Do(cmd); } } }
public void UnDo(Map.Cmd c) { GameObject.Destroy(c.chessObject); }