#Nathan Fox #Homework 6 #I give permission for this file to be posted online ##Read old files read(`C6.txt`): read(`C2.txt`): #Help procedure Help:=proc() : print(` ConWay1(L,R,i) , ConWay(L,R) , Sig(L,R) , AveSig(n,k,K) `): end: ##Problem 1 #ConWay1(L,R,i): inputs two acyclic directed graphs on #{1, ...n} (where n=nops(L)=nops(R)) representing a partizan #game, where their union is also acyclic , and an integer i #between 1 and n, representing a game-position (alias "game" #in Conway's sense) and outputs it in Conway's format, as a #pair of sets of simpler "games" where the very bottoms are #empty sets. ConWay1:=proc(L,R,i) local LN, RN, j: option remember: LN:={}: RN:={}: for j in L[i] do LN:=LN union {ConWay1(L,R,j)}: od: for j in R[i] do RN:=RN union {ConWay1(L,R,j)}: od: [LN,RN]: end: ##Problem 2 #ConWay(L,R): inputs two directed graphs in the above format #and outputs the list of length n:=nops(L) (=nops(R)) whose #i-th entry is ConWay1(L,R,i) ConWay:=proc(L,R) local i: [seq(ConWay1(L,R,i),i=1..nops(L))]: end: ##Problem 3 #Sig(L,R): inputs a pair of directed graphs with the #same number of vertices and output its signature. #Define the signature of a partizan game given as a pair #of directed graphs (L,R) the expression #a*"Zero"+b*"Positive"+c*"Negative"+ d*"Fuzzy" #where a+b+c+d=n, and there are a "Zero" positions, #b "Positive" positions etc. Sig:=proc(L,R) local i: add(WhatKind(ConWay1(L,R,i)),i=1..nops(L)): end: ##Problem 4 #AveSig(n,k,K): picks K random games and outputs their #average signature. AveSig:=proc(n,k,K) local i: add(Sig(RandGame(n,k),RandGame(n,k)),i=1..K)/convert(K,float): end: #My first run of AveSig(10,3,100) outputted #4.960000000 "Fuzzy" + 1.680000000 "Zero" + #1.880000000 "Positive" + 1.480000000 "Negative" #This was quite consistent in later runs