현재 게임 Othello를 코딩하려는 시도에서 getLegalMoves()
메소드를 코딩하려고합니다. 문제는 명확하게 정의 했음에도 불구하고 getLegalMoves()
메서드에서 기호를 찾을 수 없다는 것을 계속 말합니다.Java - getLegalMoves()에서 심볼을 찾을 수 없습니다.
int direction = (empty).getDirectionTowards(playeroccupied.get(c));
그래서 그 코드가 실패 정상입니다 :
ArrayList<Location> empty
그리고 목록은 getDirectionTowards(...)
방법이없는 :
public ArrayList <Location> getLegalMoves(String curColor)
{
ArrayList<Location> legalmoves = new ArrayList<Location>();
int i = 0;
ArrayList<Location> occupied = board.getOccupiedLocations();
ArrayList<Location> playeroccupied = new ArrayList<Location>();
ArrayList<Location> occupiedopposite = new ArrayList<Location>();
int b = 0;
while(b < occupied.size())
{
if(board.get(occupied.get(b)).equals(curColor) == false)
occupiedopposite.add(occupied.get(b));
else
playeroccupied.add(occupied.get(b));
b++;
}
int a = 0;
while(occupiedopposite.size() > i)
{
Location location = occupiedopposite.get(i);
while(board.getEmptyAdjacentLocations(location).size() > a)
{
ArrayList<Location> empty = (board.getEmptyAdjacentLocations(location));
Location emptyspot = empty.get(a);
int c = 0;
while(playeroccupied.size() > c)
{
int direction = (empty).getDirectionTowards(playeroccupied.get(c)); //this is the problem line, it can't find playerOccupied.get(c), I think
int d = 0;
Location checking = emptyspot.getAdjacentLocation(direction);
while(board.isValid(checking) && d != -1)
{
if(d == 0 && checking.equals("W"))
d = -1;
else if(checking.equals(null) || checking.equals("B"))
{
d++;
checking = checking.getAdjacentLocation(direction);
}
else if(checking.equals("W") && d != 0)
legalmoves.add(emptyspot);
}
c++;
}
a++;
}
i++;
}
return legalmoves;
}
그리고 어떤 오류가 발생합니까? –
나머지 코드는 어디에 있습니까? 당신은'''''''방법에서 이것을 부르시겠습니까? – djhworld
예외를 참조하십시오. – Kal