Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
chocojosh
Jun 9, 2007

D00D.

sund posted:

I do this in python by accessing the stdout stream directly and sending it '\b' characters.

That is incredibly cool, I just tried this in C++:

code:
#include <iostream>
using std::cout;

int main() {
	cout << "This is some text";
	cout.flush();

	sleep(2); //in seconds
	for(int i = 0; i < 17; i++)
		cout << "\b";
	cout << "new text!";
	cout.flush();

	return 0;
}

Adbot
ADBOT LOVES YOU

That Turkey Story
Mar 30, 2003

zootm posted:

Yeah, \b moves back one character whereas \r moves to the beginning of the current line.

This is not guaranteed to be portable, so use at your own risk.

zootm
Aug 8, 2006

We used to be better friends.

That Turkey Story posted:

This is not guaranteed to be portable, so use at your own risk.
The \r, the \b, or both? I've never actually used either so someone who knows about this would be appreciated.

csammis
Aug 26, 2003

Mental Institution

zootm posted:

The \r, the \b, or both? I've never actually used either so someone who knows about this would be appreciated.

I don't know about \b, but \r was used as the full newline character on pre-OS X Macs, so it wouldn't have the effect of moving the cursor back to the start of the current line.

zootm
Aug 8, 2006

We used to be better friends.
Oh yeah, now you mention it I knew that. Hmm.

Scaevolus
Apr 16, 2007

csammis posted:

I don't know about \b, but \r was used as the full newline character on pre-OS X Macs, so it wouldn't have the effect of moving the cursor back to the start of the current line.
Yeah, because we really need to support the vast quantities of pre-OS X Macs. Carriage return is an even worse newline character than "\r\n".

Kilometers Davis
Jul 9, 2007

They begin again

I've got some questions. They might be better suited for other threads but I figured I would just post them here.

How important is math when programming? I was decent at it during highschool but didn't do anything close to advanced studies. After two years post-graduation I haven't retained a lot either.

Is there a real advantage of learning C prior to C++? It's what i'm doing now (alongside of Python too) but i'm thinking of just saving myself the time and jumping into C++.

Is there a solid C primer out? I'm learning from scratch with the K&R book and it's extremely confusing with how precise it is. I need something slower and more dumbed down I guess, hah.

What language has the largest job market when it comes to specialization. That said, I realize it's important to know as much as you can.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

IntoTheNihil posted:

How important is math when programming? I was decent at it during highschool but didn't do anything close to advanced studies. After two years post-graduation I haven't retained a lot either.

It depends on if you want to do a lot of mathematical programming. Logic is important though.

IntoTheNihil posted:

Is there a real advantage of learning C prior to C++? It's what i'm doing now (alongside of Python too) but i'm thinking of just saving myself the time and jumping into C++.

Only if you want to be able to write pure C. If you only ever intend to use C++, it doesn't really matter.

IntoTheNihil posted:

Is there a solid C primer out? I'm learning from scratch with the K&R book and it's extremely confusing with how precise it is. I need something slower and more dumbed down I guess, hah.

Honestly, you'd probably learn more by simply coming up with some little projects to do and writing them in C, and use K&R as a reference.

IntoTheNihil posted:

What language has the largest job market when it comes to specialization. That said, I realize it's important to know as much as you can.

Probably Java, or maybe PHP. There are no end of lovely "enterprise" products written in Java, and no end of lovely websites written in PHP.

Kilometers Davis
Jul 9, 2007

They begin again

Thanks. Coming up with my own projects is hard but i'll give it a shot.

Also, one more thing. Are certificate classes worth taking? I've got two decent schools around here that offer programming courses.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
I don't think I've ever known someone with a "programming certificate".

hexadecimal
Nov 23, 2008

by Fragmaster

Avenging Dentist posted:

I don't think I've ever known someone with a "programming certificate".

I got one, dawg, its posted on my wall.

Scaevolus
Apr 16, 2007

hexadecimal posted:

I got one, dawg, its posted on my wall.
Was !(x^y) on your certification exam?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

I assume he's talking about A+/MS/Cisco/etc certification, in which case, not if you're interested in programming. At best, they'll be introductory data structures classes, and in the average case, they'll be strictly IT classes.

Regarding math: In high school, math was my lowest mark by a good 25% and I never bothered taking Grade 12 math. I spent two years as a music major before taking a CS course on a whim and loving it so much that I dropped out of university to take grade 12 math and precalculus. It turned out that those years away did me good, and I'm now going to be graduating with a math minor. If you're worried about your math skills, there's nothing wrong with going to a local college and brushing up your knowledge.

Another question that should be asked is, what do you want to do with your programming knowledge? This would affect what choice of language you should approach. You mentioned that you're looking at the job market, then as before, I'd echo the Java and PHP suggestions, and throw in C# as well, since IMHO it's the most tolerable of the big enterprisey languages (assuming you're on a Windows machine). Given this, I wouldn't even bother learning C and certainly not C++.

Alternately, if you're a Mac user, I have heard it said that the Mac development world is booming thanks to the iPhone, so if you're a Mac person, learning C and then Objective-C might be a path to success for you.

Also, I disagree with your "That said, I realize it's important to know as much as you can." quotation - the way I read it, it sounds like you're suggesting a breadth of languages is important, and that's not the case; you are far more employable with knowing one language very well as opposed to knowing the rudiments of five.

Kilometers Davis
Jul 9, 2007

They begin again

I was talking about a cert like this: http://www.advancedtechcollege.org/Program%20PDF/0938.pdf

Just something to give me a big boost in starting out.

Dijkstracula posted:

what do you want to do with your programming knowledge?
Honestly, i'm not sure. I've always loved working with computers and want to eventually have a career in the field. The idea of being a game developer always looms but I don't really feel I should shoot for that. I am always thinking up programs and games but don't have the skills to create anything, so i'm looking to change that.

Dijkstracula posted:

Also, I disagree with your "That said, I realize it's important to know as much as you can." quotation - the way I read it, it sounds like you're suggesting a breadth of languages is important, and that's not the case; you are far more employable with knowing one language very well as opposed to knowing the rudiments of five.
I've always thought that knowing multiple languages really opens up your career possibilities.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

It's hard to say how that certificate would go; to be sure, it would give you a foundation, but you'd still have to build on it on your own time afterwards to make yourself marketable, in my view. One year really isn't enough to get deeply into the field, IMO.

IntoTheNihil posted:

Honestly, i'm not sure. I've always loved working with computers and want to eventually have a career in the field. The idea of being a game developer always looms but I don't really feel I should shoot for that. I am always thinking up programs and games but don't have the skills to create anything, so i'm looking to change that.
So, make no mistake: if it's game development that you're keen on, then you will absolutely require a great amount of math, and most likely a university degree.A friend of a friend works at Bioware with only the Canadian equivilent of an associate's degree (two years at a polytechnic), but he would be the exception to the rule. A brilliant friend of mine was offered a job at Bioware after he graduates from university, but even then he'd only be doing toolset development gruntwork*.


IntoTheNihil posted:

I've always thought that knowing multiple languages really opens up your career possibilities.
While that's true, given that you're starting from first principles I still maintain it's better to focus on a particular skillset rather than trying to be a jack-of-all-trades. Perhaps others will weigh in on this.

*I live in the town that Bioware is based in; hence why both my gamedev stories involved that one company.

Kilometers Davis
Jul 9, 2007

They begin again

Dijkstracula posted:

It's hard to say how that certificate would go; to be sure, it would give you a foundation, but you'd still have to build on it on your own time afterwards to make yourself marketable, in my view. One year really isn't enough to get deeply into the field, IMO.

So, make no mistake: if it's game development that you're keen on, then you will absolutely require a great amount of math, and most likely a university degree.A friend of a friend works at Bioware with only the Canadian equivilent of an associate's degree (two years at a polytechnic), but he would be the exception to the rule. A brilliant friend of mine was offered a job at Bioware after he graduates from university, but even then he'd only be doing toolset development gruntwork*.

While that's true, given that you're starting from first principles I still maintain it's better to focus on a particular skillset rather than trying to be a jack-of-all-trades. Perhaps others will weigh in on this.

*I live in the town that Bioware is based in; hence why both my gamedev stories involved that one company.
Yeah, I didn't expect it to be something that would teach me everything, just give me a strong foundation to work from.

That's what I was afraid of. It's not big deal though, as I didn't expect to get to that level anyway. What other options do I have relating to programming jobs that aren't just random Java game sites? I really want to specialize somewhere I excel at and enjoy but it's hard to even know what's out there, hah.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
One thing I want to make clear: the sort of math that makes you a better general programmer (logic and discrete mathematics) is very different in both subject and style from the standard (American) high school math progression (trigonometry and calculus). Lots of people enjoy the former who hated the latter, and not just because the latter was coincident with high school.

3D games programming is heavy on linear algebra, which is sometimes kindof partly covered in calculus sequences.

wigga please
Nov 1, 2006

by mons all madden
I'm looking to write a poker hand evaluation app but I'm stuck on some algorithm. I only took my first steps in C# and programming in general a few months ago.

Basically, a string representing a hand should be searched for characters occuring multiple times. The count of these characters as well as the character itself should be returned. I'm not sure if I should use a 2-dimensional array, a collection or whatever.

Here's a basic example of the type of loop, str being the string inputted by a user, consisting of chars of 14 possible types.

code:
for (int i = 0; i < str.Length; i++)
{
   for (int j = i+1; j < str.Length; j++)
   {
       if (str[i] == str[j])
       {
         //counter should go up here as well as char should be noted somehow. 
         //if a different char occurs multiple times it can't be added, but needs 
         //it own place in an array/collection/list...
       }
   }
}
This is probably peanuts to some of you so help a goon out will ya?

Thanks

10011
Jul 22, 2007
I don't know C# that well, but a Dictionary<char, int> would work, with something like

code:
var d = new Dictionary<char, int>();
foreach (char c in str) {
  if (d.ContainsKey(c))
    d[c]++;
  else
    d[c] = 1;
}
Alternatively, you could probably do in one line using LINQ.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
If you're working with string representations of poker hands, odds are very good that it's all 7-bit ASCII and the following will work just fine:

code:
int[] set = new int[128];
foreach (char c in str) set[c]++;
EDIT: but you'll probably be much happier in both the short and long term if you parse the string into a collection of cards.

rjmccall fucked around with this message at 10:34 on Jan 13, 2009

J. Elliot Razorledgeball
Jan 28, 2005
If I just want to create a simple batch or VBS file to run as a system service, what do I need to do in order to stop getting error 1053 (Service failed to respond in a timely manner)? Do I have to have the batch file echo back something to the service controller to say "OK I'm started"?

csammis
Aug 26, 2003

Mental Institution

J. Elliot Razorledgeball posted:

If I just want to create a simple batch or VBS file to run as a system service, what do I need to do in order to stop getting error 1053 (Service failed to respond in a timely manner)? Do I have to have the batch file echo back something to the service controller to say "OK I'm started"?

Services are specialized applications that respond to the service manager. Batch files aren't services and can't be run by the service manager. You probably want to use the Task Scheduler to run your batch file or VBS at given intervals.

J. Elliot Razorledgeball
Jan 28, 2005

csammis posted:

Services are specialized applications that respond to the service manager. Batch files aren't services and can't be run by the service manager. You probably want to use the Task Scheduler to run your batch file or VBS at given intervals.

The problem is whenever I log out of RDP the program will close 10 minutes later. How can I set this up in the task scheduler to have it running 24/7? It's basically a background daemon answering simple requests on a particular port.

Also, just for curiosity's sake now, would it actually be possible to have a batch file work as a service? Or is it just absolutely impossible?

csammis
Aug 26, 2003

Mental Institution

J. Elliot Razorledgeball posted:

The problem is whenever I log out of RDP the program will close 10 minutes later. How can I set this up in the task scheduler to have it running 24/7? It's basically a background daemon answering simple requests on a particular port.

The Task Scheduler isn't for running things 24/7, but what you want to do is evidently not task scheduling. This is really throwing me though: you're answering socket requests in a batch file? How? :raise:

quote:

Also, just for curiosity's sake now, would it actually be possible to have a batch file work as a service? Or is it just absolutely impossible?

.bat files cannot be run by the service manager because they are not applications that support the service interface (Start, Stop, Restart, reporting status, etc.). Someone may have written a service that does nothing but run a batch file over and over again, but batch files are by design one-shot scripts, not daemons.

You should probably be very specific as to what you're doing with what technologies, because I'm very confused right now.

J. Elliot Razorledgeball
Jan 28, 2005
It's basically just a batch file that starts a lisp script that listens on a port, and when something connects to the port it returns some basic performance information. It needs to be running constantly in the background to listen for incoming connections.

TSDK
Nov 24, 2003

I got a wooden uploading this one

J. Elliot Razorledgeball posted:

It's basically just a batch file that starts a lisp script that listens on a port, and when something connects to the port it returns some basic performance information. It needs to be running constantly in the background to listen for incoming connections.
Can you not just modify the lisp script so that once it's kicked out the information, it loops (tail recurses) back round to start listening again?

HungryHobo
Jun 21, 2008

by angerbotSD
Last year one of my college modules involved a brief introduction to some of the approaches to machine learning and AI.
Now I've been told many a time that the only real application as it stands is boardgames and better book suggestions on Amazon but when it comes down to it I just find the whole area fascinating.
I've tried making a few basic neural networks but I always seemed to get caught in local minima or or end up wandering vaguely over the hills of uselessness.

I was wondering if anyone here could give me some sugestions for sites to read, books or decent beginner projects in this area.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

HungryHobo posted:

I was wondering if anyone here could give me some sugestions for sites to read, books or decent beginner projects in this area.
My school is big in ML, and if you told them that it was only good for boardgames, they'd go into conniptions :v:

If you're looking for an excellent overview of AI, in my view you can't go wrong with the Russell/Norvig text. Very complete and entertaining to read, even for someone like me who didn't really enjoy his AI class.

I guess the question is, what specifically did you like? Search? If so, adversarial search (minimax / alphabeta, etc)? Bayesian nets? Machine learning? If so, what specifically? Reenforcement learning? Vision? (If the answer to this question is "er, I donno", then the Russel/Norvig might be good in singling down especially what you like)

Also, talk to professors at your college who work in AI/ML. It's an excellent way to get yourself thinking about what they research, and maybe even working for them as an undergraduate summer research student.

J. Elliot Razorledgeball
Jan 28, 2005

TSDK posted:

Can you not just modify the lisp script so that once it's kicked out the information, it loops (tail recurses) back round to start listening again?

I could, but I don't know lisp and the original author of this script is long gone, so I just need to work with this for the foreseeable future. I know it's a crappy situation, but I just need this to work for now.

Rowe
May 16, 2006
I'm trying to find the answer on my own but the problem is I'm not exactly sure what I should be searching for as far as terminology.

I have an excel workbook with a bunch of pricing from different mortgage lenders. What would be the easiest way to compare across lenders when some of them price differently by state? They'll usually have a base price and then depending on state add in an additional amount. I tried making a huge table but that seems like it will take forever based on the amount of time it took me to finish one interest rate across all of them.

I thought maybe drop down boxes with a bunch of "if" statements would look the cleanest but that also seems like a ton of code. I wasn't sure if there was a way to put all the information in some sort of matrix and have excel pull it out based on which state I'm trying to compare. Any info that would point me in the right direction would be greatly appreciated.

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

J. Elliot Razorledgeball posted:

I could, but I don't know lisp and the original author of this script is long gone, so I just need to work with this for the foreseeable future. I know it's a crappy situation, but I just need this to work for now.
When does the lisp script return control to the batch script? If it happens when it's finished, then maybe just edit the batch file to run in an infinite loop?

csammis
Aug 26, 2003

Mental Institution

Jethro posted:

When does the lisp script return control to the batch script? If it happens when it's finished, then maybe just edit the batch file to run in an infinite loop?

This would be my idea without actually going out and creating a real service. The service manager still won't be able to run the infinitely looping batch file, but you could probably still use the task scheduler to start it once and just let it run until you decide to stop it (somehow).

J. Elliot Razorledgeball
Jan 28, 2005

csammis posted:

This would be my idea without actually going out and creating a real service. The service manager still won't be able to run the infinitely looping batch file, but you could probably still use the task scheduler to start it once and just let it run until you decide to stop it (somehow).

Well the program should run indefinitely - it doesn't stop when it receives the command. It keeps running forever and ever and ever and ever...

It should act just as a daemon, except it's called from within a batch script.

tripwire
Nov 19, 2004

        ghost flow
Can anyone help me out or at least point me in some direction regarding the fastest way to draw alpha blended polygons, in Windows?

It would be ideal if I could do this through python (unfortunately not ironpython, as it seems to be incompatible with numpy for the time being), however since I don't have much code I'd consider porting it into c or java or even perl if those would be faster.
What I have now is this rudimentary picture approximator which presently works by drawing on a cairo surface and aliasing this surface as a numpy array in order to process it. I have finished making it multicore using the multiprocessing module but I'm disappointed that the only available versions of cairo for windows do not support the array interface like the version available for osx and linux. I want to package this as a windows exe, but without cairo I need some other method of painting alpha blended polygons. The Python Imaging Library has a routine for drawing solid triangles but the only way I can think of going from that to alpha blending is to smush two image arrays together for each triangle drawn, and I'm sure thats not a smart way to do it. PIL allows one to write to images through numpy arrays, so one option is to try my hand at rasterizing and blending the triangles directly to image arrays just using array math. I don't know any algorithm for partitioning the triangle into a minimum number of rectangles, and certainly not any fast ones but I have a feeling I'd need to implement that if I wanted to take that route.

I know a lot of posters here have made games and done lots of 3d stuff before, can anyone give me a hint on the most painless way to port my program over to windows? Is there some library that would mesh into multithreaded python code seamlessly or am I better of starting from scratch in c or java? Should I touch the GPU?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

tripwire posted:

Should I touch the GPU?

Of course touch the GPU. GPUs are expressly designed for fast rendering of polygons.

hexadecimal
Nov 23, 2008

by Fragmaster
Transparency can be tricky. You can certainly do it very fast using OpenGL, however (Python has OpenGL library). You can play around with it's blending functions, and you can probably get your desired effect. You can use it for rendering 2d polygons as well.

One important thing to mention, besides blending functions, is the order in which you draw polygons is important to achieve the correct transparency effects. Usually you want to draw furthest to nearest polygons in order, or the other way around. If you mix the order then you get some ugly artifacts.

http://pyopengl.sourceforge.net/documentation/manual/glBlendFunc.3G.html <-- How do you scale source and destination colors? Source color is incoming color, and destination color is what's already in framebuffer (the canvas on which you are drawing).
http://pyopengl.sourceforge.net/documentation/manual/glBlendEquation.3G.xml <-- What do you do with source and destination color? That is do you add them, pick maximum out of the two, etc.

EDIT: You can probably come up with inspiration of how to implement blending yourself without OpenGL by reading about how its done in OGL. However if you do it on CPU it will be much slower.

hexadecimal fucked around with this message at 02:09 on Jan 14, 2009

Kilometers Davis
Jul 9, 2007

They begin again

Sorry to spam up this thread with even more questions but I've recently discovered how huge the Java market really is. Even around my city there's multiple high paying jobs for Java programmers. Can anyone tell me the pros and cons of the language and some general learning info? I messed with it a bit before and even though people say it's simple I couldn't grasp much.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

IntoTheNihil posted:

Sorry to spam up this thread with even more questions but I've recently discovered how huge the Java market really is. Even around my city there's multiple high paying jobs for Java programmers. Can anyone tell me the pros and cons of the language and some general learning info? I messed with it a bit before and even though people say it's simple I couldn't grasp much.
Java, you'll find, is a controversial language around a lot of places since it's (misguidedly, many would argue) used as a teaching language in most universities. Also, I wouldn't call it "simple" - doing a simple "hello-world" printing program requires a lot of keywords that a beginner won't really have a grasp on. That being said, for all intents and purposes there's nothing wrong with the language, so long as you can grok the object-oriented programming paradigm (this is where that 1 year program you talked about might come in handy--a lot of people need an instructor to really get it).

One of the best things that Java has going for it, in my view, is Sun's documentation. There are many tutorials on Sun's website, and the reference material is quite robust.

Start small and work up slowly, don't get discouraged, and have fun. :)

hexadecimal
Nov 23, 2008

by Fragmaster

IntoTheNihil posted:

Sorry to spam up this thread with even more questions but I've recently discovered how huge the Java market really is. Even around my city there's multiple high paying jobs for Java programmers. Can anyone tell me the pros and cons of the language and some general learning info? I messed with it a bit before and even though people say it's simple I couldn't grasp much.

How much of object oriented programming do you know? If you know the basics of OOP learning Java shouldn't be hard. If not you should really learn theory and concepts behind it.

Adbot
ADBOT LOVES YOU

Kilometers Davis
Jul 9, 2007

They begin again

Thanks for the info Dijk.

hexadecimal posted:

How much of object oriented programming do you know? If you know the basics of OOP learning Java shouldn't be hard. If not you should really learn theory and concepts behind it.

None at all. I'm brand new to programming but very interested in finding my niche.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply