'function for a playboard
I wanna form a function that forms a playboard with arguments (playboard) and return the representation of the playboard and goblets
Example:
def form_a_playboard(playboard):
...
>>> print(formater_plateau([[[], [], [], []], [[], [], [], []], [[], [], [], []], [[1, 3], [], [], []]]))
3 | | |
───┼───┼───┼───
2 | | |
───┼───┼───┼───
1 | | |
───┼───┼───┼───
0 □ | | |
0 1 2 3
this is what I did:
def formater_plateau(plateau):
fonct = formater_un_gobblet([])
sep1 = "3" + fonct + "|" + fonct + "|" + fonct + "|"
sep2 = " ───┼───┼───┼───"
sep3 = "2" + fonct + "|" + fonct + "|" + fonct + "|"
sep4 = "1" + fonct + "|" + fonct + "|" + fonct + "|"
sep5 = "0" + fonct + "|" + fonct + "|" + fonct + "|"
return ((sep1) + '\n' + (sep2) + '\n' + (sep3) + '\n' + (sep2) + '\n' + (sep4) + '\n' + (sep2) + '\n' + (sep5) + '\n')
it return the playboard but I don't know how yo integrate the list mecanique to put my pawns in it I already have the function for my pawns but I don't know how to integrate it in my playboard
def formater_un_gobblet(gobblet):
GOBBLET_REPRÉSENTATION = {
1: ["▫", "◇", "◯", "□"],
2: ["▪", "◆", "●", "■"],
}
if gobblet == []:
return " "
else:
return GOBBLET_REPRÉSENTATION[gobblet[0]][gobblet[1]-1]
print(formater_un_gobblet([1, 3]))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
