-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
301 additions
and
51 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,249 @@ | ||
# pycharm directory ? | ||
.idea/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
## Temp files | ||
*~ | ||
|
||
## Jupyter notebooks | ||
.ipynb_checkpoints | ||
|
||
## Core latex/pdflatex auxiliary files: | ||
*.aux | ||
*.lof | ||
*.log | ||
*.lot | ||
*.fls | ||
*.out | ||
*.toc | ||
*.fmt | ||
*.fot | ||
*.cb | ||
*.cb2 | ||
.*.lb | ||
|
||
## Intermediate documents: | ||
*.dvi | ||
*.xdv | ||
*-converted-to.* | ||
|
||
## Bibliography auxiliary files (bibtex/biblatex/biber): | ||
*.bbl | ||
*.bcf | ||
*.blg | ||
*-blx.aux | ||
*-blx.bib | ||
*.run.xml | ||
|
||
## Build tool auxiliary files: | ||
*.fdb_latexmk | ||
*.synctex | ||
*.synctex(busy) | ||
*.synctex.gz | ||
*.synctex.gz(busy) | ||
*.pdfsync | ||
|
||
## Auxiliary and intermediate files from other packages: | ||
# algorithms | ||
*.alg | ||
*.loa | ||
|
||
# achemso | ||
acs-*.bib | ||
|
||
# amsthm | ||
*.thm | ||
|
||
# beamer | ||
*.nav | ||
*.pre | ||
*.snm | ||
*.vrb | ||
|
||
# changes | ||
*.soc | ||
|
||
# cprotect | ||
*.cpt | ||
|
||
# elsarticle (documentclass of Elsevier journals) | ||
*.spl | ||
|
||
# endnotes | ||
*.ent | ||
|
||
# fixme | ||
*.lox | ||
|
||
# feynmf/feynmp | ||
*.mf | ||
*.mp | ||
*.t[1-9] | ||
*.t[1-9][0-9] | ||
*.tfm | ||
|
||
#(r)(e)ledmac/(r)(e)ledpar | ||
*.end | ||
*.?end | ||
*.[1-9] | ||
*.[1-9][0-9] | ||
*.[1-9][0-9][0-9] | ||
*.[1-9]R | ||
*.[1-9][0-9]R | ||
*.[1-9][0-9][0-9]R | ||
*.eledsec[1-9] | ||
*.eledsec[1-9]R | ||
*.eledsec[1-9][0-9] | ||
*.eledsec[1-9][0-9]R | ||
*.eledsec[1-9][0-9][0-9] | ||
*.eledsec[1-9][0-9][0-9]R | ||
|
||
# glossaries | ||
*.acn | ||
*.acr | ||
*.glg | ||
*.glo | ||
*.gls | ||
*.glsdefs | ||
|
||
# gnuplottex | ||
*-gnuplottex-* | ||
|
||
# gregoriotex | ||
*.gaux | ||
*.gtex | ||
|
||
# hyperref | ||
*.brf | ||
|
||
# knitr | ||
*-concordance.tex | ||
# TODO Comment the next line if you want to keep your tikz graphics files | ||
*.tikz | ||
*-tikzDictionary | ||
|
||
# listings | ||
*.lol | ||
|
||
# makeidx | ||
*.idx | ||
*.ilg | ||
*.ind | ||
*.ist | ||
|
||
# minitoc | ||
*.maf | ||
*.mlf | ||
*.mlt | ||
*.mtc[0-9]* | ||
*.slf[0-9]* | ||
*.slt[0-9]* | ||
*.stc[0-9]* | ||
|
||
# minted | ||
_minted* | ||
*.pyg | ||
|
||
# morewrites | ||
*.mw | ||
|
||
# nomencl | ||
*.nlo | ||
|
||
# pax | ||
*.pax | ||
|
||
# pdfpcnotes | ||
*.pdfpc | ||
|
||
# sagetex | ||
*.sagetex.sage | ||
*.sagetex.py | ||
*.sagetex.scmd | ||
|
||
# scrwfile | ||
*.wrt | ||
|
||
# sympy | ||
*.sout | ||
*.sympy | ||
sympy-plots-for-*.tex/ | ||
|
||
# pdfcomment | ||
*.upa | ||
*.upb | ||
|
||
# pythontex | ||
*.pytxcode | ||
pythontex-files-*/ | ||
|
||
# thmtools | ||
*.loe | ||
|
||
# TikZ & PGF | ||
*.dpth | ||
*.md5 | ||
*.auxlock | ||
|
||
# todonotes | ||
*.tdo | ||
|
||
# easy-todo | ||
*.lod | ||
|
||
# xindy | ||
*.xdy | ||
|
||
# xypic precompiled matrices | ||
*.xyc | ||
|
||
# endfloat | ||
*.ttt | ||
*.fff | ||
|
||
# Latexian | ||
TSWLatexianTemp* | ||
|
||
## Editors: | ||
# WinEdt | ||
*.bak | ||
*.sav | ||
|
||
# Texpad | ||
.texpadtmp | ||
|
||
# Kile | ||
*.backup | ||
|
||
# KBibTeX | ||
*~[0-9]* | ||
|
||
# auto folder when using emacs and auctex | ||
./auto/* | ||
*.el | ||
|
||
# expex forward references with \gathertags | ||
*-tags.tex | ||
|
||
# standalone packages | ||
*.sta | ||
|
||
# saved numpy arrays. | ||
*.npy | ||
|
||
# some temporary miscelaenous files. | ||
.misc | ||
|
||
# do not include torch saves. | ||
*.pth | ||
|
||
# do not include data and out directories to save space in the remote. | ||
*data/ | ||
*out/ | ||
|
||
# weights and biases directory. | ||
wandb/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import curses | ||
|
||
import numpy as np | ||
|
||
|
||
class Apple: | ||
def __init__(self): | ||
self.pos = (np.random.randint(curses.LINES), np.random.randint(curses.COLS)) | ||
|
||
def spawn(self): | ||
self.pos = (np.random.randint(curses.LINES), np.random.randint(curses.COLS)) | ||
|
||
def show(self, stdscr): | ||
stdscr.addstr(*self.pos, 'O') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import curses | ||
import time | ||
|
||
from Apple import Apple | ||
from Snake import Snake | ||
|
||
|
||
def main(stdscr): | ||
if not curses.can_change_color(): | ||
raise Warning("Cannot change terminal colors...") | ||
curses.curs_set(0) | ||
stdscr.nodelay(1) | ||
|
||
snake = Snake() | ||
apple = Apple() | ||
|
||
fps = 15 | ||
|
||
play = True | ||
while True: | ||
stdscr.erase() | ||
|
||
snake.change_direction(stdscr.getch()) | ||
if play: | ||
snake.move() | ||
if snake.update(snake.is_eating(apple)): | ||
play = False | ||
|
||
snake.show(stdscr) | ||
apple.show(stdscr) | ||
|
||
stdscr.refresh() | ||
time.sleep(1 / fps) | ||
|
||
|
||
if __name__ == "__main__": | ||
curses.wrapper(main) |