|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On June 13 2013 09:03 waxypants wrote: Do you have the source for the DLL? If so, are you compiling it as part of your solution? I have only use the C++ editions of VS so I am not sure how much visibility the C# version provides as far as C++ code and disassembly goes. I believe a DLL will only get compiled into your solution if you call methods from it. When it's referenced, though, the IDE will detect its presence, i.e. stuff in the DLL will show up in intellisence.
As far as visibility you are able to see all the method signatures as if you had the code file in your project, but you are not able to see the code within each methods (i.e. you see the interface, not the implementation, which is what you want. The DLL is in other words encapsulated).
|
On June 13 2013 00:24 Wobulator wrote: Dear all; I’ve been creating a chess AI. I’ve already created earlier versions, so I’m familiar with the programming required, but I have some specific questions about coding. The GUI is written in c#, which calls c++ DLLs to do the real thinking. Both are written by me in visual studio 2010 Express. 1) My board representations make heavy use of bitwise operators. Are these optimized and fast in a managed language? (Specifically Visual c++) 2) How does one debug a DLL? I saw something about attaching a debugger to the DLL. I’m not quite sure how this would work, and the internet says this can’t be done in Express edition anyways.
Because I'm not a computer scientist/engineer and just program for fun, I've always used the easiest programming tools, so I sometimes end up learning things backwards. Thanks for the help.
Ideally you'd have your DLL completely debugged BEFORE you start using it in your project. If you own the DLL, it's probably a good idea to fully test it on its own before you start using it in your project, which you would do with the source-code files for the DLL that you are writing, just the way you'd debug anything else. If you don't own the DLL then it's the responsibility of whoever owns it to make sure it's fully debugged before they distribute it. In this case you can (and probably should, though I never do) write a test program that will make sure the DLL works the way you think it does. If you have a unit test suite I believe you can make unit tests for a DLL (never done it myself but I've read programming books telling me that I should).
|
On June 13 2013 09:03 Millitron wrote: I need a little advice. My friends and I have been wanting to make a videogame for a good two years now. We finally have a good idea, and I want to start off on the best foot possible. I just graduated with a BS in Computer Science, so I'm pretty good at programming. I'm most confident in Java, but I also know a good deal of C#. My friends have no programming experience, and have just started learning Java.
I was wondering if anyone knew any good 2D engines that support isometric view and mouse interaction.
Thanks in advance.
I recommend trying out Löve2D And here is an isometric module for it: Isömap
You have to program in lua--> no compile, yet still quite fast. It's easy to learn, especially if you used C like languages before. I think your friend will learn it faster than Java.
Löve2D handles everything, opens the window, handles inputs, makes sounds. Has shader supports if you want some fancy effects.. Even has a built in physics engine (Box2D, used by for example Angry Birds, Bad Piggies, and a lot of Indie games. I wrote a löve2d tool for it). Also your game will be automatically multiplatform.
Cons are you can't really hide the source code, and lack of IDE support (not that much of a deal, at least there is trace)
|
I am getting a weird segmentation fault that I can't find the cause of. I would really appreciate some help. Here's my main:
// Main file
#include <iostream> #include "Deck.h" using namespace std;
int main() { Deck deck; cout << "DeckSize: " << deck.GetDeckSize() << endl;
return 0; }
This gets me a segmentation fault. However, if I separate the cout statement like the following, I don't get a segmantation fault and my code works correctly:
// Main file
#include <iostream> #include "Deck.h" using namespace std;
int main() { Deck deck; cout << "DeckSize: "; cout << deck.GetDeckSize() << endl;
return 0; }
I ran my code through GDB and it said that the segmentation fault occurred when "deck" is initiallized, then when Remake() is called, then when SetRank(int) is called such that rankIn = 2. This does not make any sense to me. Why would my cout statement change the way "deck" is initiallized and cause a seg fault some of the time?
Below are sections of the other files that are relevent.
+ Show Spoiler [Deck Header] +// Header file for Deck class
#ifndef DECK_H_ #define DECK_H_ #include "Card.h"
class Deck { Card card [52]; // 52 cards in a deck int deckSize; // Maximum number of cards in the deck, usually 52 int cardsPresent; // Current number of cards in the deck int lowRank; int highRank; bool acesHigh; // Identifies if the deck recognizes aces as high or low public: // Constructors Deck(); Deck(int); Deck(int, int);
// Getters Card GetCard(int i) {return card[i];} int GetDeckSize() {return deckSize;} int GetCardsPresent() {return cardsPresent;} int GetLowRank() {return lowRank;} int GetHighRank() {return highRank;} bool getAcesHigh() {return acesHigh;}
void Remake(); Card GetLowestCard(); // Returns the lowest card currently in the deck Card GetHighestCard(); // Returns the highest card currently in the deck void GetDeck(Card []); Card Draw(); // Draws a random card from the deck Card Draw(int, int); };
#endif + Show Spoiler [Deck Source] +// Source file for Deck class
#include <cstdlib> #include <ctime> #include "Deck.h"
Deck::Deck() { deckSize = 52; lowRank = 2; highRank = 14; acesHigh = true;
Remake(); }
...
void Deck::Remake() { for(int rank = lowRank; rank <= highRank; rank++) { for(int suit = 0; suit < 4; suit++) { card[cardsPresent].SetRank(rank); card[cardsPresent].SetSuit(suit); cardsPresent++; } } } + Show Spoiler [Card Header] +// Header file for Card class
#ifndef CARD_H_ #define CARD_H_ #define JACK 11 #define QUEEN 12 #define KING 13 #define ACE 14 #define ACE_LOW 1 #define CLUBS 0 #define DIAMONDS 1 #define HEARTS 2 #define SPADES 3 #include <string> #include <sstream> using namespace std;
class Card { int rank; // Card rank, 2-14 (aces high) or 1-13 (aces low) int suit; // Card suit, 0 = Clubs, 1 = Diamonds, 2 = Hearts, 3 = Spades string itos(int); public: Card(); // Default constructor Card(int, int); // First int specifies rank, second int specifies suit int GetRank(); // Returns card rank int GetSuit(); // Returns card suit void SetRank(int); // Sets card rank to given parameter void SetSuit(int); // Sets card suit to given parameter string GetName(); string GetNameCompact();
int operator+(Card cardIn) {return rank + cardIn.GetRank();} int operator-(Card cardIn) {return rank - cardIn.GetRank();} int operator*(Card cardIn) {return rank * cardIn.GetRank();} double operator/(Card cardIn) {return double(rank) / double(cardIn.GetRank());} Card operator=(Card cardIn); bool operator==(Card cardIn) {return rank == cardIn.GetRank() ? true : false;} bool operator!=(Card cardIn) {return rank != cardIn.GetRank() ? true : false;} bool operator>(Card cardIn) {return rank > cardIn.GetRank() ? true : false;} bool operator<(Card cardIn) {return rank < cardIn.GetRank() ? true : false;} bool operator>=(Card cardIn) {return rank >= cardIn.GetRank() ? true : false;} bool operator<=(Card cardIn) {return rank <= cardIn.GetRank() ? true : false;} };
#endif + Show Spoiler [Card Source] +// Source file for Card class
#include <iostream> #include "Card.h" using namespace std;
Card::Card() { rank = 2; suit = CLUBS; }
Card::Card(int rankIn, int suitIn) { rank = rankIn; suit = suitIn; }
void Card::SetRank(int rankIn) { rank = rankIn; }
int Card::GetRank() { return rank; }
void Card::SetSuit(int suitIn) { suit = suitIn; }
int Card::GetSuit() { return suit; }
|
@Beamer, I don't think you've actually set the value for cardsPresent in your Deck constructor.
|
It appears that cardsPresent is uninitialized, leading to unintended behavior (you could easily be accessing cards that don't exist). It's probably failing and breaking immediately as you call "SetRank(rank)" when rank is 2 because the default-constructed Deck will always have a lowRank of 2. Try adding "cardsPresent = 0" somewhere in the constructor and see if there are further problems.
|
Wow, thanks guys! That fixed my problem. I would have never guessed that the seg fault was because of that (in fact, I still don't understand it).
|
On June 19 2013 09:39 Beamer wrote: Wow, thanks guys! That fixed my problem. I would have never guessed that the seg fault was because of that (in fact, I still don't understand it). The segfault is in the Remake: card[cardsPresent].SetRank(rank); since cardsPresent is not defined, you don't what number you are going to get. GDB was right
|
Hey, got a question about reading binary files. (c++)
Is there any simple way of being able to see if someone edited the binary file before i try to load it in? So the program wont crash.
|
|
|
Anyone mess with the new android studio yet? i just finished my first year of compsci at UMD and looking to learn java now, does anyone recommend any books that have the equivalents of labs / projects that i would get from a course? thats always been my biggest issue, its much easier for me to learn if i things im told to program releating to what im currently learning.
|
On June 20 2013 01:16 phar wrote: Checksum
You answered me?
I got another question on the subject then. Say my program saves the file in it's first run and then the file is only loaded the next times i run the program. How is the program supposed to know what checksum the file had when it was written?
|
On June 20 2013 01:19 Omer wrote: Anyone mess with the new android studio yet? i just finished my first year of compsci at UMD and looking to learn java now, does anyone recommend any books that have the equivalents of labs / projects that i would get from a course? thats always been my biggest issue, its much easier for me to learn if i things im told to program releating to what im currently learning.
I'm subscribed to the New York Android Group, and they say it's still really buggy. It's only still in its early stages (v0.1.1). I'd recommend sticking with eclipse for the time being.
The java tutorials (http://docs.oracle.com/javase/tutorial/) are a great resource to start with to learning java.
|
Hyrule19149 Posts
On June 20 2013 01:58 Nausea wrote:You answered me? I got another question on the subject then. Say my program saves the file in it's first run and then the file is only loaded the next times i run the program. How is the program supposed to know what checksum the file had when it was written?
Save it somewhere.
|
On June 20 2013 01:58 Nausea wrote:You answered me? I got another question on the subject then. Say my program saves the file in it's first run and then the file is only loaded the next times i run the program. How is the program supposed to know what checksum the file had when it was written? Put the checksum at the beginning of the file? Fixed byte offset is easy to deal with.
And I don't really understand why you would check a binary file. If someone's dumb enough to play with those, they deserve a bluescreen.
|
On June 20 2013 02:15 Leafty wrote:Show nested quote +On June 20 2013 01:58 Nausea wrote:On June 20 2013 01:16 phar wrote: Checksum You answered me? I got another question on the subject then. Say my program saves the file in it's first run and then the file is only loaded the next times i run the program. How is the program supposed to know what checksum the file had when it was written? Put the checksum at the beginning of the file? Fixed byte offset is easy to deal with. And I don't really understand why you would check a binary file. If someone's dumb enough to play with those, they deserve a bluescreen.
Ok, thank you.
|
On June 20 2013 02:15 Leafty wrote:Show nested quote +On June 20 2013 01:58 Nausea wrote:On June 20 2013 01:16 phar wrote: Checksum You answered me? I got another question on the subject then. Say my program saves the file in it's first run and then the file is only loaded the next times i run the program. How is the program supposed to know what checksum the file had when it was written? Put the checksum at the beginning of the file? Fixed byte offset is easy to deal with. And I don't really understand why you would check a binary file. If someone's dumb enough to play with those, they deserve a bluescreen.
or you can save an example.bin.md5 or whatever in the same directory. Generate an md5 from the binary file when you load it, then compare it to the .md5 in the directory. If they match, there has been no corruption.
Sometimes files can get modified accidentally and not maliciously. Checksums will also catch things like corruption from weird things, like uploading it via ASCII mode instead of BIN mode to an ftp server. The most common case I see of this is stupid version control systems (*cough* clearcase *cough*)
|
Question:
1)Is there any good quiz or tests online that can accurately gauge your aptitude in a language? So if I wanna say that, for example, I am intimate with Java how can I make sure that I really am good with it proving myself that I am indeed knowledgeable in said field.
Also any tips for an aspiring Software Dev or Architect?
Been thinking of dabbling in web/online stuff except I have no experience or knowledge to even sustain my ability to study such field. Should I just go study javascript, css, html, php and go from there ?
edit: More info on 1: At what point can you say that you know a language well enough and know that you can confidently work on any project with said language coupled with a good reference to recall some obscure class/method/object? I doubt that people know the full capacity of a language's library much like someone knowing ALL the vocabulary in an dictionary. Is it just know the basic frame of an OOP language (if, do, while, bool etc...) and know your algo (data structures, search query etc...) and fill in any gaps (hopefully some gaps) with a good reference considering languages changes all the time?
|
On June 20 2013 03:00 heroyi wrote: Question:
1)Is there any good quiz or tests online that can accurately gauge your aptitude in a language? So if I wanna say that, for example, I am intimate with Java how can I make sure that I really am good with it proving myself that I am indeed knowledgeable in said field.
Also any tips for an aspiring Software Dev or Architect?
Been thinking of dabbling in web/online stuff except I have no experience or knowledge to even sustain my ability to study such field. Should I just go study javascript, css, html, php and go from there ?
edit: More info on 1: At what point can you say that you know a language well enough and know that you can confidently work on any project with said language coupled with a good reference to recall some obscure class/method/object? I doubt that people know the full capacity of a language's library much like someone knowing ALL the vocabulary in an dictionary. Is it just know the basic frame of an OOP language (if, do, while, bool etc...) and know your algo (data structures, search query etc...) and fill in any gaps (hopefully some gaps) with a good reference considering languages changes all the time?
Aptitude in a specific language is really hard to measure and even long time professionals don't really memorize a lot of the stuff, e.g. method names of specific libraries. You could ask some experienced Java programmers wether the native Array in Java uses .count, .getLength(), .size() or whatever else to return the number of elements and they would probably be stumped for a bit. A good programmer can tell you which datatype to use for some use-cases, e.g. list vs native array and all that, though he might not even know how to spell a specific class name since he will usually use autocomplete for it. As for algorithms, you learn a lot of algorithms when becoming a programmer and you will find out that you actually won't use any of them. Noone programs his sort algorithms from scratch unless he is developing a new language since all languages have their native implementations that work a lot faster and in 99.9% of the cases it doesn't matter what algorithm the .sort() of the native library uses.
It's not the knowledge of the tiny parts that matters, it's knowledge about how to put it all together that defines a good programmer. You know a language good enough when you are able to take a project requirement and turn it into actual, working code.
You need to know the basics, e.g. loops, conditionals, basic datatypes (int,float,double,bool,string,etc.) and then you are done learning specifics, the rest is all about putting it together and checking the reference or google when you need to know how to do a specific thing (you'd be suprised how much even the most experienced programmers use google). For that you might want to look into design patterns that give a small guide into how to put the parts together but the biggest help for that is experience and talent, you can't really learn that part in any school or book.
|
On June 20 2013 01:58 Nausea wrote:You answered me? I got another question on the subject then. Say my program saves the file in it's first run and then the file is only loaded the next times i run the program. How is the program supposed to know what checksum the file had when it was written? Yea sorry, was on phone couldn't type more quickly. Other people have given more detailed hints. The specifics of your implementation will sort of depend on your use case, but saving checksum in the same file is ok if it's just a small thing. Not terribly secure, but it'll work
|
|
|
|
|
|