Commit 01fb10f8 authored by hagrid67's avatar hagrid67
Browse files

mostly just adding trailing junk

parent c2b8a390
......@@ -71,11 +71,11 @@
```
%% Cell type:code id: tags:
``` python
sfEnv = "C:/Users/u224870/Projekte_Git/flatland/env-data/tests/test1.npy"
sfEnv = "../flatland/env-data/tests/test1.npy"
if True:
oEnv.rail.load_transition_map(sfEnv)
oEnv.width = oEnv.rail.width
oEnv.height = oEnv.rail.height
```
......@@ -157,11 +157,11 @@
%% Cell type:code id: tags:
``` python
wid_img.unregister_all()
oEditor = JupEditor(oEnv,wid_img)
oEditor = JupEditor(oEnv, wid_img)
wid_img.register_move(oEditor.event_handler)
wid_img.register_click(oEditor.on_click)
```
......@@ -225,10 +225,11 @@
``` python
# wid_box
wid_main = HBox([wid_img, vbox_controls])
wid_output.clear_output()
wid_main
```
%%%% Output: display_data
......@@ -280,31 +281,10 @@
``` python
if False:
oEnv.rail.save_transition_map("../flatland/env-data/tests/test-editor.npy")
```
%%%% Output: error
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-20-a40691809d2c> in <module>()
----> 1 oEnv.rail.save_transition_map("../flatland/env-data/tests/test-editor.npy")
c:\users\u224870\appdata\local\programs\python\python36\lib\site-packages\flatland_rl-0.1.1-py3.6.egg\flatland\core\transition_map.py in save_transition_map(self, filename)
259
260 """
--> 261 np.save(filename, self.grid)
262
263 def load_transition_map(self, filename, override_gridsize=True):
c:\users\u224870\appdata\local\programs\python\python36\lib\site-packages\numpy\lib\npyio.py in save(file, arr, allow_pickle, fix_imports)
490 if not file.endswith('.npy'):
491 file = file + '.npy'
--> 492 fid = open(file, "wb")
493 own_fid = True
494 elif is_pathlib_path(file):
FileNotFoundError: [Errno 2] No such file or directory: '../flatland/env-data/tests/test-editor.npy'
%% Cell type:markdown id: tags:
## Junk below here
%% Cell type:code id: tags:
......@@ -428,8 +408,212 @@
['1000', '0000', '0010', '0000']
%% Cell type:code id: tags:
``` python
oEnv.rail
```
%%%% Output: execute_result
<flatland.core.transition_map.GridTransitionMap at 0x7fc6dd6c9e48>
%% Cell type:code id: tags:
``` python
binDeadend = 0b0010000110000100
format(~binDeadend & 0xffff, "#018b")
```
%%%% Output: execute_result
'0b1101111001111011'
%% Cell type:code id: tags:
``` python
oEnv.rail.cell_neighbours_valid((2,5))
```
%%%% Output: execute_result
True
%% Cell type:code id: tags:
``` python
oEnv.rail.grid[2,6] & binDeadend
```
%%%% Output: execute_result
0
%% Cell type:code id: tags:
``` python
oTrans = oEnv.rail.grid[2,5]
oTrans
oEnv.rail.transitions.repr(oTrans, 1)
```
%%%% Output: execute_result
''
%% Cell type:code id: tags:
``` python
oEnv.rail.transitions.is_valid(oTrans)
```
%%%% Output: execute_result
True
%% Cell type:code id: tags:
``` python
oEnv.rail.transitions.gDir2dRC
```
%%%% Output: execute_result
array([[-1, 0],
[ 0, 1],
[ 1, 0],
[ 0, -1]])
%% Cell type:code id: tags:
``` python
binTrans = oEnv.rail.get_transitions((2,2))
sBinTrans = format(binTrans, "#018b")[2:]
print(sBinTrans)
lsBinTrans = [ sBinTrans[i:i+4] for i in range(0,16, 4)]
print(lsBinTrans)
```
%% Cell type:code id: tags:
``` python
lnBinTrans = array([ binTrans >> 8, binTrans & 0xff ], dtype=np.uint8)
g2binTrans = np.unpackbits(lnBinTrans).reshape(4,4)
g2binTrans
```
%%%% Output: execute_result
array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype=uint8)
%% Cell type:code id: tags:
``` python
gDirIn = g2binTrans.any(axis=1)
gDirOut = g2binTrans.any(axis=0)
print(gDirIn)
print(gDirOut)
```
%% Cell type:code id: tags:
``` python
giDirOut = np.argwhere(gDirOut)[:,0]
giDirOut
```
%%%% Output: execute_result
array([], dtype=int64)
%% Cell type:code id: tags:
``` python
any((0,0,0))
```
%%%% Output: execute_result
False
%% Cell type:code id: tags:
``` python
oEnv.rail.transitions.gDir2dRC
```
%%%% Output: execute_result
array([[-1, 0],
[ 0, 1],
[ 1, 0],
[ 0, -1]])
%% Cell type:code id: tags:
``` python
oEnv.rail.transitions.gDir2dRC[giDirOut,:]
```
%%%% Output: execute_result
array([], shape=(0, 2), dtype=int64)
%% Cell type:code id: tags:
``` python
t4TransOut = oEnv.rail.get_transitions((2,2,3))
print (t4TransOut)
for iDir in np.argwhere(t4TransOut)[:,0]:
print(iDir, oEnv.rail.transitions.gDir2dRC[iDir])
```
%% Cell type:code id: tags:
``` python
lsRepr = []
sDirs = "NESW"
lsDirs = list(sDirs)
cell_transition = oTrans
sbinTrans = format(cell_transition, "#018b")[2:]
print(sbinTrans)
for iDirIn in range(0,4):
sDirTrans = sbinTrans[iDirIn*4:iDirIn*4+4]
if sDirTrans=="0000":
continue
sDirsOut = [
lsDirs[iDirOut]
for iDirOut in range(0,4)
if sDirTrans[iDirOut]=="1"
]
lsRepr.append(lsDirs[iDirIn] + ":" + "".join(sDirsOut))
", ".join(lsRepr)
```
%%%% Output: execute_result
''
%% Cell type:code id: tags:
``` python
s="1010"
ints = int(s,2)
gs = array(ints, dtype=np.uint8)
print(gs, np.unpackbits(gs)[4:8])
```
%% Cell type:code id: tags:
``` python
oEnv.rail.transitions.repr(1025)
```
%%%% Output: execute_result
'N:0000 E:0100 S:0000 W:0001'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment