0
\$\begingroup\$

I've got a task for job application to create a snake AI that can defeat their basic AI. Searching in this topic I've found that it's very similar to Tron and it's solved mostly by minimax algorithm. But my problem is that I've got an interface defined, and I can only acces these from the AI class:

public interface Data
{
    Point getFoodPosition();
    Body getSnake(int i);
    int getSnakePiece();
    BoardElements getBoardElement(int x, int y);
    Size getBoardSize();
}

public interface Body
{
    Point getHead();
    int getLength();
    Directions getDirection();
    Point? getBodyPiece(int i);
    Point getEnd();
    void setSnakeColor(Color color);
}

I can't see their AI's code, because it's in a DLL. I can't access the whole map to then pass it. I could get each element from the map, but that would be a dirty solution in my opinion. But without it I can only do ineffective solutions. I've tried to create a heuristic based on distance of the food, but it seems not complex enough. What do you think, how should I approach this problem?

\$\endgroup\$
8
  • 1
    \$\begingroup\$ defeat their basic AI on what metric? \$\endgroup\$
    – Theraot
    Commented Jun 17, 2020 at 9:42
  • \$\begingroup\$ Probably not a big deal, but, I can't figure out what getSnakePiece is meant to do. \$\endgroup\$
    – Theraot
    Commented Jun 17, 2020 at 9:50
  • \$\begingroup\$ Anyway, an importante challenge in snake AI is leaving a way out. Sometimes the shortest path to the food will result in not enough space for the snake to move afterwards. Meaning that the snake must take a longer path, to ensure the tail gets out of the way, to ensure that after eating the food, there is room to move. And no, longest path does not solve that either. The longest path will tend to fill the space, again leaving no room. \$\endgroup\$
    – Theraot
    Commented Jun 17, 2020 at 9:56
  • 3
    \$\begingroup\$ Wouldn't receiving our help constitute cheating on your application test? \$\endgroup\$
    – Philipp
    Commented Jun 17, 2020 at 10:07
  • 3
    \$\begingroup\$ Remember that this website is public, so your employer can always search, find who gave you the answer, and hire them instead. 😉 \$\endgroup\$
    – DMGregory
    Commented Jun 17, 2020 at 10:50

0

You must log in to answer this question.

Browse other questions tagged .