-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bot like a python kit. Fixed Random. !!! Mixed up axes in board 2d ar…
…ray (bug or feature?).
- Loading branch information
Alexey Pogasiy
committed
Nov 27, 2022
1 parent
00a425d
commit 5057d0e
Showing
9 changed files
with
305 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.luxai.lux; | ||
|
||
public class MoveUtils { | ||
|
||
public static final int X = 0; | ||
public static final int Y = 1; | ||
|
||
public static final int MOVE_CENTER = 0; | ||
public static final int MOVE_DOWN = 1; | ||
public static final int MOVE_RIGHT = 2; | ||
public static final int MOVE_UP = 3; | ||
public static final int MOVE_LEFT = 4; | ||
|
||
public static final int MOVE_UNAVAILABLE = -1; | ||
|
||
public static int getManhattanDistance(int x1, int y1, int x2, int y2) { | ||
return (Math.abs(x1 - x2) + Math.abs(y1 - y2)); | ||
} | ||
|
||
public static int getDirection(int xSource, int ySource, int xTarget, int yTarget) { | ||
int dx = xTarget - xSource; | ||
int dy = yTarget - ySource; | ||
|
||
if (dx == 0 && dy == 0) | ||
return MOVE_CENTER; | ||
|
||
if (Math.abs(dx) > Math.abs(dy)) { | ||
if (dx > 0) | ||
return MOVE_RIGHT; | ||
else | ||
return MOVE_LEFT; | ||
} | ||
else { | ||
if (dy > 0) | ||
return MOVE_UP; | ||
else | ||
return MOVE_DOWN; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package com.luxai.lux; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class State { | ||
|
||
public Obs obs; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters