This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <curses.h> | |
#define H 22 | |
#define W 79 | |
#define OFF 1 | |
#define C_YOU '@' | |
#define C_WALL '#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # ### ## # # ## # # # # ### # # # ## # # | |
# # # # # ### # #### ##### # | |
#### ## # # # ## ### # ## # ## # | |
# # # # # # # # # # | |
# # # ###### # #### | |
# # #### # | |
# ## # ## # # | |
# #### | |
# ## # # | |
## # ### # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Curses;sub a{$V=$Z>100;$VV=$V;for$x(0..79){for$y(0..23){if($x==0or$y==0or$x==79or$y==23){$u[$x][$y]=0}else{$u[$x][$y]=r(2)}}}for$x(2..77){for$y(2..21){$c=$u[$x+1][$y]+$u[$x+1][$y+1]+$u[$x][$y+1]+$u[$x-1][$y]+$u[$x-1][$y-1]+$u[$x][$y-1]+$u[$x+1][$y-1]+$u[$x-1][$y+1];if($c>=5){$u[$x][$y]=1}elsif($c<=3){$u[$x][$y]=0}if($x==0or$y==0or$x==79or$y==23){$u[$x][$y]=0}}}$X=r(80);$Y=r(24);while(!$u[$X][$Y]){$X=r(80);$Y=r(24)}i($X,$Y);my$g;for my$x(0..79){for my$y(0..23){if($u[$x][$y]==3){$u[$x][$y]= $V?1:r(20)?1:5;$g++}else{$u[$x][$y]=0}}}a()if($g>3000 or$g<500);$B=r(80);$N=r(24);while(!$u[$B][$N]){$B=r(80);$N=r(24)}by_init :D}sub r{int rand shift}sub z{($x,$y)=(shift,shift);$u[$x][$y]<2and($u[$x][$y]>0or$u[$x][$y]==-1)}sub n{($x,$y)=(shift,shift);h($x,$y)<3}sub h{($x,$y)=(shift,shift);(($x-$X)**2+($y-$Y)**2)}sub i{my$x=shift;my$y=shift;return if$u[$x][$y]^1;$u[$x][$y]=3;i($x+1,$y);i($x-1,$y);i($x,$y+1);i($x,$y-1)}$U=100;$Z=0;initscr;noecho;&a;while($U>0){if($VV){$u[$B][$N]=5;$VV=0};clear;for my$x(0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5293121 function calls (5220589 primitive calls) in 70.422 CPU seconds | |
Ordered by: cumulative time | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.005 0.005 70.422 70.422 {execfile} | |
1 0.001 0.001 70.416 70.416 main.py:20(<module>) | |
1 1.012 1.012 58.785 58.785 Game.py:111(mainLoop) | |
267 0.022 0.000 51.445 0.193 Game.py:1291(playerTurn) | |
301 0.002 0.000 50.176 0.167 Unicurses.py:2312(getch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FOV >> calcFov | |
FOV Total: 132.086039 ms on 23 calls. | |
FOV L: 5.503178 ms CALL calcFov(<Game.Game instance at 0x80ab70c>) | |
FOV A: 5.742871 ms | |
FOV H: 6.980896 ms CALL calcFov(<Game.Game instance at 0x80ab70c>) | |
FOV Trace starts at ./main.py:35 (<module>) | |
FOV play.mainLoop() ./main.py:35 (<module>) | |
FOV self.calcFov() /home/init/CutlassRLgit/CutlassRL/src/Game.py:430 (mainLoop) | |
FOV HIST(bins: 10 step: 0.147772 ms) | |
FOV 5.50318 ms 2|########## | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getLine(self, x1, y1, x2, y2): | |
"""Bresenham's line algorithm""" | |
points = [] | |
issteep = abs(y2 - y1) > abs(x2 - x1) | |
if issteep: | |
x1, y1 = y1, x1 | |
x2, y2 = y2, x2 | |
rev = False | |
if x1 > x2: | |
x1, x2 = x2, x1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inLos(self, x1, y1, px, py): | |
"""Checks if point is in LOS""" | |
x2 = px | |
y2 = py | |
if FAST_LOS: | |
self.gamemap[x1][y1].changed = True | |
issteep = abs(y2 - y1) > abs(x2 - x1) | |
if issteep: | |
x1, y1 = y1, x1 | |
x2, y2 = y2, x2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function floodFillScanline(x, y, width, height, diagonal, test, paint) { | |
// xMin, xMax, y, down[true] / up[false], extendLeft, extendRight | |
var ranges = [[x, x, y, null, true, true]]; | |
paint(x, y); | |
while(ranges.length) { | |
var r = ranges.pop(); | |
var down = r[3] === true; | |
var up = r[3] === false; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flood(self, x, y, old, new): | |
seed_pos = (x, y) | |
if old == new: | |
return | |
stack = [] | |
w, h = MAP_W, MAP_H | |
max_x = max_y = 0 | |
min_x = w | |
min_y = h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "/usr/lib/python2.7/site.py", line 554, in <module> | |
main() | |
File "/usr/lib/python2.7/site.py", line 536, in main | |
known_paths = addusersitepackages(known_paths) | |
File "/usr/lib/python2.7/site.py", line 264, in addusersitepackages | |
user_site = getusersitepackages() | |
File "/usr/lib/python2.7/site.py", line 239, in getusersitepackages | |
user_base = getuserbase() # this will also set USER_BASE | |
File "/usr/lib/python2.7/site.py", line 229, in getuserbase |