开发者

Using search to solve the 15-puzzle

开发者 https://www.devze.com 2022-12-31 02:45 出处:网络
I\'m trying to write a 4 x 4 grid using verti开发者_如何转开发cal bars and underscore. I have a class for the puzzle, but i want to know what fields and methods i can use to represent and manipulate a

I'm trying to write a 4 x 4 grid using verti开发者_如何转开发cal bars and underscore. I have a class for the puzzle, but i want to know what fields and methods i can use to represent and manipulate a configuration for the puzzle.

Reference: Fifteen puzzle


I agree, you could give more information... however, consider an approach like this:

In your puzzle class, you may have a Value[][] member for storing the values. You could do something like this

public Value get(int x, int y) {
    return values[x][y];
}

public void set(int x, int y, Value v) {
    values[x][y] = v;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消