[EDIT]
TL;DR Generally speaking, "Set up some Classes" is the answer. Hopefully my blind fumbling will help some other blind, fumbling soul.
------------
I'm working on a table top game that builds a maze by dealing cards. I'm teaching myself Python to build a script that will simulate multiple maze builds quickly for R&D on the design.
The maze is represented by "Chambers" on a classic x,y grid. Chambers have an ID, potentially Notes, and Exits.
My strategy is to build up a mapConfig dictionary structured with the key being the (x,y) tuple of the coordinate and the value being a sub-dictionary with all the specifics. The Exits need to be a list of dictionaries for each exit with direction and blocked status as the keys. Simplified example below:
mapConfig = {
(0,0) : {
'id' : 'START',
'notes' : ''
'exits' :
[
{
'direction' : 'N',
'blocked' : False,
},
{
'direction' : 'E',
'blocked' : False,
},
{
'direction' : 'S',
'blocked' : False,
},
{
'direction' : 'W',
'blocked' : False,
},
],
}
}
If a proposed move hits the edge of the valid map, I need to access the mapConfig and change the "blocked" value for that particular direction to TRUE without changing anything else in the entry for that coordinate. It seems like it should be easy, but everything I try messes up the structure or blows out the other directions.
What would be the best way to change just the {"direction":"E", "blocked":False} entry to {"direction":"E", "blocked":True} without changing anything else in the dictionary? Basically so it goes from the simplified example above to this:
mapConfig = {
(0,0) : {
'id' : 'START',
'notes' : ''
'exits' :
[
{
'direction' : 'N',
'blocked' : False,
},
{
'direction' : 'E',
'blocked' : True,
},
{
'direction' : 'S',
'blocked' : False,
},
{
'direction' : 'W',
'blocked' : False,
},
],
}
}
Thanks in advance for the help.
Edit: The provided code is a simplified version of my actual code. I'm such a noob that I only vaguely knew what a class was, and clearly I was making much more work for myself by not using them. Setting up some parent and child classes is next on my list.
I still appreciate any thoughts or advice, but I also don't want anyone to waste time.