Skip to content

Commit

Permalink
Merge branch 'fix-bug-caused-by-reachable'
Browse files Browse the repository at this point in the history
  • Loading branch information
knewjade committed Dec 11, 2022
2 parents 265f388 + e992136 commit 6dcf70a
Show file tree
Hide file tree
Showing 111 changed files with 1,804 additions and 3,588 deletions.
1 change: 1 addition & 0 deletions kicks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The kicks here are for testing. The kicks for artifacts is at [distribution/kicks](/distribution/kicks).
106 changes: 106 additions & 0 deletions kicks/jstris180.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This kick was made by @metallicLurker in PC Gang.

L.NE=(0,0)(-1,0)(-1,+1)(0,-2)(-1,-2)
L.ES=(0,0)(+1,0)(+1,-1)(0,+2)(+1,+2)
L.SW=(0,0)(+1,0)(+1,+1)(0,-2)(+1,-2)
L.WN=(0,0)(-1,0)(-1,-1)(0,+2)(-1,+2)

L.NW=(0,0)(+1,0)(+1,+1)(0,-2)(+1,-2)
L.WS=(0,0)(-1,0)(-1,-1)(0,+2)(-1,+2)
L.SE=(0,0)(-1,0)(-1,+1)(0,-2)(-1,-2)
L.EN=(0,0)(+1,0)(+1,-1)(0,+2)(+1,+2)

L.NS=(0,0)(0,+1)
L.EW=(0,0)(+1,0)
L.SN=(0,0)(0,-1)
L.WE=(0,0)(-1,0)

J.NE=&L.NE
J.ES=&L.ES
J.SW=&L.SW
J.WN=&L.WN

J.NW=&L.NW
J.WS=&L.WS
J.SE=&L.SE
J.EN=&L.EN

J.NS=&L.NS
J.EW=&L.EW
J.SN=&L.SN
J.WE=&L.WE

S.NE=&L.NE
S.ES=&L.ES
S.SW=&L.SW
S.WN=&L.WN

S.NW=&L.NW
S.WS=&L.WS
S.SE=&L.SE
S.EN=&L.EN

S.NS=&L.NS
S.EW=&L.EW
S.SN=&L.SN
S.WE=&L.WE

Z.NE=&L.NE
Z.ES=&L.ES
Z.SW=&L.SW
Z.WN=&L.WN

Z.NW=&L.NW
Z.WS=&L.WS
Z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@@ -1,7 +1,7 @@
package common;

import common.datastore.Operation;
import core.action.reachable.LockedReachable;
import core.action.reachable.ILockedReachable;
import core.field.Field;
import core.mino.Mino;
import core.mino.MinoFactory;
Expand All @@ -21,15 +21,15 @@
public class SpinChecker {
private final MinoFactory minoFactory;
private final MinoRotationDetail minoRotationDetail;
private final LockedReachable lockedReachable;
private final ILockedReachable lockedReachable;
private final List<RotateDirection> rotations;

public SpinChecker(MinoFactory minoFactory, MinoRotationDetail minoRotationDetail, LockedReachable lockedReachable) {
public SpinChecker(MinoFactory minoFactory, MinoRotationDetail minoRotationDetail, ILockedReachable lockedReachable) {
this(minoFactory, minoRotationDetail, lockedReachable, false);
}

public SpinChecker(
MinoFactory minoFactory, MinoRotationDetail minoRotationDetail, LockedReachable lockedReachable,
MinoFactory minoFactory, MinoRotationDetail minoRotationDetail, ILockedReachable lockedReachable,
boolean use180Rotation
) {
this.minoFactory = minoFactory;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/common/cover/B2BContinuousCover.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import common.datastore.MinoOperation;
import common.datastore.MinoOperationWithKey;
import common.datastore.SimpleMinoOperation;
import core.action.reachable.LockedReachable;
import core.action.reachable.ILockedReachable;
import core.action.reachable.ReachableFacade;
import core.field.Field;
import core.field.KeyOperators;
import core.mino.Mino;
Expand Down Expand Up @@ -38,7 +39,7 @@ public B2BContinuousCover(MinoRotation minoRotation, boolean use180Rotation) {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotationDetail minoRotationDetail = new MinoRotationDetail(minoFactory, minoRotation);
LockedReachable lockedReachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxY);
ILockedReachable lockedReachable = ReachableFacade.createLocked(minoFactory, minoShifter, minoRotation, maxY, use180Rotation);
SpinChecker spinChecker = new SpinChecker(minoFactory, minoRotationDetail, lockedReachable, use180Rotation);

this.b2BCondition = (Field field, int height, MinoOperation key) -> {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/common/cover/TSpinCover.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import common.cover.reachable.ReachableForCover;
import common.datastore.MinoOperationWithKey;
import common.datastore.SimpleMinoOperation;
import core.action.reachable.LockedReachable;
import core.action.reachable.ILockedReachable;
import core.action.reachable.ReachableFacade;
import core.field.Field;
import core.field.KeyOperators;
import core.mino.Mino;
Expand Down Expand Up @@ -76,7 +77,7 @@ private TSpinCover(MinoRotation minoRotation, TSpinCondition tSpinCondition, TSp
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotationDetail minoRotationDetail = new MinoRotationDetail(minoFactory, minoRotation);
LockedReachable lockedReachable = new LockedReachable(minoFactory, minoShifter, minoRotation, maxY);
ILockedReachable lockedReachable = ReachableFacade.createLocked(minoFactory, minoShifter, minoRotation, maxY, use180Rotation);
this.spinChecker = new SpinChecker(minoFactory, minoRotationDetail, lockedReachable, use180Rotation);
this.initGuard = initGuard;
this.tSpinCondition = tSpinCondition;
Expand Down Expand Up @@ -229,6 +230,7 @@ private boolean existsValidByOrderWithHold(
return piece != null && existsValidByOrderWithHold(field, eachBlocks, pieces, height, reachable, maxDepth, depth, piece, deleteKey, hold, guard);
}


private boolean existsValidByOrderWithHold(Field field, EnumMap<Piece, LinkedList<MinoOperationWithKey>> eachBlocks, List<Piece> pieces, int height, ReachableForCover reachable, int maxDepth, int depth, Piece usePiece, long deleteKey, Piece nextHoldPiece, TSpinGuard guard) {
LinkedList<MinoOperationWithKey> operationWithKeys = eachBlocks.get(usePiece);
if (operationWithKeys == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package common.cover.reachable;

import core.action.reachable.LockedReachable;
import core.action.reachable.ILockedReachable;
import core.action.reachable.Reachable;
import core.action.reachable.ReachableFacade;
import core.field.Field;
import core.mino.Mino;
import core.mino.MinoFactory;
Expand All @@ -10,13 +11,13 @@

public class LastSoftdropReachableForCover implements ReachableForCover {
private final Reachable reachable;
private final LockedReachable lockedReachable;
private final ILockedReachable lockedReachable;
private final int allowDepth;

public LastSoftdropReachableForCover(Reachable reachable, MinoRotation minoRotation, int maxY, int allowDepth) {
public LastSoftdropReachableForCover(Reachable reachable, MinoRotation minoRotation, int maxY, int allowDepth, boolean use180Rotation) {
assert 1 <= allowDepth;
this.reachable = reachable;
this.lockedReachable = new LockedReachable(new MinoFactory(), new MinoShifter(), minoRotation, maxY);
this.lockedReachable = ReachableFacade.createLocked(new MinoFactory(), new MinoShifter(), minoRotation, maxY, use180Rotation);
this.allowDepth = allowDepth;
}

Expand Down
38 changes: 38 additions & 0 deletions src/main/java/concurrent/ILockedReachableThreadLocal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package concurrent;

import core.action.reachable.ILockedReachable;
import core.action.reachable.ReachableFacade;
import core.mino.MinoFactory;
import core.mino.MinoShifter;
import core.srs.MinoRotation;

import java.util.function.Supplier;

public class ILockedReachableThreadLocal extends ThreadLocal<ILockedReachable> {
private final MinoFactory minoFactory;
private final MinoShifter minoShifter;
private final MinoRotation minoRotation;
private final int maxY;
private final boolean use180Rotation;

public ILockedReachableThreadLocal(MinoRotation minoRotation, int maxY, boolean use180Rotation) {
this(new MinoFactory(), new MinoShifter(), minoRotation, maxY, use180Rotation);
}

public ILockedReachableThreadLocal(Supplier<MinoRotation> minoRotationSupplier, int maxY, boolean use180Rotation) {
this(minoRotationSupplier.get(), maxY, use180Rotation);
}

public ILockedReachableThreadLocal(MinoFactory minoFactory, MinoShifter minoShifter, MinoRotation minoRotation, int maxY, boolean use180Rotation) {
this.minoFactory = minoFactory;
this.minoShifter = minoShifter;
this.minoRotation = minoRotation;
this.maxY = maxY;
this.use180Rotation = use180Rotation;
}

@Override
protected ILockedReachable initialValue() {
return ReachableFacade.createLocked(minoFactory, minoShifter, minoRotation, maxY, use180Rotation);
}
}
13 changes: 8 additions & 5 deletions src/main/java/concurrent/LockedCandidateThreadLocal.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package concurrent;

import core.action.candidate.LockedCandidate;
import core.action.candidate.CandidateFacade;
import core.action.candidate.ILockedCandidate;
import core.mino.MinoFactory;
import core.mino.MinoShifter;
import core.srs.MinoRotation;

import java.util.function.Supplier;

public class LockedCandidateThreadLocal extends ThreadLocal<LockedCandidate> {
public class LockedCandidateThreadLocal extends ThreadLocal<ILockedCandidate> {
private final Supplier<MinoRotation> minoRotationSupplier;
private final int maxY;
private final boolean use180Rotation;

public LockedCandidateThreadLocal(Supplier<MinoRotation> minoRotationSupplier, int maxY) {
public LockedCandidateThreadLocal(Supplier<MinoRotation> minoRotationSupplier, int maxY, boolean use180Rotation) {
this.minoRotationSupplier = minoRotationSupplier;
this.maxY = maxY;
this.use180Rotation = use180Rotation;
}

@Override
protected LockedCandidate initialValue() {
protected ILockedCandidate initialValue() {
MinoFactory minoFactory = new MinoFactory();
MinoShifter minoShifter = new MinoShifter();
MinoRotation minoRotation = minoRotationSupplier.get();
return new LockedCandidate(minoFactory, minoShifter, minoRotation, maxY);
return CandidateFacade.createLocked(minoFactory, minoShifter, minoRotation, maxY, use180Rotation);
}
}
35 changes: 0 additions & 35 deletions src/main/java/concurrent/LockedReachableThreadLocal.java

This file was deleted.

37 changes: 0 additions & 37 deletions src/main/java/concurrent/SRSAnd180CandidateThreadLocal.java

This file was deleted.

35 changes: 0 additions & 35 deletions src/main/java/concurrent/SRSAnd180ReachableThreadLocal.java

This file was deleted.

Loading

0 comments on commit 6dcf70a

Please sign in to comment.