Как я могу предотвратить сортировку с направленной смещением при перемещении значений в сетке плиток?Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Как я могу предотвратить сортировку с направленной смещением при перемещении значений в сетке плиток?

Сообщение Anonymous »

Я пытаюсь сделать простую, плавную динамику в сетке плитки для игры. По сути, я хочу, чтобы значения воды ячеек в сетке проходили к одной соседней ячейке в каждой кадре в соответствии с парой правил. У меня закончились слова, пытающиеся объяснить и включить код.
context_img_bciranoutofwords < /p>
ниже - функция потока, которую я призываю на плитках. Я прошу прощения, я знаю, что это чрезмерно написать это так, и если у вас есть способ консолидироваться, я бы хотел услышать это! В основном я сделал это, чтобы убедиться, что я мог видеть каждый шаг, потому что я не могу понять, почему программа ведет себя, как она. Я старался изо всех сил в функции, чтобы принять справедливое решение между восточной и западной плитки. И если это не так, есть ли что -то еще в этой функции, что может вызвать это? "Self.Blank_Adj [0]" = объект бета -плитки. "Self.Blank_Adj [_1]" = проверка, которая верна, если смежный квадрат выглядит < /p>
def gravity_water_flow_nl_2(self):
#self._adj [0] = beta tile
#self._adj [1] = greater alt check

flow_tile = self
if self.water > FLOW:

#S exists
if self.S_adj != None:

#S not tall
if self.S_adj[1] != True:

#S not full
if self.S_adj[0].water < (100-FLOW):
flow_tile = self.S_adj[0]

#S Full
else:

#S full, W exists
if self.W_adj != None:

#W not tall
if self.W_adj[1] != True:

#W not full
if self.W_adj[0].water < (100 - FLOW):

#Check E
#E exists
if self.E_adj != None:

#E tall
if self.E_adj[1] == True:

flow_tile = self.W_adj[0]

#E not tall
else:

#E not full
if self.E_adj[0].water self.W_adj[0].water:
flow_tile = self.W_adj[0]
elif self.E_adj[0].water < self.W_adj[0].water:
flow_tile = self.E_adj[0]
else:
flow_tile = random.choice([self.E_adj[0],self.W_adj[0]])

#W equal or more than self
else:
flow_tile = self.E_adj[0]

#E equal or more than self
else:
flow_tile = self.W_adj[0]

#E doesn't exist
else:
flow_tile = self.W_adj[0]

#W full
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj

#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#W tall
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj

#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#S full, W doesn't exist
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj
#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#S tall
else:

#W exists
if self.W_adj != None:

#W not tall
if self.W_adj[1] != True:

#W not full
if self.W_adj[0].water < (100 - FLOW):

#Check E
#E exists
if self.E_adj != None:

#E tall
if self.E_adj[1] == True:

flow_tile = self.W_adj[0]

#E not tall
else:

#E not full
if self.E_adj[0].water < (100 - FLOW):

#E less water than self
if self.E_adj[0].water < self.water:

#W less water than self
if self.W_adj[0].water < self.water:

if self.E_adj[0].water > self.W_adj[0].water:
flow_tile = self.W_adj[0]
elif self.E_adj[0].water < self.W_adj[0].water:
flow_tile = self.E_adj[0]
else:
flow_tile = random.choice([self.E_adj[0],self.W_adj[0]])

#W equal or more than self
else:
flow_tile = self.E_adj[0]

#E equal or more than self
else:
flow_tile = self.W_adj[0]

#E doesn't exist
else:
flow_tile = self.W_adj[0]

#W full
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj
#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#W tall
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj
#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#W doesn't exist
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj
#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#S doesn't exist
else:

#W exists
if self.W_adj != None:

#W not tall
if self.W_adj[1] != True:

#W not full
if self.W_adj[0].water < (100 - FLOW):

#Check E
#E exists
if self.E_adj != None:

#E tall
if self.E_adj[1] == True:

flow_tile = self.W_adj[0]

#E not tall
else:

#E not full
if self.E_adj[0].water < (100 - FLOW):

#E less water than self
if self.E_adj[0].water < self.water:

#W less water than self
if self.W_adj[0].water < self.water:

if self.E_adj[0].water > self.W_adj[0].water:
flow_tile = self.W_adj[0]
elif self.E_adj[0].water < self.W_adj[0].water:
flow_tile = self.E_adj[0]
else:
flow_tile = random.choice([self.E_adj[0],self.W_adj[0]])

#W equal or more than self
else:
flow_tile = self.E_adj[0]

#E equal or more than self
else:
flow_tile = self.W_adj[0]

#E doesn't exist
else:
flow_tile = self.W_adj[0]

#W full
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj
#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#W tall
else:

#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj
#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#W doesn't exist
else:
#E exists
if self.E_adj != None:

#E not tall
if self.E_adj[1] != True:

#E not full
if self.E_adj[0].water < (100-FLOW):
flow_tile = self.E_adj
#E full
else:
#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E tall
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj

#E doesn't exist
else:

#N exists
if self.N_adj != None:

#N not tall
if self.N_adj[1] != True:

#N not full
if self.N_adj[0].water < (100 - FLOW):
flow_tile = self.N_adj


Подробнее здесь: https://stackoverflow.com/questions/797 ... id-of-tile
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»