0

Hello everyone,

I want to start implementing some of my mathematics knowledge into programming through AI.

Back 3 months ago I had no idea what is AI, but then I took Machine Learning course on Coursera and finally realized how much maths is included in AI.

However I wasn't able to finish the course with good understanding of what is going on in algorithms because I have no idea what are derivates yet, we haven't studied that in school yet ( will do this year ).

Now... before we study that, I would like to get familiar with some simpler algorithms than Neural Networks.
I've heard of genetics algorithm.. minimax...

Could you tell me which algorithm might be the best for start, if we take in consideration that I don't understand derivates yet?

Thank you.

0

Well, I came up with this question because I realized I wouldn't be able to rotate images, which is major problem in dominos game.

I see you have power and health in your UI, seems you're aiming to something more complex, right?

From that experience, would you recommend learning SDL and OpenGL for simpler projects?

Thank you for replying.

1

Hi guys,

I haven't been on daniweb for a while, I've started learning scripting in UDK.

But still I wish to make smaller games using native languages.

So here goes my question: what is the best IDE for programming small games with nice UI?

So far, for programming win apps I have used Borland Builder only, and it doesn't seem as a piece of software that is easy to make nice UI with ( no support for PNG kills me ).

On the other hand, VC++ seems pretty good for that.

My plan is to make a little Dominos game, for PC only.

I am familiar with C++, therefore is VC++ the best choice? Can you tell me more about that?

Thank you and happy New Year to everyone! :D

0

Hi people,

I am making a little experiment to see something. I wished to inherit "string" class and add a function to child class.
Function should take a char as parameter and return bool depending on is there such a character in our string or not.

I have started off with this, but I got stuck with "this":

class MyStringClass:public string{
    public:
    MyStringClass(const char* a):string(a){};
    bool isInString(char);
};

bool MyStringClass::isInString(char s)
{
    for(int i=0;i<=this->length();++i){
        if(s==(*this)[i]) //here
            return true;

    }

    return false;

}

this has type of MyStringClass*?

If so, why can't we access to its elements this way: this[i]?

I assumed so since if we made a pointer like:

int* a=new int;
a[0]=3;

Why wouldn't it work with this too?

MyStringClass* this;
this[0]=something
0

Hi,

Do you have any useful explanation of how to create a draggable window?
What I wish to say is when you select your window will have no border ( considering that, it cannot be dragged around screen), how to make it draggable, for example by making a certain area in window "sensible" so after user presses that area and moves cursor, it moves window too?

I can't remember best, but I think I saw a tutorial on VB about this problem, and he added a panel writing to it some code and making it "sensible" to dragging.

Thank you.

0

Hi,

I need little help with using MediaPlayer from System tab in Borland Builder 6 for C++.
Does anyone know what member function of MediaPlayer returns bool variable which tells us is music currently being played or not?

I have seen solution for this problem where we use Timer which has frequency which equals the length of song that is being played, so as soon as specified time passes, Timer switches to the next song.
But I wish to know is that the only way.

Thank you!

0

Hi,

Is anyone familiar with this problem in BorlandBuilderC++:

void Print(AnsiString Path){
Label1->Caption=Path.c_str();
}
...
Print("C:\Directory1\Directory2\Music.mp3");

When I pass this string to Print(AnsiString) and try to display it in Label1, I lose all '\' signs and text in Label1 looks like this : "C:Directory1Directory2Music.mp3"

Why is this like that?

Thank you!

0

@deceptikon

If the queue is empty, what were you expecting a reference to by calling front() or back()? This is a case of undefined behavior, which is largely why the empty() member function exists.

I was just curious about does original <queue> own any checks for such cases.

@mike_2000_17
Thanks for great explanation!

why don't you just wrap it instead of writing your own queue implementation

I was learning how to create queue following cplusplus.com documentation, and the idea from my first post was just a result of my curiosity.

0

Hi,

There is short explanation of queue at cplusplus.com site which tells that queue should contain front() and back() functions.
As I have tested in VC++, if I use queue from <queue> and call any of these functions for an empty queue, program crashes.

Could this problem be solved by simply adding a throw, in case when queue is actually empty, so front and back would throw an exception which'd be caught by try block?

( of course I am talking about queue, one would create, as I have done)

Here is my simple solution of this problem.

struct Exception{
const char* error;
Exception(const char* a):error(a){};
};

struct elem{
    int data;
    elem* next;
};

class queue{
    elem* head;
    elem* last;
    elem* current;
    int size;

public:
    queue();
    int& front();
    int& back();
    void pop();
    void push(int);
    int Size();
    bool empty();

};
bool queue::empty(){
if(head==NULL)
    return true;
return false;
}
queue::queue(){
head=0;
size=0;
}

void queue::push(int x){
    current=new elem;
    current->data=x;
    current->next=NULL;

    if(head==NULL){
        head=current;
        last=head;
    }
    else if(head!=NULL){
    last->next=current;
    last=current;
    }
}

void queue::pop(){
    if(head!=NULL){current=head;
    head=current->next;
    }
}

int& queue::front(){
    if(head!=NULL)  
    return head->data;
    else throw Exception("Queue is empty.");
}
int& queue::back(){
    if(last!=NULL)      
    return last->data;
    else throw Exception("Queue is empty.");
}

int queue::Size(){
size=0;
current=head;

while(current!=NULL){
size++;
current=current->next;
}

return size;

}

Do you have any critics about this solution, if you do, what is it, and what's your better solution?

Thanks.

0

Maybe you can supply some addtional information. Why are you trying to do this? Are you perhaps thinking of making a game?

I have the game already.. not a regular game, but a Lotto Game, so I am updating it, and I need a shortcut for skipping the generating numbers part ( it can be boring ). I could add a button or something else to provide "Skip" option, but I wish to find more elegant way ( for example pressing ENTER would skip that part ).

Thank you for replying!

0

Hi,

I am learning queues and I have found 2 examples. Both examples represent queues with limited size, for example 30.
But <queue> allows us to create queue that is not limited by *pre-set queue size.

Can anyone explain me how have they created something like that?

Thanks!

*By pre-set I wanted to say that we have set the queue size during its initialization. Like when we create the arrays.

0

Thank you for big reply and book.

So basically when I do this:
typedef int (*pF)(int);
I create new type named pf which creates pointers to functions with int as a parameter and a return type?

It confuses me a bit since this...
typedef short SmallNumber;
...doesn't look very familiar with example for pf, because there is no such thing as
typedef "original" "user-defined"
Where "user-defined" gets attributes from "original", do you understand what is my spot of stumbling?

huh...

Thanks.

0

Hi, I have read this on IBM:

An exception specification may only appear at the end of a function declarator of a function, pointer to function, reference to function, pointer to member function declaration, or pointer to member function definition. An exception specification cannot appear in a typedef declaration. The following declarations demonstrate this:

Can anyone write me an example of reference to function (so it contains exception specification with it)?

And another question about syntax I can't understand. What does this mean:

void h(void i() throw(int));

Thanks.

0

Hi,

I have read something on IBM's site about exception specification and pointers to functions:

void (*f)();
void (*g)();
void (*h)() throw (int);

void i() {
f = h;
//   h = g;  This is an error.
}

IBM says:

The compiler allows the assignment f = h because f can throw any kind of exception. The compiler would not allow the assignment h = g because h can only throw objects of type int, while g can throw any kind of exception.

But I tested the code in VC++, DEVC++ and CodeBlocks, no error anywhere.

Any explanations?

Thanks.

0

Hi,

I have been playing around with pointers and made a little mistake of this type:

class D{
      public:
             int a;
             };

int main()
{

    D *x;        //As you can see I didn't allocate memory at all...
    x->a=3;      // ... but initialized a member variable 
    cout<<x->a<<endl;

    return EXIT_SUCCESS;
}

I get run-time error if compiled in DEVC++.

But I tried the same in Code::Blocks, and it works, as if I regularly allocated memory before initializing... hm... what?

Can anyone explain me this behaviour, I know some rules differ from compiler to compiler, but what's the matter with this one?

Thanks!

0

Hi,

I've been searching around about DLLs and I can't get what they actually are.
Why do we need .cpp, .h and .dll file and how do we link it using CodeBlocks?
I used tutorials to create DLL files, and it was successful, they contained 2 functions, but linking is the problem.
If anyone could explain me this process or even theoretical part of linking DLL files.

If I could manage to create a DLL and call it in simple hello world program, I think I will understand it much better.

Thanks!

0

Hi,

I have recently finished first game in C++ which has huge code which will be fixed in future who knows how many times.
It is really not practical to publish entire .exe launcher as fix, but I heard that it isn't case with DLL files.
I could simply create DLL with my functions and if I fix some, I publish only DLL ( it's more elegant too ).

My question is: what kind of knowledge in C++ should I have, so I can be able to create simple DLL...simple as it contains only one function ( for start )?

I know basics of OOP, generic programming... is that enough?

And is there any tutorial about making DLLs using DEVC++ or BorlandBuilder?

Thanks!

0

That syntax is the initialization list.

The initialization list is for all sub-objects (which includes both base-class instances and data members) of an object. It is simply a comma-separated list of constructor calls for each base-class instance and data member belonging to a class. In your specific example, value is a data member of the general class template A and it is constructed with value i.

Thanks, helped!

0

Hi,

I found the examples of explicit specialization, but I have a vagueness about code:

using namespace std;

template<class T = float, int i = 5> class A
{
   public:
      A();
      int value;
};

template<> class A<> { public: A(); };
template<> class A<double, 10> { public: A(); };

template<class T, int i> A<T, i>::A() : value(i) {
   cout << "Primary template, "
        << "non-type argument is " << value << endl;
}

A<>::A() {
   cout << "Explicit specialization "
        << "default arguments" << endl;
}

A<double, 10>::A() {
   cout << "Explicit specialization "
        << "<double, 10>" << endl;
}

int main() {
   A<int,6> x;
   A<> y;
   A<double, 10> z;
}

What does this line of code do?

template<class T, int i> A<T, i>::A() : value(i)

My assumption is that we are creating general definition for A().
But what baffles me is the syntax of

A():value(i)

I remember of this from inheritance tutorial where we can specify which constructor of base class will be called together with constructor of derived class.

Can anyone explain me how does this work?

Thanks!

0

Hi,

I have made some sorting function based on finding largest element and swapping its place with last element of array and then searching largest element of rest of array and putting it on one place before last one and so on.

I am curious about is there a name for sorting of this type?
I searched [URL="