This file contains hidden or 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
| from collections import deque | |
| import curses | |
| import time | |
| import random | |
| #random.seed(1) | |
| class Snake: | |
| def __init__(self, width, height, stdscr): | |
| self.width = width |
This file contains hidden or 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
| #!/bin/bash | |
| message () { | |
| ans=$(zenity --entry --title="It's time!" --timeout=86000 --text="$current_message"s) | |
| if [ "$ans" != "123" ] | |
| then | |
| sleep 1m | |
| message | |
| else | |
| end_time=$(date -u) | |
| touch buffer |
This file contains hidden or 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
| import os | |
| import time | |
| import signal | |
| def timestr(seconds): | |
| if seconds >= 60: | |
| return '%0.0f minutes %0.0f seconds' % (seconds//60, seconds % 60) | |
| else: | |
| return str(int(seconds)) + ' seconds' |
This file contains hidden or 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
| #ifndef ARCPLACER_H | |
| #define ARCPLACER_H | |
| #include <math.h> | |
| #define loopy(i, n) for(unsigned int i = 0; i < n; i++) | |
| static inline float posMod(float a, float n){ | |
| return a - n * floor(a/n); | |
| } |
This file contains hidden or 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
| void SensorySystem::update() { | |
| loopy(i, subSNumber){ | |
| subSystems[i]->sense(); | |
| } | |
| if(centralTileSensor.enabled) centralTileSensor.sense(body->GetPosition()); | |
| } | |
| void SensorySystem::draw ( NVGcontext* vg ) { | |
| loopy(i, subSNumber){ |
This file contains hidden or 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
| struct CanBeSensed{ | |
| uint16 senseMask; | |
| //id for unordered_map inside sensors | |
| static IdInt idCountS; | |
| CanBeSensed(uint16 _senseMask): idS (++idCountS), | |
| senseMask(_senseMask){} | |
| IdInt getIdS() const { return idS; }; |
This file contains hidden or 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
| struct Base{ | |
| virtual float getDistance() = 0; | |
| }; | |
| struct CanBeSmelled{ | |
| Smell smells[10]; | |
| Smell getSmell(); | |
| }; | |
| struct CanBeHeard{ | |
| Sound sounds[10]; | |
| Sound getSound(); |
This file contains hidden or 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
| struct Sensor{ | |
| void sense(CanBeSensed* o){ | |
| for(int i = 0; i< 1000000; i++){ | |
| for(int j = 0; j< 1000000; j++){ | |
| float value = o->getSound(); or o->getSmell(); | |
| std::cout<<value<<std::endl; | |
| } | |
| } | |
| } |
This file contains hidden or 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
| long long int getTime(timeval* tp){ | |
| gettimeofday(tp, nullptr); | |
| return tp->tv_sec * 1000 + tp->tv_usec / 1000; | |
| } | |
| int main (int argc, char *argv[]) | |
| { | |
| struct timeval tp; | |
| long int n = 1000000L; | |
| std::vector<unsigned long int> idx; |
This file contains hidden or 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
| import numpy as np | |
| def sig(z): | |
| return 1/(1 + np.exp(-z)) | |
| def sig_der(output): | |
| return output*(1 - output) | |
| and_ = 0 | |
| if and_: |
NewerOlder