dimanche 31 mars 2019

Is there a way to bridge differences between given code and implementation?

In a snake game, the game model doesen't support the implementation that I would like to use.

I'm taking part in a friendly competition of who can write the best AI for a snake game. The game model is a given, we cannot change anything in it. I would like to implement an A* pathfinding AI. The problem is that the coordinates in the games are written in a way that they don't support this solution. The nodes that i would like to use look like the example below.

public final class Coordinate {

    private final int x;
    private final int y;
    }

public class Node {

    private int aStarValueG;
    private int aStarValueF;
    private int aStarValueH;
    private int coordinateX;
    private int coordinateY;
    private boolean isBlocked;
    private Node parent;
    }

I am looking for a way to brigde the differences between the 2 classes. I would like my AI to communicate with the coordinates through the nodes, and vice-verse. I'm familiar with design patterns, and I feel like they are the solution to this problem, but I don't know how. I'm also open to any other suggestions. Thanks.

Aucun commentaire:

Enregistrer un commentaire