예제 #1
0
def main():
    # states
    L = ["start", "bad", "good", "lose", "win"]
    # initial state
    L0 = "start"
    # action alphabet
    Sigma = (("grab", "lift", "switch"), ("grab", "lift", "switch"))
    # action labeled transitions
    Delta = [("start", ("grab", "grab"), "bad"),
             ("start", ("grab", "grab"), "good"),
             ("bad", ("switch", "switch"), "good"),
             ("good", ("switch", "switch"), "good"),
             ("bad", ("lift", "lift"), "lose"),
             ("bad", ("lift", "switch"), "lose"),
             ("bad", ("switch", "lift"), "lose"),
             ("bad", ("switch", "lift"), "lose"),
             ("good", ("lift", "switch"), "lose"),
             ("good", ("lift", "lift"), "win")]
    # observation partitioning
    Obs = [[["start"], ["bad"], ["good"], ["lose"], ["win"]],
           [["start"], ["bad", "good"], ["lose"], ["win"]]]

    # G is a MultiplayerGame-object, and so are GK and GK0
    G = MultiplayerGame.create(L, L0, Sigma, Delta, Obs)
    GK = G.KBSC()
    G2K = GK.KBSC()

    G0 = G.project(0)  # (G|0)
    G1 = G.project(1)  # (G|1)

    GK0 = G0.KBSC()  # (G|0)^K
    GK1 = G1.KBSC()  # (G|1)^K

    GK0_ = GK.project(0)  # G^K|0
    GK1_ = GK.project(1)  # G^K|1

    #This would be used for G3K's agents. Something is wonky with the MKBSC
    G2K0_ = G2K.project(0)
    G2K1_ = G2K.project(1)

    G2K0 = GK0_.KBSC()  # (G^K|0)^K
    G2K1 = GK1_.KBSC()  # (G^K|1)^K

    # export the GK game to ./pictures/GK.png
    #export(G, "G")
    #export(GK, "GK")
    #export(G2K, "G2K")

    #export(GK0_, "GK0_")
    #export(GK1_, "GK1_")

    #export(GK0, "GK0")
    #export(GK1, "GK1")

    export(G2K0, "G2K0")
    export(G2K1, "G2K1")
예제 #2
0
파일: 2memory.py 프로젝트: olandr/mkbsc
    ("11", ("at", "b0"), "00"),
    ("11", ("at", "bt"), "00"),
    ("11", ("b0", "-1"), "10"),
    ("11", ("b0", "a0"), "00"),
    ("11", ("b0", "at"), "00"),
    ("11", ("b0", "b0"), "10"),
    ("11", ("b0", "bt"), "10"),
    ("11", ("bt", "-1"), "10"),
    ("11", ("bt", "a0"), "00"),
    ("11", ("bt", "at"), "00"),
    ("11", ("bt", "b0"), "10"),
    ("11", ("bt", "bt"), "10"),
]
#observation partitioning
Obs = [[["start"], ["00", "01", "10", "11"], ["win"], ["lose"]],
       [["start"], ["00", "01", "10", "11"], ["win"], ["lose"]]]

#G is a MultiplayerGame-object, and so are GK and GK0
G = MultiplayerGame.create(L, L0, Sigma, Delta, Obs)
export(G, "2_memory_G")

GK = G.KBSC()
export(GK, "2_memory_GK")

(log2, GK2, iso_type2) = iterate_until_isomorphic(G,
                                                  limit=3,
                                                  print_size=False,
                                                  verbose=True)
export(GK2, "2_memory_GK2")
print(log2, GK2, iso_type2)
예제 #3
0
파일: main.py 프로젝트: olandr/mkbsc
    ("*", ("w", "r"), "*"),
    ("*", ("w", "w"), "*"),


]
#observation partitioning
Obs = [
    [["0", "*", "1"], ["win"], ["lose"]],
    [["0", "1", "*"], ["win"], ["lose"]]
]

#G is a MultiplayerGame-object, and so are GK and GK0
G = MultiplayerGame.create(L, L0, Sigma, Delta, Obs)
#G = from_file("stuff")
GK = G.KBSC()
export(GK, "GK")



(log2, GK2, iso_type2) = iterate_until_isomorphic(G, limit=2, print_size=False, verbose=True)
export(GK2, "GK2")
print(log2, GK2, iso_type2)
'''
(log3, GK3, iso_type3) = iterate_until_isomorphic(G, limit=3, print_size=False, verbose=True)
export(GK3, "GK3")
print(log3, GK3, iso_type3)

(logi, GKi, iso_typei) = iterate_until_isomorphic(G, limit=-1, print_size=False, verbose=True)
export(GKi, "GKi")
print(logi, GKi, iso_typei)
'''
예제 #4
0
파일: main.py 프로젝트: gpihl/mkbsc
#action alphabet
Sigma = (("G", "P", "D"), ("G", "P", "D"))

#action labeled transitions
Delta = [
    ("start", ("G", "G"), "hole"),
    ("start", ("G", "G"), "no hole"),
    ("hole", ("D", "D"), "hole"),
    ("hole", ("P", "P"), "win"),
    ("hole", ("P", "D"), "lose"),
    ("hole", ("D", "P"), "lose"),
    ("no hole", ("D", "D"), "hole"),
    ("no hole", ("D", "P"), "lose"),
    ("no hole", ("P", "D"), "lose"),
    ("hole", ("P", "P"), "lose"),
]
#observation partitioning
Obs = [[["start"], ["hole", "no hole"], ["win"], ["lose"]],
       [["start"], ["hole"], ["no hole"], ["win"], ["lose"]]]

#G is a Multiplayer Game-object, and so are GK and GK0
G = MultiplayerGame.create(L, L0, Sigma, Delta, Obs)
GK = G.KBSC()
G2K = GK.KBSC()

# We set epistemic to e-tree to generate e-trees as a representation of the knowledge in the game graph
export(G2K, "G2K", epistemic="e-tree", file="eps")

#print(test)
#to_file(GK, "GK")
예제 #5
0
if len(sys.argv) > 1:
    games = Games[int(sys.argv[1])]
else:
    games = Games

    for game in games:
        print(game.name + ":")

        G = MultiplayerGame.create(game.L, game.L0, game.Sigma, game.Delta, game.Obs)
        GK = G.KBSC()

        GKA = []

        for n in range(game.noa):
            Gtemp = G.project(n)
            GKA.append(Gtemp.KBSC())

        directory = 'pictures/' + game.name
        if not os.path.exists(directory):
            os.makedirs(directory)

        export(G, "G", view=False, folder = directory)
        export(GK, "GK", view=False, folder = directory)

        for idg, gka in enumerate(GKA): export(gka, "GK"+str(idg), view=False, folder = directory)
        print("Expansion done, translating to .ispl")
        makeISPL(game.name)
        print("Translation done\n")

예제 #6
0
    (0, ("0", "t"), 1),
    (0, ("t", "-1"), 1),
    (0, ("t", "0"), 1),
    (0, ("t", "t"), 1),
    (1, ("-1", "-1"), "win"),
    (1, ("-1", "0"), 0),
    (1, ("-1", "t"), 0),
    (1, ("0", "-1"), 0),
    (1, ("0", "0"), 0),
    (1, ("0", "t"), 0),
    (1, ("t", "-1"), 0),
    (1, ("t", "0"), 0),
    (1, ("t", "t"), 0),
]
#observation partitioning
Obs = [[["start"], [0, 1], ["win"], ["lose"]],
       [["start"], [0, 1], ["win"], ["lose"]]]

#G is a MultiplayerGame-object, and so are GK and GK0
G = MultiplayerGame.create(L, L0, Sigma, Delta, Obs)

GK = G.KBSC()
export(GK, "memory_GK")

(log2, GK2, iso_type2) = iterate_until_isomorphic(G,
                                                  limit=-1,
                                                  print_size=False,
                                                  verbose=True)
export(GK2, "memory_GK2")
print(log2, GK2, iso_type2)
예제 #7
0
#!/usr/bin/env python3

from mkbsc import MultiplayerGame, iterate_until_isomorphic, \
                  export, to_string, from_string, to_file, from_file

#states
L = [0, 1, 2]
#initial state
L0 = 0
#action alphabet
Sigma = (("w", "p"), ("w", "p"))
#action labeled transitions
Delta = [(0, ("p", "p"), 0), (0, ("w", "w"), 0), (0, ("w", "p"), 1),
         (0, ("p", "w"), 2), (1, ("p", "p"), 1), (1, ("w", "w"), 1),
         (1, ("w", "p"), 2), (1, ("p", "w"), 0), (2, ("p", "p"), 2),
         (2, ("w", "w"), 2), (2, ("w", "p"), 0), (2, ("p", "w"), 1)]
#observation partitioning
Obs = [[[0, 1], [2]], [[0, 2], [1]]]

#G is a MultiplayerGame-object, and so are GK and GK0
G = MultiplayerGame.create(L, L0, Sigma, Delta, Obs)
GK = G.KBSC()
GK0 = GK.project(0)

#export the GK game to ./pictures/GK.png
export(GK, "GK")