Created
February 4, 2020 22:35
-
-
Save modernserf/ea8ee60c1f0f1565c38626466da634b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- discontiguous gender/2. | |
:- discontiguous balls/2. | |
:- discontiguous age/2. | |
:- discontiguous gender_pair/2. | |
:- discontiguous position/2. | |
% positions: [sled] -> wheel -> team -> swing -> lead | |
% TODO: what is the significance of the wind? | |
% hari | |
gender(hari, male). | |
balls(hari, neutered). | |
age(hari, adult). | |
gender_pair(hari, male). | |
% runs best in the middle of the team | |
position(hari, swing). | |
position(hari, team). | |
% zagat | |
gender(zagat, male). | |
balls(zagat, intact). | |
age(zagat, yearling). | |
gender_pair(zagat, male). | |
gender_pair(zagat, female). | |
% "excellent leader in training" -- behind lead? or along side? | |
position(zagat, swing). | |
%flame | |
gender(flame, female). | |
balls(flame, neutered). | |
age(flame, adult). | |
gender_pair(flame, male). | |
position(flame, swing). | |
position(flame, team). | |
% spike | |
gender(spike, male). | |
balls(spike, neutered). | |
age(spike, adult). | |
gender_pair(spike, male). | |
gender_pair(spike, female). | |
% "can run lead or anywhere else" | |
% might want to remove other positions if too many options | |
position(spike, lead). | |
position(spike, swing). | |
position(spike, team). | |
position(spike, wheel). | |
%TODO: how to capture "friends with colbert" | |
%dora | |
gender(dora, female). | |
balls(dora, intact). | |
age(dora, yearling). | |
gender_pair(dora, male). | |
gender_pair(dora, female). | |
% "strong"; "smart but needs to tire herself out before she can really think" -- back of the pack? | |
position(dora, team). | |
position(dora, wheel). | |
%refried | |
gender(refried, female). | |
balls(refried, neutered). | |
age(refried, adult). | |
gender_pair(refried, male). | |
position(refried, swing). | |
position(refried, team). | |
%donut | |
gender(donut, female). | |
balls(donut, neutered). | |
age(donut, adult). | |
gender_pair(donut, female). | |
gender_pair(donut, male). | |
position(donut, swing). | |
position(donut, team). | |
%colbert | |
gender(colbert, male). | |
balls(colbert, intact). | |
age(colbert, adult). | |
gender_pair(colbert, female). | |
gender_pair(colbert, male). | |
% "can run with anyone but yearling males" | |
% (redundant with `not_intact_pair` rule) | |
position(colbert, wheel). | |
%helli | |
gender(helli, female). | |
balls(helli, intact). | |
age(helli, adult). | |
gender_pair(helli, female). | |
gender_pair(helli, male). | |
% "if she has to wait too long, she'll chew her harness" -- does this suggest a position? | |
position(helli, lead). | |
position(helli, swing). | |
position(helli, team). | |
position(helli, wheel). | |
%jeff | |
gender(jeff, male). | |
balls(jeff, neutered). | |
age(jeff, adult). | |
gender_pair(jeff, female). | |
position(jeff, swing). | |
position(jeff, team). | |
% pepe | |
gender(pepe, female). | |
balls(pepe, neutered). | |
age(pepe, adult). | |
gender_pair(pepe, female). | |
gender_pair(pepe, male). | |
position(pepe, lead). | |
% jules | |
gender(jules, male). | |
balls(jules, intact). | |
age(jules, yearling). | |
gender_pair(jules, female). | |
% "should be brought to the gang-line last" -- does that imply position? | |
position(jules, lead). | |
position(jules, swing). | |
position(jules, team). | |
position(jules, wheel). | |
% boo | |
gender(boo, male). | |
balls(boo, intact). | |
age(boo, adult). | |
gender_pair(boo, female). | |
gender_pair(boo, male). | |
position(boo, lead). | |
position(boo, swing). | |
position(boo, team). | |
position(boo, wheel). | |
% jenga | |
gender(jenga, female). | |
balls(jenga, spayed). | |
age(jenga, adult). | |
gender_pair(jenga, female). | |
gender_pair(jenga, male). | |
position(jenga, lead). | |
position(jenga, swing). | |
position(jenga, team). | |
position(jenga, wheel). | |
% biggie | |
gender(biggie, male). | |
balls(biggie, intact). | |
age(biggie, yearling). | |
gender_pair(biggie, female). | |
position(biggie, lead). | |
position(biggie, swing). | |
position(biggie, team). | |
position(biggie, wheel). | |
% grinch | |
gender(grinch, male). | |
balls(grinch, neutered). | |
gender_pair(grinch, female). | |
gender_pair(grinch, male). | |
position(grinch, team). | |
position(grinch, wheel). | |
compatible_one_way(Target, Compare) :- | |
gender(Compare, CompareGender), | |
gender_pair(Target, CompareGender). | |
not_intact_pair(Left, _) :- balls(Left, neutered). | |
not_intact_pair(Left, Right) :- | |
balls(Left, intact), | |
balls(Right, neutered). | |
not_two_yearlings(Left, _) :- age(Left, adult). | |
not_two_yearlings(Left, Right) :- | |
age(Left, yearling), | |
age(Right, adult). | |
compatible(Left, Right) :- | |
not_intact_pair(Left, Right), | |
not_two_yearlings(Left, Right), | |
compatible_one_way(Left, Right), | |
compatible_one_way(Right, Left). | |
pair_for_position((Left, Right), Position) :- | |
position(Left, Position), | |
position(Right, Position), | |
compatible(Left, Right). | |
% this is the performance-sensitive part, I think? | |
% should probably not be four appends in a row | |
% but who knows? computers are fast | |
take_two(Input, (Left, Right), Output) :- | |
append(Prefix1, [Left | Rest], Input), | |
append(Prefix2, [Right | Postfix], Rest), | |
append(Prefix1, Prefix2, Prefix), | |
append(Prefix, Postfix, Output). | |
team(Input, Output, Leads, Swings, Teams, Wheels) :- | |
take_two(Input, Leads, Next1), | |
pair_for_position(Leads, lead), | |
take_two(Next1, Swings, Next2), | |
pair_for_position(Swings, swing), | |
take_two(Next2, Teams, Next3), | |
pair_for_position(Teams, team), | |
take_two(Next3, Wheels, Output), | |
pair_for_position(Wheels, wheel). | |
two_teams(AllDogs, [Leads1, Swings1, Teams1, Wheels1], [Leads2, Swings2, Teams2, Wheels2]) :- | |
team(AllDogs, RemainingDogs, Leads1, Swings1, Teams1, Wheels1), | |
team(RemainingDogs, _, Leads2, Swings2, Teams2, Wheels2). | |
run(Team1, Team2) :- | |
two_teams( | |
[hari, zagat, flame, spike, dora, refried, donut, colbert, helli, | |
jeff, pepe, jules, boo, jenga, biggie, grinch], | |
Team1, | |
Team2 | |
). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: