let With = null; With = this.addLink("with", null); With.f = SmartLink.getIsWith();
As you can see, a link is created via the puzzle method
this.addLink("link name", nounType)
You may notice that the noun type is null for the default link. This is later set to the first noun type of the puzzle when the puzzle module is validated.
// Links. let directlyRightOf = this.addLink("directly to the right of", houses); directlyRightOf.f = SmartLink.getIsMoreBy(1); let nextTo = this.addLink("next to", houses); nextTo.f = SmartLink.getIsNextTo();
Below are the links declared in the puzzle module for the logic puzzle "Air Turbulence". Note that two of the links have their function defined using a lambda expression.
// Links. let oneMoreThan = this.addLink("one more than", runways); oneMoreThan.f = (noun1, noun2) => (noun1.num === noun2.num + 1 && noun1.num !== 4) ? Is : IsNot; let higherThan = this.addLink("higher-numbered than", runways); higherThan.f = SmartLink.getIsMoreThan(); let twiceThan = this.addLink("twice higher than", runways); twiceThan.f = (noun1, noun2) => (noun1.num === 3 && noun2.num === 1) || (noun1.num === 4 && noun2.num === 2) ? Is : IsNot;
This article is part of the "Build Logic Puzzles" series. The next article in the series is "Build Facts". Thank you.