# AI for 1v1 snake

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
{
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?

• defeat their basic AI on what metric? – Theraot Jun 17 '20 at 9:42
• Probably not a big deal, but, I can't figure out what getSnakePiece is meant to do. – Theraot Jun 17 '20 at 9:50
• 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. – Theraot Jun 17 '20 at 9:56
• Wouldn't receiving our help constitute cheating on your application test? – Philipp Jun 17 '20 at 10:07
• Remember that this website is public, so your employer can always search, find who gave you the answer, and hire them instead. 😉 – DMGregory Jun 17 '20 at 10:50