spuriousgeek 48 Newbie Poster

I've tried using co-pilot, codeium, claude, chatgpt and gemini. They are good for repetitive work but anything remotely complex and they are pretty terrible tbh. I find that it's quicker for me to just solve issues on my own a lot of the time than try to prompt my way through. You can very easily fall into the trap of going around in circles trying to get the answer you need with various prompts, instead of spending the time using existing knowledge to resolve it yourself quicker. That's just my personal experience but I've been a developer for a number of years now. Writing unit tests is the only place where I've found genuine value so far.

Dani commented: Thank you :) +34
spuriousgeek 48 Newbie Poster

I have been plagued by an issue for the past couple of days and I am yet to find a solution. I have an service installed at several customer sites. This service grabs data from a database, packages it up and then submits it to a web service hosted on a different server. This is done using SOAP and everything works absolutely fine when I am running the submission service under .NET 2.

However, after a recent upgrade to .NET 4, I have been receiving a SoapException when my submission service attempts to logon to the web service. The error I get is: "SoapException: Unexpected error occurred when attempting to authenticate user with the LDAP repository".

The credentials have remained unchanged and I have confirmed that they are not the cause. The strange thing is, the latest version of the submission service works at some customer sites but not at others. The environments on which the service is installed vary greatly so it seems unlikely to be a platform specific issue.

I've got to the point where I am pretty much guessing at things that might be causing this problem e.g. have there been any subtle changes in the way the .NET framework handles SOAP requests between .NET 2 and .NET 4.

I haven't really supplied a whole lot of information but since I am not really too sure what people would want to know about this issue, it is probably easier if you just ask me lots of questions.

spuriousgeek 48 Newbie Poster

Hmm, well my previous code suggestion would still work then would it not?
If -1 effectively means that a particular direction does not lead to another room, then we can assume that when -1 is returned from getNorth(), getEast() etc, the player has attempted to go in a direction that does not lead to another room. Therefore, when -1 is returned, we should display a message that tells the player that they cannot go that way.

My previous code snippet does the following:
* First, the user input is checked so that we know which direction the player wants to travel in.
* Next, we check whether the chosen direction of travel leads to another room.
* If the choice does lead to another room (not -1) then the player's position is updated.
* If the choice does not lead to another room (-1), then a message is displayed to inform the user of this.

Let me know if I've still not answered your question :)

spuriousgeek 48 Newbie Poster

Ah ok so there is already a planned route that you should be taking. So I presume then that returning -1 from your getNorth(), getSouth() etc. functions, signifies that the player is trying to go somewhere that is not part of the pre-defined route?
If my assumption is correct, then you could simply change your exising 'if' statements to something like:

if(choice == 'n')
{
    if(testRooms[playerPos].getNorth() == -1)
    {
        cout << "You cannot go north!" << endln;
    }
    else
    {
        playerPos = testRooms[playerPos].getNorth();
    }
}
spuriousgeek 48 Newbie Poster

I am struggling to make sense of what you have written. To clarify, are you asking how you would prevent the player from going north, for example, if the current room has no north exit?
If this is the case then you could do something like:

if((choice == 'n') && (testRooms[playerPos].getNorth() != -1) && 
(testRooms[playerPos].hasNorthExit()))
{
    playerPos = testRooms[playerPos].getNorth();
}

This code obviously relies upon the existence of a 'hasNorthExit' method which would return a bool value that is true when a room has a north exit. Hope this helped!

spuriousgeek 48 Newbie Poster

WiX is very useful for creating an installer, is highly customisable and has plenty of online documentation.
http://wixtoolset.org/

spuriousgeek 48 Newbie Poster

If you have used both static methods and objects before then I am suprised that you do not see why people use objects so frequently. Objects make it easier to understand and also maintain code. Imagine if you wanted to store some data about a person and decided that you would only make use of static methods. You would have to have some way of coordinating the use of the methods so you know which name, age, address etc. belongs to which 'person'. This would likely result in very messy code that would quickly become difficult to maintain.

Objects provide the opportunity to group data and functionality so that code is easier to understand and use. Storing a collection of person objects is much more straight-forward than creating lots of static functions that attempt to group related data for the same purpose.

ddanbe commented: Very good simple explanation! +14
spuriousgeek 48 Newbie Poster

It looks like your tutor/lecturer/teacher/mentor is trying to get you to look into operator overloading. Here is a nice starting point: http://msdn.microsoft.com/en-gb/library/5tk49fh2(v=vs.80).aspx

In particular it reads as though you should be aiming to overload '++' and '--' intially and then move on to the relational and stream operators. Once they are overloaded you should be able to achieve something like the following:

dateType myDateTypeInstance;
myDateTypeInstance++; // Increment the 'day' value
myDateTypeInstance--; // Decrement the 'day' value

Since you haven't asked for help with anything in particular I can't really offer any specific advice (DaniWeb encourages people to do their own homework/assignments etc. - its the only way you will learn!). Once you have attempted to wrap your head around the concept of operator overloading I will be more than happy to clarify anything that you may be struggling to understand. If you think that you understand but still can't make much progress with your code then post any attempts that you've made to solve the problem and I'm sure I can point you in the right direction :)

spuriousgeek 48 Newbie Poster

I would like to mention a couple of things akashi:
1) When programming you really need to pay close attention to code that you are reading or writing -- The updated code that you have provided shows a new struct that can be used to represent a date, however, your Toy struct still doesn't contain a data member.

It should look more like:

struct Toy
{
string toyName;
double price;
string madeIn;
Date date;
};

2) If you are struggling to figure out how to write something in code it can very often be helpful to write down a solution in pseudo-code or plain English first and then convert to code after.

Finally, just in case you weren't already aware, DaniWeb isn't a place you should come to get someone else to do your work for you - You will never learn this way!
Instead, the forumns provide a way for you to get assistance when you are having problems or to get new ideas that may further your development skills.

Edit:
Once you have made an attempt at the validation, please post the code that you have produced yourself so that we can help you to resolve any issues.

spuriousgeek 48 Newbie Poster

I hate to reiterate what Nathan already said but....what exactly are you stuck on?
Its hard to help you if you don't specify the problem.

Having said that I should point out that the above code already has mistakes -- did you know this?
e.g. line 16 should actually be:
cout<<"Name of Toy:"<<to.toyName<<endl; -- toyname is not a member of your struct but toyName is

In main you also call display() when in fact you should be calling Display() (unless you rename your function).

Also, if you read the requirements that you posted you will notice that the manufacture date should be a struct, hence your toy struct should contain another struct instead of the three ints that you are currently using.

For example:

struct Toy
{
    string toyName;
    double price;
    string madeIn;
    Date date;
};

Where Date is defined as:

struct Date
{
    int day;
    int month;
    int year;
};

Finally, you don't appear to have any validation at present is this what you need help with?

spuriousgeek 48 Newbie Poster

I've just done some testing within my application and I have to say the performance has been improved significantly :)
For now I will mark this thread as solved, however if you think of any further optimisations then please feel free to pm me.

spuriousgeek 48 Newbie Poster

Well the performance timings definitely seem promising. I will look into implementing this and get back to you when I've had chance to get it done.

spuriousgeek 48 Newbie Poster

I should probably mention that I don't mind suggestions on data structure alterations etc. if it improves performance. For example, if you have a more efficient implementation for a PriorityQueue then I would like to see it :) -- Calls to dequeue in my implementation are slightly more costly than I would like

spuriousgeek 48 Newbie Poster

A* algorithm:

using System.Collections.Generic;

namespace Route
{
    public delegate float HeuristicDelegate(NavigationNode node, NavigationNode goalNode);
    public delegate float EdgeCostDelegate(GraphEdge edge);

    public class RouteFinder
    {
        public bool ComputePath(NavigationNode startNode, NavigationNode goalNode,
                                ref List<NavigationNode> outPath, HeuristicDelegate heuristic, EdgeCostDelegate costFunc)

        {
            // Create a priority queue to store the open list of nodes
            var openList = new PriorityQueue<float, NavigationNode>();

            // Put the start node in the open list
            startNode.Cost = 0.0f;
            startNode.EstimatedCostToGoal = heuristic(startNode, goalNode);
            openList.Enqueue(startNode.EstimatedCostToGoal, startNode);

            NavigationNode currentNode = startNode;

            // While the open list isn't empty
            while (!openList.IsEmpty)
            {
                // Get the smallest element in the open list
                currentNode = openList.Dequeue();

                // If the current node is the goal node then terminate
                if(currentNode.Equals(goalNode))
                {
                    break;
                }

                // Get all potential successor nodes via edges
                var edges = currentNode.Edges;
                foreach(var edge in edges)
                {
                    var neighbour = (NavigationNode)edge.Head;

                    // Set the cost of the successor to be the cost of the current node
                    // plus the cost to get to the successor node from the current node
                    var fEdgeCost = costFunc(edge);
                    var fNeighbourCost = currentNode.Cost + fEdgeCost;

                    switch (neighbour.State)
                    {
                        // If the successor is in the closed list but the current node is as good
                        // as, or better, then discard the successor and continue
                        case NodeState.closed:
                            if (neighbour.Cost <= fNeighbourCost)   // Skip if no shorter route is found
                            {
                                continue;
                            }
                            // Else, remove the node from the closed list
                            neighbour.State = NodeState.other;
                            break;
                        case NodeState.open:
                            if (neighbour.Cost <= fNeighbourCost)   // Skip if no shorter route is found
                            {
                                //continue; …
spuriousgeek 48 Newbie Poster

Hi Everyone,

Background:
I have recently implemented the A* pathfinding algorithm in C# based on some pseudo code that I found.
I need the algorithm to run as fast as possible and at present my code isn't quite cutting it. I understand that the heuristics used can have a big impact on the performance of the algorithm, however, I have gotten to the point where I feel that the only way that I can make further gains is to optimise the algorithm itself.

Reason:
The reason why I need the algorithm to be so fast is so that I can 'instantly' determine a decent estimate for the time it would take to travel between two points.

Further Info:
So far I have tried using a hierarchical graph structure to allow at least a partial path to be returned immediately -- The problem with this approach is that I don't actually need path data immediately, I simply need the path to be computed in order to get the time estimate.

I have also considered making the pathfind function unsafe in order to improve performance but I'm not really sure how this would work -- I can't create node pointers because they are "non-unmanaged" types.

This is essentially the first time where I've had to write performance critical code in C# (usually I'm working in C++) so I'm not sure what I could do to really squeeze those gains. If anyone has any ideas then I would greatly …