1
我有以下幾點:的Java:檢查是否在迴路電流項是堆棧中的最後一個項目繞環
public Move nextBestMove(Stack<Move> possibleMoves, Stack<Square> enemyPieces){
int highestWeight;
Move best = null;
for(Move move: possibleMoves){
Square landing = move.getLanding();
int landingX = move.getLandingXC();
int landingY = move.getLandingYC();
int score = scoring(enemyPiece.pieceName()){
if(score > highestWeight){
highestWeight = score;
best = move;
if(!possibleMoves.hasNext()){ //Check if i am at end of stack
return best;
else{
continue;
}
}
}
}
}
我想評價一個簡單的棋牌戰略實施做出最好的舉動,通過不斷更新基於權重的最佳舉措。不過,我不確定如何檢查我是否處於循環中的最後一項。
我知道我可以使用.hasNext()
作爲列表,但是如何通過Stack實現類似的循環?
使用迭代器。 – shmosel