[QUOTE=Ott;48969665]I wish Lua got more love.[/QUOTE]
Using Lua for shell scripts feels like using C when you have better alternatives.
In the mean time when I'm writing up some Perl script I end up doing code golf.
[QUOTE=Ott;48969665]I wish Lua got more [B]love[/B].[/QUOTE]
I really hope that was intentional.
[url]https://streamable.com/8lsc[/url]
(Red is AI controlled)
Finally got crouch turns working well. It used to fall on its back if it did it too sharply.
I entered it in a league for new players, so that should be interesting.
[QUOTE=Rocket;48970029]You don't automatically know how to program in Python just by knowing how to program.[/QUOTE]
Well i know getting stoned makes you automatically know LOGO, i have to try it with python some time. :v:
[editline]24th October 2015[/editline]
Cannabis pythonica.
I'm working on [url=https://facepunch.com/showthread.php?t=1000894&p=25564833&viewfull=1#post25564833]sane[/url] things.
So since my eventual goal is communication over serial with external programs anyways, I've been taking a really basic pass at optimizing someones github code from like 3 months ago. So far I've just been moving static and const items into the flash memory instead of storing them in the tremendously limited RAM. This program actually can't run on most of the smaller Arduino's, and I think that may have been what caused the problems for the guy who made this- (snip this was wrong, it just fails to compile for most small dev boards). I still don't know if I can get it under 2kbytes, but I did cut 230 bytes of RAM usage and that's not too shabby for the basics.
In terms of optimization on this scale, anyone got any tips or locations for reading? I already see a bunch of variables being made floats when they don't need to be, or usage of the double type which isn't even different from float on arduino. The guy who wrote this seems to know what he's doing in general, but did admit that he's never written for arduino before. Apparently there's a 2-4s delay between information being dumped into the serial buffer on the arduino and it propagating to the OLED screens he's using. Here's the [URL="https://github.com/Geneticus/SE-ArduinoTest-App"]github repo[/URL] and my version of the code is here:
[CODE]/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//#include <avr/dtostrf.h> Uncomment for Arduino Due
#include "SELogo.h"
#include "Oxygen.h"
#include "Suit_Energy.h"
/*-----( Declare Constants and Pin Numbers )-----*/
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
//int led13 = 13;
//int led12 = 12;
/*-----( Declare objects )-----*/
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
/*-----( Declare Variables )-----*/
const byte numChars = 128;
char receivedChars[numChars];
boolean message = false;
char startMarkerUsed = '.';
void setup()
{
//pinMode(led13, OUTPUT); // sets the digital pin as output
//pinMode(led12, OUTPUT); // sets the digital pin as output
Serial.begin(115200); //set serial to 115200 baud rate
display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay();
display.drawBitmap(0, 0, Logo, 128, 64, 1);
display.display();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay();
display.drawBitmap(0, 0, Logo, 128, 64, 1);
display.display();
delay(3000);
Serial.println();
Serial.println(F("setup complete"));
Serial.print(F("Free RAM at setup: "));
Serial.println(freeRam());
}
//~4, Here is a first string to parse^<234, 467, 4587, 125><1234, 9467, 4587, 6125>~3, Here is a second string to parse!^~4, Here is a third string to parse^<945, 7, 28, 1159>~3, Here is a fourth string to parse!^
// <1,3,0021,100>
void loop()
{
//Serial Double Format (StartBit)(DataType,Item,CurrentValue,MaxValue)(StopBit)
//StartBit = "\x02"
//DataType = Double value starting from 1. Indicates if values are Int, Float, Bool, etc.
//Item = Double begining with 1. Indicates what the message content is i.e. Health, speed, dampers.
//CurrentValue = Send as a double (4 byte limit) send coordinates as strings
//MaxValue = Send as a double (4 byte limit) send coordinates as strings
//StopBit = "\x03"
//Serial String Format (StartBit)(Item,StringValue)(StopBit)
//StartBit = "\x04"
//Item = Int begining with 1. Indicates what the message content is i.e. 1 =X coordinate, 2=Y Coordinate, 3=Z coordinate
//StringValue = Send as a double (4 byte limit) send coordinates as strings
//StopBit = "\x05"
static boolean recvInProgress = true;
static byte index = 0;
//char startMarker = 0x2;
//char endMarker = 0x3;
char startMarker = '<';
char endMarker = '>';
char startMarkerString = '~';
char endMarkerString = '^';
char rc;
//Serial.println("Grabbing message to parse:");
while (Serial.available() > 0 && message == false)
{
rc = Serial.read();
if (rc == startMarker) {
startMarkerUsed = rc;
Serial.println(startMarkerUsed);
recvInProgress = true;
}
if (rc == startMarkerString) {
startMarkerUsed = rc;
Serial.println(startMarkerUsed);
recvInProgress = true;
}
if (recvInProgress == true)
{
delay(1);
Serial.print(rc);
if (rc != endMarker && rc != endMarkerString )
{
delay(1);
receivedChars[index] = rc;
index++;
if (index >= numChars)
{
index = numChars -1 ;
}
}
else
{
delay(1);
Serial.println();
Serial.println(F("Terminating read"));
receivedChars[index] = '\0'; // terminate the string
recvInProgress = false;
index = 0;
message = true;
Serial.print(F("All Characters reveived: "));
Serial.println(String(receivedChars));
Serial.println();
}
}
}
//Serial.println("End of message");
//delay(1000);
//Serial.println("End of Serial available");
//delay(10000);
switch (startMarkerUsed)
{
case '<':
//message = true;
startMarkerUsed = '.';
parseDoubleMessage();
break;
case '~':
//message = true;
startMarkerUsed = '.';
parseStringMessage();
break;
case '.':
//do nothing
break;
default:
//DebugPrint("Default case: ", 1);
break;
}
//Serial.print("RAM after Execution: ");
//Serial.println(freeRam());
//delay(5000);
}
void DebugPrint( char *debugMessage, int Var1)
{
Serial.print (debugMessage);
Serial.print (Var1, DEC);
Serial.println();
}
void parseDoubleMessage()
{
char delimiter[] = ",";
char* valPosition;
double doublearray[5];
int dataType = 0;
int item = 0;
double CurrentValue = 0.0;
double MaxValue = 0.0;
int i = 0;
//Serial.println("Parsing Double Message:");
if (message == true)
{
//Serial.print("RecievedChars: ");
//Serial.println(receivedChars);
valPosition = strtok(receivedChars, delimiter);
while (valPosition != NULL)
{
doublearray[i] = atoi(valPosition);
valPosition = strtok(NULL, delimiter);
//DebugPrint("Item Index: ", i);
//DebugPrint("Loop Value: ", doublearray[i]);
i++;
}
//DebugPrint("Current Item1: ", doublearray[0]);
//DebugPrint("Current Item2: ", doublearray[1]);
// DebugPrint("Current Item3: ", doublearray[2]);
//DebugPrint("Current Item4: ", doublearray[3]);
//String serialDebug = "";
//serialDebug = " Array of ";
//serialDebug += i,DEC ;
//serialDebug += " doubles created.";
//Serial.println(serialDebug);
dataType = (int)doublearray[0];
item = (int)doublearray[1];
CurrentValue = doublearray[2];
MaxValue = doublearray[3];
doublearray[4] = '\0';
//DebugPrint("DataType: ", dataType);
//DebugPrint("item: ", item);
DebugPrint("CurrentValue: ", CurrentValue);
//DebugPrint("MaxValue: ", MaxValue);
message = false;
//Message received:
//digitalWrite(led13, HIGH); // turn the LED on (HIGH is the voltage level)
//delay(1000); // wait for a second
//digitalWrite(led13, LOW); // turn the LED off by making the voltage LOW
//delay(1000); // wait for a second
}
switch (item)
{
case 1:
//DisplayHealth();
break;
case 2:
DisplayEnergy(CurrentValue);
break;
case 3:
DisplayOxygen(CurrentValue);
break;
default:
//DebugPrint("Default case: ", 1);
break;
}
//delay(5000);
Serial.println(F("Double Parsing Completed."));
delay(2000);
}
void parseStringMessage()
{
char delimiter[] = ",";
char* valPosition;
int ItemType = 0;
char ItemText[64];
int i = 0;
//Serial.println("Parsing String Message:");
if (message == true)
{
//Serial.print("RecievedChars: ");
//Serial.println(receivedChars);
valPosition = strtok(receivedChars, delimiter);
ItemType = atoi(valPosition);
valPosition = strtok(NULL, delimiter);
strcpy(ItemText, valPosition);
}
// DebugPrint("Item Type: ", ItemType);
// String serialDebug = "";
// serialDebug = "String received: ";
// serialDebug += String(ItemText);
// Serial.println(serialDebug);
// digitalWrite(led12, HIGH); // turn the LED on (HIGH is the voltage level)
// delay(1000); // wait for a second
// digitalWrite(led12, LOW); // turn the LED off by making the voltage LOW
// delay(1000); // wait for a second
//message = false;
//Serial.println("End of String Parsing");
}
void DisplayEnergy(double CurrentValue)
{
char TempString[7];
dtostrf(CurrentValue / 100, 2, 2, TempString);
String displayVal = String(TempString); // cast it to string from char
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay();
display.display();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
display.drawBitmap(0, 0, Suit_Energy, 128, 64, 1);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(34, 36);
display.println(displayVal + '%');
display.display();
Serial.println(F("Energy displayed."));
//delay(2000);
}
void DisplayOxygen(double CurrentValue)
{
char TempString[7];
dtostrf(CurrentValue / 100, 2, 2, TempString);
String displayVal = String(TempString); // cast it to string from char
display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay();
display.display();
display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
display.drawBitmap(0, 0, Oxygen, 128, 64, 1);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(34, 36);
display.println(displayVal + '%');
display.display();
Serial.println(F("O2 displayed."));
//delay(2000);
}
int freeRam () {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
[/CODE]
I'm thinking just cleaning. And maybe a different parser, but I don't have the C# program sending the data from space engineers so I'm not sure whats coming out or what format it's in and that doesn't help.
edit: well holy shit they forgot to shuffle one of their logo files (huuuge array for LCD, just uint8_t type) to flash. I assumed it already had been sent there, but when I did it myself the SRAM usage dropped from 2705bytes... to 1,681 bytes. Yay! I'm also rewriting the routine for writing to and accessing the flash for this program, the avr progmem seems fine on a low level but I think I can improve this. Also going to look for more spots I can cut.
[QUOTE=ZpankR;48932310]Making a "Keep Talking and Nobody Explodes" helper. So far so good![/QUOTE]
I wanted to learn more about data science and decided to try and learn Python. Looks like we had similar ideas! Not really data science but straight forward and seems like a good project. I only have a wire module so far. I plan on building some kind of validation to make sure the user gives the program a valid wire module, so you can't give it words that aren't colors or too many wires.
[video]https://youtu.be/cJ61ff-yzlg[/video]
[QUOTE=Winner;48969598]this is such a fucking stupid and short-sighted post, it completely depends on what you're trying to do
making a 3d game? use c#, java, unity, whatever...
interactive data analysis? use jupyter with python, haskell or r
writing a spark application to offload some heavy tasks to a cluster? use python or java
plus it's [I]extremely[/I] convenient to know an interpreted language for being able to punch out a quick script without setting up a proper dev environment (doing stuff on an ec2 instance, someone else's computer...), or when you need to make and rapidly update a simple script without creating extra project files or compiling every time, etc. your options for this are pretty much python, perl, and ruby, and python is by far the easiest to learn and the most actively used at the moment.[/QUOTE]
What i mean is, there's nothing new in Python that you need to learn if you're already a programmer.
There's no explicit learning process. Just think about what you need to make and go through the documentation.
Find the functions you need and implement your solution.
[QUOTE=MatheusMCardoso;48972051]What i mean is, there's nothing new in Python that you need to learn if you're already a programmer.
There's no explicit learning process. Just think about what you need to make and go through the documentation.
Find the functions you need and implement your solution.[/QUOTE]
Well, not necessarily, a solution deemed idiomatic in C#, Java, C++ or C is probably not one that is so in Python, but sure, you can probably just jump in and produce code. It just probably won't be any good by the standards of the language. :v:
Though, admittedly, python isn't that much of a paradigm shift from most others, but still.
Or as is commonly said: "You Can Write FORTRAN in any Language"
Finished adding support for functions to my RPN calculator.
[vid]http://zippy.gfycat.com/FlatZealousLangur.webm[/vid]
[img]http://nabile.s-ul.eu/NFuguG1f[/img]
Woo ! :dance:
Basically, I've tried to do a constructor overload to avoid passing a delegate for most types I use with this class.
I knew it was dirty, but I just wanted to see what would have happened.
Some Frostbite 2+ terrain loading, rendering, and editing amongst other things.
[t]http://i.nofate.me/IkgGfjoB.png[/t]
More [url=http://forums.veniceunleashed.net/viewtopic.php?f=43&p=48228]here[/url] with side-by-side comparison of in-game terrain.
I've been working on a web based mutiplayer space shooter with my friend/artist salmonmarine. We recently posted the game on 4Chan to get some people to test. It was pretty fun with all the people we got to join. Got a lot of interesting feedback so salmonmarine put some of it together in this image.
[thumb]https://pbs.twimg.com/media/CSDg2H4UEAAh2MV.jpg:large[/thumb]
Some responses weren't that constructive(it is 4Chan I don't know what I expected) but it was awesome seeing people play.
Our project for the CUES hackathon (half way through so far)
[img]http://i.imgur.com/pDZwqjs.png[/img]
was trying to get a dither shader working and got this by accident on the way there
[IMG]http://i.imgur.com/KfTMCGG.gif[/IMG]
It took me several days, but I finally my engine compiling and running under GLFW and GLM instead of Qt. It can compile and run without crashing, and everything appears to work, however actually sending shit to the shaders doesn't quite work yet.
Not sure why, but I recon it has something to do with attribute arrays. Back in Qt that shit was easy, it was like uploading a uniform.
[img]http://i.imgur.com/ergeihx.png[/img]
[QUOTE=r0b0tsquid;48975474]http://i.imgur.com/ergeihx.png[/QUOTE]
#trashtag brings up some interesting results.
[t]http://i.imgur.com/P8oOjqX.png[/t]
In other news, here's a guide on how not to limit a air vehicles rotation:
[vid]https://dl.dropboxusercontent.com/u/15606445/How%20not%20to%20limit%20rotation.mp4[/vid]
[t]http://i.imgur.com/fc8aPeP.png[/t]
[t]http://i.imgur.com/AU5v2Q3.jpg[/t]
More screens of the game that I'm working on! A friend of mine is learning how to model in order to help me with the game. The gun being used by the capsuleperson in these shots has been made by him!
This is a co-op game where players will be able to "go inside TV channels" and fight their way through movies and shows. We are currently working on the first show, a "die-hard"esque police action movie called "Achilles Last Stand".
I am enjoying working on this project!
Tweets randomly selected from a file
[img]http://i.imgur.com/njuShMe.png[/img]
[QUOTE=r0b0tsquid;48976349]Tweets randomly selected from a file
[img]http://i.imgur.com/njuShMe.png[/img][/QUOTE]
You could have potentially billions of phrases with a fraction of the effort, using this one weird trick...
[sp]Writers HATE me![/sp]
[vid]http://webm.host/f153a/vid.webm[/vid]
Got love.audio working on 3DS to some degree
Rather small uninteresting update
Bots work together now and if one has the puck the other will go back to play defense rather than running over its teammate to get to the puck.
[img]https://i.imgur.com/Q9W8r5U.png[/img]
Making an http server is pretty cool. Never really thought of implementing a server at the protocol level.
First time hooking DirectX on my multiplayer mod. Implemented a way for the server to write to player's screens in a makeshift chat, even got a small syntax for putting colours in and a way to put raw data in without it being parsed. Next task is using the camera matrix to put nametags over people.
[media]https://www.youtube.com/watch?v=2Hy-hmZ0X6M[/media]
so like
[code]
ADD_MESSAGE(kMessageConsoleMsg, "{20,20,255}CONSOLE: {255,255,255} %s");
ADD_MESSAGE(kMessageConsoleErr, "{20,20,255}CONSOLE: {255,255,255} %s");
ADD_MESSAGE(kMessageConnected, "{85,210,85}Connected to server.");
[/code]
NPC's in the video aren't synchronised but I have a framework in place that needs networked and testing, basically letting the first person in the cell control objects and sync them to the other clients, people could cheat but whatever. Inventory and apparel synch just needs the net messages on and then it should be somewhat playable. Also I wish ffmpeg wasn't horse shit man.
[QUOTE=brianosaur;48976933]Making an http server is pretty cool. Never really thought of implementing a server at the protocol level.[/QUOTE]
In python:
[code]import http.server[/code]
Does this count?
[img_thumb]http://i.imgur.com/DdGNNsL.jpg[/img_thumb]
Game can compile and be played on linux now. Although SFML is cross-platform I had to rewrite parts of my collision code and clean up some bad code here and there.
Following up on my previous post about terrain editing in Frostbite 2+ games, here's a screenshot with a custom flat terrain for Alborz in BF3 (notice the floating trees, lake, and debris.)
The mountains in the back are meshes (probably), not terrain.
[t]http://i.nofate.me/bP2vMu0O.png[/t]
Tried implemeting an HTTP server in perl. After reading the following code, it dawned on me how incredibly simple it can be to do:
[code]
#!/usr/bin/perl
use Socket;
use Carp;
use FileHandle;
# (1) use port 8080 by default, unless overridden on command line
$port = (@ARGV ? $ARGV[0] : 8080);
# (2) create local TCP socket and set it to listen for connections
$proto = getprotobyname('tcp');
socket(S, PF_INET, SOCK_STREAM, $proto) die;
setsockopt(S, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) die;
bind(S, sockaddr_in($port, INADDR_ANY)) die;
listen(S, SOMAXCONN) die;
# (3) print a startup message
printf(" <<<Type-O-Serve Accepting on Port %d>>>\n\n",$port);
while (1)
{
# (4) wait for a connection C
$cport_caddr = accept(C, S);
($cport,$caddr) = sockaddr_in($cport_caddr);
C->autoflush(1);
# (5) print who the connection is from
$cname = gethostbyaddr($caddr,AF_INET);
printf(" <<<Request From '%s'>>>\n",$cname);
# (6) read request msg until blank line, and print on screen
while ($line = <C>)
{
print $line;
if ($line =~ /^\r/) { last; }
}
# (7) prompt for response message, and input response lines,
# sending response lines to client, until solitary "."
printf(" <<<Type Response Followed by '.'>>>\n");
while ($line = <STDIN>)
{
$line =~ s/\r//;
$line =~ s/\n//;
if ($line =~ /^\./) { last; }
print C $line . "\r\n";
}
close(C);
}
[/code]
And the above is far from the simplest way of doing it.
Some people on PerlMonks even suggested the following:
[code]
io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 ? "./$1 |" : $1) if /^GET \/(.*) / })
[/code]
Which, when you look at it, is actually a REALLY readable single line web server. Neat.
nice work
is no indentation standard for perl? :v:
Sorry, you need to Log In to post a reply to this thread.