Skip to content

Commit 333bae4

Browse files
committed
alter graph generation to have 1206x4 dimensions from lab
1 parent 6a09bcf commit 333bae4

13 files changed

+174
-151
lines changed

lib/JumperGraphSolver/jumper-graph-generator/generateJumperX4Grid.ts

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export const generateJumperX4Grid = ({
4444

4545
const {
4646
padWidth,
47-
padHeight,
47+
outerPadHeight,
48+
innerPadHeight,
4849
leftPadCenterX,
4950
rightPadCenterX,
5051
row1CenterY,
@@ -54,15 +55,17 @@ export const generateJumperX4Grid = ({
5455
} = dims1206x4
5556

5657
const padHalfWidth = padWidth / 2
57-
const padHalfHeight = padHeight / 2
58+
const outerPadHalfHeight = outerPadHeight / 2
59+
const innerPadHalfHeight = innerPadHeight / 2
5860

5961
// Calculate center-to-center distances for the grid
6062
// Horizontal spacing: from one cell center to next cell center
6163
const cellWidth = rightPadCenterX - leftPadCenterX + padWidth // total width of pads region
6264
const horizontalSpacing = cellWidth + marginX
6365

6466
// Vertical spacing: from one cell center to next cell center
65-
const cellHeight = row1CenterY - row4CenterY + padHeight // total height of pads region
67+
// row4 is at top (Y=1.2), row1 is at bottom (Y=-1.2)
68+
const cellHeight = row4CenterY - row1CenterY + outerPadHeight // total height of pads region
6669
const verticalSpacing = cellHeight + marginY
6770

6871
// Calculate outer padding from bounds if specified
@@ -278,28 +281,33 @@ export const generateJumperX4Grid = ({
278281
const p8CenterY = centerY + row1CenterY
279282

280283
// Helper to create bounds for a pad at given center
281-
const createPadBounds = (padCenterX: number, padCenterY: number) => ({
284+
const createPadBounds = (
285+
padCenterX: number,
286+
padCenterY: number,
287+
halfHeight: number,
288+
) => ({
282289
minX: padCenterX - padHalfWidth,
283290
maxX: padCenterX + padHalfWidth,
284-
minY: padCenterY - padHalfHeight,
285-
maxY: padCenterY + padHalfHeight,
291+
minY: padCenterY - halfHeight,
292+
maxY: padCenterY + halfHeight,
286293
})
287294

288-
const pad1Bounds = createPadBounds(p1CenterX, p1CenterY)
289-
const pad2Bounds = createPadBounds(p2CenterX, p2CenterY)
290-
const pad3Bounds = createPadBounds(p3CenterX, p3CenterY)
291-
const pad4Bounds = createPadBounds(p4CenterX, p4CenterY)
292-
const pad5Bounds = createPadBounds(p5CenterX, p5CenterY)
293-
const pad6Bounds = createPadBounds(p6CenterX, p6CenterY)
294-
const pad7Bounds = createPadBounds(p7CenterX, p7CenterY)
295-
const pad8Bounds = createPadBounds(p8CenterX, p8CenterY)
295+
// Outer rows (1, 4) use outerPadHalfHeight, inner rows (2, 3) use innerPadHalfHeight
296+
const pad1Bounds = createPadBounds(p1CenterX, p1CenterY, outerPadHalfHeight)
297+
const pad2Bounds = createPadBounds(p2CenterX, p2CenterY, innerPadHalfHeight)
298+
const pad3Bounds = createPadBounds(p3CenterX, p3CenterY, innerPadHalfHeight)
299+
const pad4Bounds = createPadBounds(p4CenterX, p4CenterY, outerPadHalfHeight)
300+
const pad5Bounds = createPadBounds(p5CenterX, p5CenterY, outerPadHalfHeight)
301+
const pad6Bounds = createPadBounds(p6CenterX, p6CenterY, innerPadHalfHeight)
302+
const pad7Bounds = createPadBounds(p7CenterX, p7CenterY, innerPadHalfHeight)
303+
const pad8Bounds = createPadBounds(p8CenterX, p8CenterY, outerPadHalfHeight)
296304

297305
// Underjumper region - single vertical region in the center between left and right pads
298306
const underjumperBounds = {
299307
minX: pad1Bounds.maxX,
300308
maxX: pad8Bounds.minX,
301-
minY: pad4Bounds.minY,
302-
maxY: pad1Bounds.maxY,
309+
minY: pad1Bounds.minY, // row 1 is now at bottom (Y=-1.2)
310+
maxY: pad4Bounds.maxY, // row 4 is now at top (Y=1.2)
303311
}
304312

305313
// Throughjumper regions (conductive body of each resistor)
@@ -332,8 +340,8 @@ export const generateJumperX4Grid = ({
332340
// The full extent of main regions for this cell
333341
const mainMinX = pad1Bounds.minX
334342
const mainMaxX = pad8Bounds.maxX
335-
const mainMinY = pad4Bounds.minY
336-
const mainMaxY = pad1Bounds.maxY
343+
const mainMinY = pad1Bounds.minY // row 1 is now at bottom (Y=-1.2)
344+
const mainMaxY = pad4Bounds.maxY // row 4 is now at top (Y=1.2)
337345

338346
// Create main regions
339347
const pad1 = createRegion(`${idPrefix}:pad1`, pad1Bounds, true)
@@ -412,13 +420,14 @@ export const generateJumperX4Grid = ({
412420

413421
if (regionsBetweenPads) {
414422
// Left side between-pad regions
423+
// With new Y ordering: pad1 at bottom (Y=-1.2), pad4 at top (Y=1.2)
415424
leftBP12 = createRegion(
416425
`${idPrefix}:L-BP12`,
417426
{
418427
minX: pad1Bounds.minX,
419428
maxX: pad1Bounds.maxX,
420-
minY: pad2Bounds.maxY,
421-
maxY: pad1Bounds.minY,
429+
minY: pad1Bounds.maxY, // top of pad1
430+
maxY: pad2Bounds.minY, // bottom of pad2
422431
},
423432
false,
424433
)
@@ -427,8 +436,8 @@ export const generateJumperX4Grid = ({
427436
{
428437
minX: pad2Bounds.minX,
429438
maxX: pad2Bounds.maxX,
430-
minY: pad3Bounds.maxY,
431-
maxY: pad2Bounds.minY,
439+
minY: pad2Bounds.maxY, // top of pad2
440+
maxY: pad3Bounds.minY, // bottom of pad3
432441
},
433442
false,
434443
)
@@ -437,20 +446,21 @@ export const generateJumperX4Grid = ({
437446
{
438447
minX: pad3Bounds.minX,
439448
maxX: pad3Bounds.maxX,
440-
minY: pad4Bounds.maxY,
441-
maxY: pad3Bounds.minY,
449+
minY: pad3Bounds.maxY, // top of pad3
450+
maxY: pad4Bounds.minY, // bottom of pad4
442451
},
443452
false,
444453
)
445454

446455
// Right side between-pad regions
456+
// With new Y ordering: pad8 at bottom (Y=-1.2), pad5 at top (Y=1.2)
447457
rightBP87 = createRegion(
448458
`${idPrefix}:R-BP87`,
449459
{
450460
minX: pad8Bounds.minX,
451461
maxX: pad8Bounds.maxX,
452-
minY: pad7Bounds.maxY,
453-
maxY: pad8Bounds.minY,
462+
minY: pad8Bounds.maxY, // top of pad8
463+
maxY: pad7Bounds.minY, // bottom of pad7
454464
},
455465
false,
456466
)
@@ -459,8 +469,8 @@ export const generateJumperX4Grid = ({
459469
{
460470
minX: pad7Bounds.minX,
461471
maxX: pad7Bounds.maxX,
462-
minY: pad6Bounds.maxY,
463-
maxY: pad7Bounds.minY,
472+
minY: pad7Bounds.maxY, // top of pad7
473+
maxY: pad6Bounds.minY, // bottom of pad6
464474
},
465475
false,
466476
)
@@ -469,8 +479,8 @@ export const generateJumperX4Grid = ({
469479
{
470480
minX: pad6Bounds.minX,
471481
maxX: pad6Bounds.maxX,
472-
minY: pad5Bounds.maxY,
473-
maxY: pad6Bounds.minY,
482+
minY: pad6Bounds.maxY, // top of pad6
483+
maxY: pad5Bounds.minY, // bottom of pad5
474484
},
475485
false,
476486
)
@@ -612,9 +622,9 @@ export const generateJumperX4Grid = ({
612622
: innerColChannelPointCount,
613623
),
614624
)
615-
// Top connects to pad1, pad8, and underjumper
616-
ports.push(createPort(`${idPrefix}:T-P1`, top, pad1))
617-
ports.push(createPort(`${idPrefix}:T-P8`, top, pad8))
625+
// Top connects to pad4, pad5, and underjumper (pad4/pad5 are at top with new Y ordering)
626+
ports.push(createPort(`${idPrefix}:T-P4`, top, pad4))
627+
ports.push(createPort(`${idPrefix}:T-P5`, top, pad5))
618628

619629
// Underjumper connections to top - multiple ports when regionsBetweenPads
620630
if (regionsBetweenPads) {
@@ -661,9 +671,9 @@ export const generateJumperX4Grid = ({
661671
: innerColChannelPointCount,
662672
),
663673
)
664-
// Bottom connects to pad4, pad5, and underjumper
665-
ports.push(createPort(`${idPrefix}:B-P4`, bottom, pad4))
666-
ports.push(createPort(`${idPrefix}:B-P5`, bottom, pad5))
674+
// Bottom connects to pad1, pad8, and underjumper (pad1/pad8 are at bottom with new Y ordering)
675+
ports.push(createPort(`${idPrefix}:B-P1`, bottom, pad1))
676+
ports.push(createPort(`${idPrefix}:B-P8`, bottom, pad8))
667677

668678
// Underjumper connections to bottom - multiple ports when regionsBetweenPads
669679
if (regionsBetweenPads) {
@@ -890,10 +900,11 @@ export const generateJumperX4Grid = ({
890900
}
891901

892902
// Vertical connections from cell above (A on top, current B on bottom)
893-
// Note: A.bottom only touches B's top row (pad1, pad8) and underjumper, not all pads
903+
// Note: A.bottom only touches B's top row (pad4, pad5) and underjumper, not all pads
904+
// (with new Y ordering, pad4/pad5 are at the top of each cell)
894905
if (row > 0) {
895906
const aboveCell = cells[row - 1][col]
896-
// A.bottom connects to B.left, B.pad1, B.underjumper, B.pad8, B.right
907+
// A.bottom connects to B.left, B.pad4, B.underjumper, B.pad5, B.right
897908
if (left) {
898909
ports.push(
899910
...createMultiplePorts(
@@ -906,9 +917,9 @@ export const generateJumperX4Grid = ({
906917
}
907918
ports.push(
908919
createPort(
909-
`cell_${row - 1}_${col}->cell_${row}_${col}:B-P1`,
920+
`cell_${row - 1}_${col}->cell_${row}_${col}:B-P4`,
910921
aboveCell.bottom!,
911-
pad1,
922+
pad4,
912923
),
913924
)
914925
// Underjumper connections from above cell's bottom - multiple ports when regionsBetweenPads
@@ -940,9 +951,9 @@ export const generateJumperX4Grid = ({
940951
}
941952
ports.push(
942953
createPort(
943-
`cell_${row - 1}_${col}->cell_${row}_${col}:B-P8`,
954+
`cell_${row - 1}_${col}->cell_${row}_${col}:B-P5`,
944955
aboveCell.bottom!,
945-
pad8,
956+
pad5,
946957
),
947958
)
948959
ports.push(

0 commit comments

Comments
 (0)