Skip to content

Commit 0b6bc81

Browse files
committed
Adjust frequency of gates in levels.
1 parent 6244a37 commit 0b6bc81

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

src/levels.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ export const freeMode: Level = {
3636
randomQubit: () => randomQubit(),
3737
deal: () => {
3838
let buffer = [];
39-
for (let _i of range(4)) {
39+
for (let _i of range(5)) {
4040
buffer.push(QubitPair.random());
4141
}
42-
buffer.push(GatePiece.random());
42+
for (let _i of range(2)) {
43+
buffer.push(GatePiece.random());
44+
}
4345
for (let _i of range(1)) {
4446
buffer.push(MeasurementPiece.random());
4547
}
@@ -56,9 +58,11 @@ function primaryLevel(axis: Axis): Level {
5658
for (let _i of range(5)) {
5759
buffer.push(new QubitPair(random(), random()));
5860
}
59-
buffer.push(new GatePiece(axis, choice(gateRotations)));
61+
for (let _i of range(2)) {
62+
buffer.push(new GatePiece(axis, choice(gateRotations)));
63+
}
6064
buffer.push(new MeasurementPiece(random()));
61-
return buffer;
65+
return shuffle(buffer);
6266
},
6367
};
6468
}
@@ -72,7 +76,9 @@ function secondaryLevel(axis: Axis): Level {
7276
for (let _i of range(5)) {
7377
buffer.push(new QubitPair(random(), random()));
7478
}
75-
buffer.push(new GatePiece(axis, choice(gateRotations)));
79+
for (let _i of range(2)) {
80+
buffer.push(new GatePiece(axis, choice(gateRotations)));
81+
}
7682
buffer.push(new MeasurementPiece(random()));
7783
return buffer;
7884
},
@@ -92,9 +98,11 @@ export const primaryLevels: Level[] = [
9298
for (let _i of range(5)) {
9399
buffer.push(new QubitPair(random(), random()));
94100
}
95-
buffer.push(
96-
new GatePiece(choice(["X", "Y", "Z"]), choice(gateRotations))
97-
);
101+
for (let _i of range(2)) {
102+
buffer.push(
103+
new GatePiece(choice(["X", "Y", "Z"]), choice(gateRotations))
104+
);
105+
}
98106
buffer.push(new MeasurementPiece(random()));
99107
return buffer;
100108
},
@@ -114,9 +122,11 @@ export const secondaryLevels: Level[] = [
114122
for (let _i of range(5)) {
115123
buffer.push(new QubitPair(random(), random()));
116124
}
117-
buffer.push(
118-
new GatePiece(choice(["X", "Y", "Z"]), choice(gateRotations))
119-
);
125+
for (let _i of range(2)) {
126+
buffer.push(
127+
new GatePiece(choice(["X", "Y", "Z"]), choice(gateRotations))
128+
);
129+
}
120130
buffer.push(new MeasurementPiece(random()));
121131
return buffer;
122132
},

src/nodes/Player.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,15 @@ export default class Player extends GameNode {
234234
}
235235

236236
newCurrent() {
237-
this.pieceCount++;
237+
this.canSwap = true;
238+
this.board.current = this.deck.pop();
239+
this.board.setCurrentPosition(startingCell);
240+
this.board.view.addChild(this.board.current.view);
241+
242+
if (this.board.current instanceof QubitPair) {
243+
// Only increase the piece count on actual new pieces.
244+
this.pieceCount++;
245+
}
238246
// Increase level
239247
if (this.pieceCount > levelCount) {
240248
this.level++;
@@ -248,10 +256,6 @@ export default class Player extends GameNode {
248256
this.onLevelUp?.(this.levels[this.level]);
249257
}
250258
}
251-
this.canSwap = true;
252-
this.board.current = this.deck.pop();
253-
this.board.setCurrentPosition(startingCell);
254-
this.board.view.addChild(this.board.current.view);
255259
}
256260

257261
swap() {

0 commit comments

Comments
 (0)