Eat. Sleep. Code: The Computer Programming Thread, Ver. 010

Next tuesday Im attending a talk on the new unity GUI features coming out, should be cool, might meet some interesting people

Got assigned a project at work today to break up the constant support and clean up of a proprietary ERP system that I 've been doing for two months.

Happy and a tad nervous. I donā€™t think itā€™ll be too bad.

So are you going to rewrite the whole thing then?

All by my lonesome.

No, Iā€™m rewriting an old app that is part of the approval process for putting ā€˜Itemsā€™ into the system and hopefully making the whole thing a but more automated since right it has people copy/pasting records from one SQL database into another.

Thanks for the insight. Nice post. In a way I found out that DB code (transact and whatever else) loosely resembl;es stuff like discrete math, calculus and other maths. I currently work for tier II support for an agency. Itā€™s boring as hell, and itā€™s almost like collecting retirement/welfare/unemployment/free checks. I guess this is my holdover job until private sector and public sectors start hiring again in the tech industry, or maybe not if they keep on outsourcing and suchā€¦

Say whatā€¦

Has anyone taken a Masterā€™s in Computer Science program? Is it like being in a Bachelorā€™s program? Whatā€™s different?

doing a Msc one now, I think thats really dependant on the university you are at. Similar structure, similar style tuition, my uni gave me a pretty varied list of optional modules, but the main thing is the workload is insignificantly increased, plus you have a thesis to do (so summer break for me).

I went into a different field for my Masters. I did Robotics and Control.

I looked into the MS for computer science and it was mostly specialize in a particular field under computer science. For example, machine learning was a popular choice at our school.
Not all MS degrees require a thesis, just the completion of the advanced course work.

I did a project and a thesis on it (90 pages, lots of pictures, and printing it was a pain in the butt).

Got to start my thesis now, I have to put in 660hrs between now and Christmas.

I was going to make a racing game but I think I would spend too much time in photoshop doing all the graphics, so Iā€™ve decided to do a super puzzle fighter clone for android. Not yet decided what extra features to add but I was recently playing portal which gave me a few ideas, as well as ST, so I might experiment with including a meter building mechanism if I have time. I wonā€™t be making all the characters, Iā€™ll probably just stick to Ken and Donovan.

Anyhoo, does anyone have any good sources for gaming algorithms? In order to get top marks Iā€™m thinking Iā€™d have to keep the Vs element of the game, but failing that Iā€™d have to allow the user to vs the CPU, Iā€™ll need to write an algorithm for the CPU to compete with the user.

ā€¦I think Iā€™ve bitten off more than I can chew. :wasted:

Programming AI is easy. Just have it be cheap and near unbeatable and piss the player off.

Iā€™m just wondering how youā€™d write that, how would you tell it to build gems, to not destroy a stack when the first opportunity arises, and take into account what the player is doing, then on top of that to do it at vary speeds. Maybe Iā€™m just getting too ahead of myself.

-yo: is javascript really a pain in the ass to use with Unity?

shit tonne of vids on youtube on the subject

I use C# for Unity scripts since Iā€™m more comfortable with that language.

^ - Thanks, guys! Thatā€™s what a dev told me at a hackathon. Iā€™m still working with him on the project because both him and another developer understand it back to front. Iā€™ll probably just ramp up in C# instead.

Have you done game state evaluation before? Along with look ahead stats?

It might be kinda hard actually if you keep the AI legit, and only let the evaluation know about the next piece in the stack. Youā€™d have to invent some sort of logic that weighs whats best now (clearing a block) vs whats best long term (making a big play). You could cobble together an AI that always clears when it can, and then use that as a foundation to have it start saving up for bigger plays. Luckily theres only a finite set of moves you can make, and you can at most evaluate a depth of 2, so you can process it pretty fast. Its all about weighting the board state properly. Most likely youā€™ll want to have the AI evaluate the current opponent board state, and make a decision based on that. No point in saving up for a big move if youā€™re about to get blocks rained down on your side of the board.

edit: http://electures.informatik.uni-freiburg.de/portal/download/49/6003/06-games_4up.pdf covers the different approaches pretty good

So, you have to write/develop a game and write a 90 page paper? What are the criteria for the game and the 90 page paper? I just finished mine in Organizational Leadership. We had to write a 40+ paper.

Thanks Pimp Willy :tup:

Yeh write a piece of software, write a paper with a max of 60pages, and do a presentation. The criteria is to use everything weā€™ve learnt plus an advanced module. So Iā€™ve pretty much learnt the fundamentals of programming, but now I have to look into something like A.I, security, show that I can teach myself and successfully implement it into my programme if I want to get a first.

Iā€™m new to much of this and am wondering whatā€™s an easy way to convert a string into an integer using getline() in C++?

It was suggested that I use stringstream, but the results arenā€™t what I want. It returns all integers until it comes upon a non-integer character.

For example, ā€œ9.4ā€ returns "9"
And ā€œ73oiasfkā€ returns ā€œ73ā€

I want to be able to evaluate the entire string and to attempt to convert it into an integer.

So something like ā€œ9.4ā€ or ā€œ73oiasfkā€ would return ā€œYou enterted a non-integer. Exitingā€¦ā€



#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {
 int input_var = 0;
 string num ="";
 
 do {
 cout << "Enter an integer (-1 = quit): ";
 getline(cin, num);

 stringstream myStream(num);
 if (!(myStream >> input_var )) {
 cout << "You entered a non-integer. Exiting..." << endl;
 break;

 }
 if (input_var != -1) {
 cout << "You entered " << input_var << endl;
 }
 } while (input_var != -1);
 cout << "All done." << endl;
 system("PAUSE");
}


Ok, forum software fucked me up on the reply I was going to give. Want to give code examples but Iā€™m pretty tired. Someone else can do that but maybe these pages can help you a little.

If your compiler supports the C++11 extensions for string objects, you can use the stoi() function to try it.

http://www.cplusplus.com/reference/string/stoi/

You can use a size_t pointer that will be set to the first non-numeric character in the string (if any), so you can check to see if itā€™s set after the conversion, and give the error if itā€™s not

If you canā€™t do that, you can probably scan the string the hard way before trying to convert it to an integer.

http://www.cplusplus.com/reference/cctype/isdigit/

Basically, use the length() function for string objects (num.length() in your case) to get the number of characters, then using a for loop to use the isdigit() function on each character until you either get a character that isnā€™t a digit, or the null terminator. If you donā€™t get a non-digit character, then do the conversion.