A-Lounsbury / pysimultaneous

A class for handling simultaneous games with any number of players
0 stars 0 forks source link

Write appendStrategy input validation #9

Closed A-Lounsbury closed 3 months ago

A-Lounsbury commented 3 months ago

This code:

outcome1 = ListNode(100, True)
outcome1.append(100, True)
outcome2 = ListNode(100, True)
outcome2.append(100, True)
append_2 = [
    [outcome1, outcome2]
]

outcome3 = ListNode(200, True)
outcome3.append(200, True)
outcome4 = ListNode(200, True)
outcome4.append(200, True)

append_3 = [
    [outcome1, outcome2],
    [outcome3, outcome4]
]

H = SimGame(3)
H.appendStrategy(0, append_3)
H.print()

results in this payoff matrix:

0, 0, 0   0, 0, 0 
0, 0, 0   0, 0, 0   
100, 100   100, 100 

0, 0, 0   0, 0, 0   
0, 0, 0   0, 0, 0   
200, 200   200, 200 
A-Lounsbury commented 3 months ago

Fixed when appending a strategy for players 1 and 2 for games up to 3 players.

A-Lounsbury commented 3 months ago

Need to check for the correct numbers of outcomes. The following test results in an IndexError:

o1 = ListNode()
o2 = ListNode()
o1 = o1.load([10, 10])
o2 = o2.load([20, 20])
append_2 = [
    [o1, o2, o2]
]

G = SimGame(2)
G.appendStrategy(1, append_2)
G.print()
A-Lounsbury commented 3 months ago

Fixed for players 1 and 2.

A-Lounsbury commented 3 months ago

For some reason, this test

o1 = ListNode()
o2 = ListNode()
o3 = ListNode()
o4 = ListNode()
o5 = ListNode()
o6 = ListNode()
o7 = ListNode()
o8 = ListNode()
o9 = ListNode()
o1 = o1.load([1, 1, 1])
o2 = o2.load([2, 2, 2])
o3 = o3.load([3, 3, 3])
o4 = o4.load([4, 4, 4])
o5 = o5.load([5, 5, 5])
o6 = o6.load([6, 6, 6])
o7 = o7.load([7, 7, 7])
o8 = o8.load([8, 8, 8])
o9 = o9.load([9, 9, 9])

append_3_player3 = [
    [
        [o1, o2, o3],
        [o4, o5, o6], 
        [o7, o8, o9]
    ]
]

H = SimGame(3)
H.appendStrategy(2, append_3_player3)
H.print()

results in

0, 0, 0   0, 0, 0 
0, 0, 0   0, 0, 0 

0, 0, 0   0, 0, 0 
0, 0, 0   0, 0, 0 

1, 1, 1   2, 2, 2 
4, 4, 4   5, 5, 5
A-Lounsbury commented 3 months ago

The appendStrategy function should accept lists who's submembers are either lists of floats/ints or LIstNodes (linked lists).

A-Lounsbury commented 3 months ago

The previous comment has been dealt with.

A-Lounsbury commented 3 months ago

The issue of it appending part of an array that's the wrong size has been resolved.