public void move(Map world) { setOldPos(getPos()); if (frindly) { int des = 1 + rand.nextInt(4); switch (des) { case 1: moveTo(new Position(getPos().getX() - 1, getPos().getY()), world); break; case 2: moveTo(new Position(getPos().getX() + 1, getPos().getY()), world); break; case 3: moveTo(new Position(getPos().getX(), getPos().getY() - 1), world); break; case 4: moveTo(new Position(getPos().getX(), getPos().getY() + 1), world); break; case 5: break; default: } } else { if (path != null) { if (path.hasNext()) moveTo(path.getNext(), world); } if (target == null) { target = world.find_player(getPos()); } else { path = world.getGraph(getPos(), target.getPos()).findShortestPath(); } } if (getPos() == getOldPos()) setMoving(no_move); }