Home Artists Posts Import Register

Content

For a bit of fun, here's a fragment of the harlot selection algorithm to determine which harlots are presented to the player.  I've been tweaking it this week to have some repeat visits show up a little more frequently.  Not shown is an override system to force some harlots to appear on future rounds (you'll find out why soon...).

Twine isn't particularly complex, but it allows you to use the standard for loops and arrays of any other programming language.  Because it's fairly standard stuff, I wouldn't have much trouble porting this to other languages should the interest be there to make a 'proper' game with graphics and sounds.


/* regular selection */


<<if $isTesting>>

''SELECTION ALGORITHM: REGULAR SELECTION''<br>

<br>

<</if>>


/* 1. Establish Pools */

<<set $visitedPool to []>>

<<set $factionPool to []>>

<<set $generalPool to []>>


/* 2. Establish which faction player currently has the highest affinity with. */

<<include [[Determine Player Max Faction Affinities: Algorithm]]>>


/* 3. Sort through all harlots.  Pull out any that can appear on the current round.  Then put them in 3 groups -

A. Has been visited before and not plot relevant

B. Belong to faction(s) player has affinity

C. The rest.

*/

<<for _hn to 0; _hn lt $allHarlots.length; _hn++>>

<<set _harlot to $allHarlots[_hn]>>

<<if $currentRound gte _harlot.minRound and $currentRound lte _harlot.maxRound>>

<<if _harlot.hasBeenVisited and not _harlot.hasPlotRepeatVisits eq true>>

<<if _harlot.isRepeatable>>

<<set $visitedPool.push(_harlot.number)>>

<</if>>

<<else>>

<<set _isInFaction to false>>

<<set _mfc to $player.maxFactionAffinities.length>>

<<for _fin to 0; _fin lt _mfc; _fin++>>    

<<set _mfa to $player.maxFactionAffinities[_fin]>>

<<if _harlot.faction eq _mfa>>

<<set _isInFaction to true>>

<</if>>

<</for>>

<<if _isInFaction eq true>>

<<set $factionPool.push(_harlot.number)>>

<<else>>

<<set $generalPool.push(_harlot.number)>>

<</if>>

<</if>>

<</if>>

<</for>>


<<if $isTesting eq true>>

<<include [[Test Harlot Selection: Print Faction Harlots]]>>

<<include [[Test Harlot Selection: Print General Harlots]]>>

<<include [[Test Harlot Selection: Print Visited Harlots]]>>

<br>

<</if>>


/* Need this test code in place to stop unseemly crashes of the test versions */

<<if $factionPool.length eq 0>>

<<goto [[No Girls End]]>>

<</if>>

<<if $factionPool.length + $generalPool.length lt 2>>

<<goto [[No Girls End]]>>

<</if>>


/* 4. Select 1st harlot from [Faction] */

<<if $harlotSelectionPool[0] eq -1>>

<<set _hi to $factionPool.pluck()>>

<<set $harlotSelectionPool[0] to _hi>>


<<if $isTesting eq true>>

Faction Harlot = <<print $allHarlots[_hi].name>><br>

<</if>>

<</if>>


/* 5. Select 2nd Harlot from [All but repeats] */

<<if $harlotSelectionPool[1] eq -1>>

/* Add Pool C to Pool B. */

<<for _i to 0; _i lt $generalPool.length; _i++>>

<<set $factionPool.push($generalPool[_i])>>

<</for>>


/* selection from pool */

<<set _hi to $factionPool.pluck()>>

<<set $harlotSelectionPool[1] to _hi>>


<<if $isTesting eq true>>

Regular Harlot = <<print $allHarlots[_hi].name>><br>

<</if>>

<</if>>


/* 6. Select 3rd harlot from [All] */

<<if $harlotSelectionPool[2] eq -1>>

/* Add Pool A to Pool B */

<<for _i to 0; _i lt $visitedPool.length; _i++>>

<<set $factionPool.push($visitedPool[_i])>>

<</for>>


/* selection from pool */

<<set _hi to $factionPool.pluck()>>

<<set $harlotSelectionPool[2] to _hi>>


<<if $isTesting eq true>>

Repeat Harlot = <<print $allHarlots[_hi].name>><br><br>

<</if>>

<</if>>


/* 7. Transfer to harlot choices (to randomise order) */

<<set $hci to []>>


<<for _i to 0; _i lt $hcCount; _i++>>

<<set $hci[_i] to $harlotSelectionPool.pluck()>>

<</for>>

Comments

No comments found for this post.