Re: Large map arrays in Python?
The results seem pretty good, near instantaneous results for nearest obstical along a given axis, even on large 1000 by 1000 by 1000 scale:
import numpy as np
#generate array
box = np.zeros((1000,1000,1000),dtype='uint8')
#player coordinates player = [500,500,500] print('seed map') #left: x,y,z box[6][500][500] = 1 box[99][500][500] = 1 #right box[678][500][500] = 1 box[690][500][500] = 1 #forward box[500][500][9] = 1 box[500][500][32] = 1 #backward box[500][500][789] = 1 box[500][500][753] = 1 #up box[500][12][500] = 1 box[500][52][500] = 1 #down box[500][876][500] = 1 box[500][976][500] = 1 print('quick find along 6 axis:') #find left print('left: '+str(np.argwhere(box[0:500,500,500]==1)[-1][0])) #find right print('right: '+str((player[0]+np.argwhere(box[500:1000,500,500]==1)[0][0]))) #forward print('forward: '+str(np.argwhere(box[player[0],player[1],0:500]==1)[-1][0])) #backward print('backward: '+str((player[2]+np.argwhere(box[500,500,500:1000]==1)[0][0]))) #up print('up: '+str(np.argwhere(box[500,0:500,500]==1)[-1][0])) #down print('down: '+str((player[1]+np.argwhere(box[500,500:1000,500]==1)[0][0])))
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector