private Result getNode(int curDepth, int agentIdx, ClientGameState curState) { Player me = curState.Me; Player opponent = curState.Opponent; this.nodesSearched++; if (agentIdx == 0) { curDepth++; if (nodesSearched % 1000 == 0) { this.debugWindow.AddLog("Searched " + this.nodesSearched + " nodes..."); } } else { me = curState.Opponent; opponent = curState.Me; } if ((curDepth == this.searchDepth) || (curState.Won == true) || (curState.Lost == true)) { double score = curState.Evaluate(); ActionSet actions = new ActionSet(me.units.Count); for (int idx = 0; idx < me.units.Count; idx++) { actions[idx] = Action.NONE; } return new Result(score, actions); } Result result; if (agentIdx == 0) { result = this.getMax(curDepth, agentIdx, curState); } else { result = this.getMin(curDepth, agentIdx, curState); } return result; }
private Result getNode(int curDepth, int agentIdx, ClientGameState curState, double alpha, double beta) { Player me = curState.Me; Player opponent = curState.Opponent; this.nodesSearched++; if (agentIdx == 0) { curDepth++; if (nodesSearched % 1000 == 0) { this.debugWindow.AddLog("Searched " + this.nodesSearched + " nodes..."); } } else { me = curState.Opponent; opponent = curState.Me; } if (me.bullets.Count < 1 || curDepth > 15) { #if DEBUG if ((curDepth >= this.searchDepth) || (curState.Won == true) || (curState.Lost == true)) #else if ((curDepth == this.searchDepth) || (curState.Won == true) || (curState.Lost == true) || (searchDuration.ElapsedMilliseconds > 2800)) #endif { double score = curState.Evaluate(); //Program.abDebug.WriteLine(String.Join(",", moveStack) + " - " + curDepth.ToString() + ":" + score.ToString()); ActionSet actions = new ActionSet(me.units.Count); for (int idx = 0; idx < me.units.Count; idx++) { actions[idx] = Action.NONE; } return new Result(score, actions); } } Result result; if (agentIdx == 0) { result = this.getMax(curDepth, agentIdx, curState, alpha, beta); } else { result = this.getMin(curDepth, agentIdx, curState, alpha, beta); } return result; }