C++ :: Logic Error - Maze Not Displaying

Jan 24, 2014

So I have a program where I solve a maze using stacks. So my display_maze function take two parameters and displays the maze according to where the x coordinate and y coordinate are.

I have an error during my move function, as my maze doesn't display for some reason

void Player::player_move() {
Stack stack;
Maze maze;
Lock taken;
// Monster monster;

stack.push_values();

[Code] ....

It should be displaying, because after debugging I discovered the problem isn't with the display_maze function.

View 1 Replies


ADVERTISEMENT

C++ :: Cannot Seem To Find Logic Error In Perceptron

Jan 28, 2014

I can't seem to find the logic error in my perceptron. The perceptron's feedback function pushes back a bias of 1.0 into the input vector, and calculates the dot product of the input vector and it's weight vector, and returns 1 if the dot product is > 0, and -1 otherwise. This will determine whether the inputted point is above or below the hyperplane given by the functor.

The training function instantiates a trainer object , which feeds it a vector random numbers, along with the correct answer (in this case, whether the point is above or below the hyperplane given by a functor). It then calls the feedback function, and subtracts its answer from the correct answer, and updates the weights by adding the input vector to the weight vector, and multiplying the weight vector by the error, and by a correction factor, in this case 0.01.

Typedef.hpp

Code:
#ifndef TYPEDEF_HPP
#define TYPEDEF_HPP
#include <vector>
#include <random>
typedef std::vector<float> FloatV;
typedef std::random_device RNG;
typedef std::uniform_int_distribution<> UID;

[Code] ....

View 14 Replies View Related

C++ :: Mystic Logic Error In Double For Loop

Aug 16, 2014

In a record I have IDs of type int but some may repeat. These IDs also got sales of type float. I wish to compare the IDs number of times they appear and of match found accumulate their sales and put it in another struct. However if an ID is found which is new I pass it to a function to initiate sales..but my code never reach second ID, given I am trying with two IDs.. given IDs in transFile

ID Sale

12345 870
90909 100

I enter these two in transFile and match it with masterRecord. 12345 is matched and updated likewise but 90909 is never executed or matched in checkID function..

void sync_trans_files(unsigned short int count, master masterRecord[], char transFile[]){
const short int weeklyemployee=25;
//read number of records from transFile;
struct trans{

[Code].....

View 8 Replies View Related

C/C++ :: Simple Logic Error While Writing To XML File

Sep 15, 2014

I created a program to convert files to XML. This if statement is giving me some trouble. I am trying to replace all &s with the XML & so that &s will work in the entities of the XML file. Some entities have more than 1 &. With those which have more than one I get an output like this: <cit:district>Anambra & Enugu & Eb</cit:district> .

if(word.find("&") != string::npos) {
word.replace(word.find("&"), 1, "&");
}

View 2 Replies View Related

C++ ::  Adding New Item To Vectors Received As Parameter - Logic Error

Mar 14, 2014

I once again have a logic error. This time I am positively baffled: I am making a function that messes with three vectors it receives as parameters. The function adds new items to those vectors, but the funny thing is, while it completely normally adds items to two of the three, it fails to do so for the first, despite the fact that I use the same template! Here the function is:

void giveReward( Character player, vector<string>& spells, vector<string>& weapons, vector<string>& armor ) {
int reward, rewardGen;
srand( time( 0 ) );
reward = rand() % 3 + 1;

[Code] ....

View 10 Replies View Related

C :: Error Displaying All Info Entered By User

Mar 4, 2013

Code:

#include<stdio.h>
main() {
int item_code, quantity;
char ans, y;

[Code] ....

View 4 Replies View Related

C/C++ :: Right Hand Maze Not Working Properly

Nov 1, 2014

I am creating a right hand maze solution, and it actually works for the most part, but it gets stuck at the sixth spot and will not proceed any further. I cannot seem to find my error even though I know it's probably a small one in my code, here is what I have at the moment:

#include "stdafx.h"
#include <iostream>
#include <Windows.h>

[Code].....

View 6 Replies View Related

C/C++ :: Maze Solver Is Not Backtracking Correctly?

Mar 15, 2014

I'm working on a homework problem where we are given a class of functions to traverse a maze and must use those functions to recursively find the end.

The problem I'm having is when the function backtracks it doesn't reset the whole path it came from.

Here is my function that I have created

void solveMaze(Maze M, int path[][MAX])
{
// << overwritten to print the maze out
cout<<M;

[Code].....

View 7 Replies View Related

C/C++ :: How To Make Object Move In A Maze

Apr 29, 2013

What c++ code can be used to make an 'X' move through a maze. I have some code, but I'm not sure where to go from there. I have divided the program into three files, A header file, a main file and a .cpp implementation file.

In my implementation file I have:

#include "Maze.h"  
Maze::Maze() {  
} void Maze::mazeTraversal(char maze[][COLS], int row, int col, int direction) {
    enum Direction {DOWN, RIGHT, UP, LEFT};  
    switch(option)

[Code] ....

View 1 Replies View Related

C++ :: Find Area Of Room In A Given Square Maze

Apr 1, 2013

Area of the room. Your task is to write a program that will find the area of room in a given square maze.

Note. Use recursion for solving this problem.

Input:
First line contains only one number N (3 <= N <= 10).The number that describes the size of the square maze.
On the next N lines maze itself is inputed ('.' - empty cell,'*' - wall).
And the last line contains two numbers - the row and column of the cell in the room those area you need to find.It is guaranteed that given cell is empty and that the maze is surrounded by walls on all sides.

Output:
Output only one number - total amount of empty cells in the selected room.

View 8 Replies View Related

C/C++ :: Word Maze - Find String In Vector

Mar 4, 2015

This program is to solve a word maze and find the number of words in the maze from a dictionary file.

The program runs, but stops by finding 1,2 and 3 letter words.

#include<iostream>
#include<vector>
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
vector <string> dict,forward,reverse;

[Code] .....

I also tried to find words using the entire vector as a container, the synopsis code that also did not work is below

while(j<dict.size()) {
if(dict[j].size()>2) {
if (std::find(forward.begin(), forward.end(), dict[j]) != forward.end()) {
cout<<"found word "<<dict[j]<<endl;

[Code] ....

Attached File(s)

dumpling2.txt (2.54K)

Dictionary.txt (718.34K)

View 13 Replies View Related

C++ :: Shortest Path Maze Solver Algorithm

Mar 26, 2014

I'm working on a maze solving program. So far I got the program to solve a maze using the recursive backtracking algorithm. I represent the maze as vector<vector<Square>> where Square is an enum that contains the kind of square (empty, wall, etc.). I use a class Point that contains 2 ints which are used for subscripting the vector of vectors. I have a Point begin and Point end. Now I want the program to solve the maze using the shortest path. I can either use the A* algorithm, Dijkstra's algorithm, or the breadth first search algorithm.

View 6 Replies View Related

C++ :: Simple Recursive Maze Algorithm And Counting Steps

Jun 1, 2013

My maze algorithm must be able to count total steps. He is not allowed to "jump" from a deadend back to the cross-way he originally came from.

Code:
int R2D2Turbo::findIt(Labyrinth* incLab, int x, int y){
if ((x == incLab->getExit().x) && (y == incLab->getExit().y))
{
return 1;

[Code] .....

Due to the nature of recursive algoirthms, he jumps instead of moving the way back from the deadend one by one... The only solutions I could think of are way overloaded...

View 3 Replies View Related

C++ :: How To Move A Ghost In PacMan Game Randomly Around The Maze

Oct 1, 2014

I have tried rand() for x and y positions of ghost but does not work. it moves but not randomly it follows same path every time I run the code.

View 2 Replies View Related

C/C++ :: Reading From File To Construct A Pointer Based Maze?

Nov 29, 2014

I'm trying to read a "pointer-based" maze .txt. The first letter in each row corresponds to the room letter...then the letters that follow are North node, East node, South node, and West node respectively. The asterisk indicates an empty room or not a valid option.

Here is what I have come up with, what is happening is after the file is parsed by read_maze it is calling my is_empty function indicating that there is no maze because it doesn't go into the else statement here.

I've attached a sample input file:

 maze.txt (130bytes)
Number of downloads: 19

We can't assume the rooms will be in order alphabetically A - Z, We are expecting a maximum of 12 rooms and there is a space between each letter or asterisk.

void Maze::read_maze(string FileName){

string line;
ifstream inStream;
inStream.open(FileName.c_str());
int test = inStream.peek();
int i = 0;
if (!(inStream.fail())){
while (!inStream.eof() && test != EOF){

[code]....

View 5 Replies View Related

Visual C++ :: Can't Make Maze Work Correctly With Arrays

Apr 30, 2014

I have to make a maze with arrays, but i cant seem to move down or up or at all. Here is what I have so far

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

[Code].....

View 5 Replies View Related

C# :: Logic For Building Numbers Pyramid?

Jan 7, 2012

Code:
1
121
12321
1234321
123454321 EDIT:
the above pyramid looks like a doom.i.e 1-5 will be in center.1-4(L)1-3(L)1-2(L)1(L) similarly 1-4(R) 1-3(R) 1-2(R) 1(R)

I'm partly successful in building the requirement of the program.but cant able to think the logic for the other half. how can i proceed.below is the code written in c#.

Code:
for (int i = 1; i <= 5; i++)
{
//int l = 1;

[Code]....

View 3 Replies View Related

C++ :: Logic - Writing Input To TXT File

Oct 30, 2014

So I'm trying to take some information that a user inputs and to then write it into a .txt file. The user would input a student ID followed by 4 quiz grades. I need to use nested loops for the input, a while loop for the outer and a for loop for the inner.

The data in the .txt should would look like:
studentID quiz1 quiz2 quiz3 quiz4
studentID quiz1 quiz2 quiz3 quiz4
etc.

My problem is I'm not sure how to structure the code. I have very few examples I'm working with to understand what I'm working with.

View 2 Replies View Related

C++ :: Function Keys (F1-F12) Encountered A Logic Bug

Feb 27, 2014

I was developing an exercise program for myself (note: not a project in school) to enhance my programming skills in C++ then I encountered a "logic bug" (that's how I call it :D ) I think. I googled stuffs I need to know and ended up to post my question here.

Here's the scene:

1. When using GetAsyncKeyState I can capture Function Keys [F1-F12, etc..]

2. While doing and having fun to my exercise program, I suddenly noticed that whatever key I pressed from the keyboard {example: asdfkj], it keeps the keys entered and brings to a "field" that accepts user input.

What you should do...

1. Press any key (example: asdfisdjfisdjff) then proceed to press F1. And see what happens. I don't know how to erase what I have entered before pressing F1.

here's the code.

#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
void gotoxy();
void gotoxy( int column, int line ) {

[code]....

View 5 Replies View Related

C++ :: Combinational Logic Simulation Using QThreads

Oct 30, 2013

I'm trying to create program that reads in commands from an input file, and accordingly creates, connects or destroys logic gate primitives (and gates, or gates). Additionally, I'm trying to modify a previous program that I wrote to do this using QThreads, where each gate is placed in its own QThread. I'm trying to avoid using invokemethod, and I'm sure this method can work. My specific issue that I'm having trouble debugging is in my connect code block in main.cpp. Whenever I try to reference a gate specified by the input file that is NOT the true or false gate (I have one of each and they are attached to any gate that needs a true or false input), I get only a NULL reference. This includes attempting to reference the gate in my gatelist QMap. Calling gatelist.value(newCommand.at(1)) causes the program to hang, and the connect statements referencing said gate return errors about connecting a signal or slot of a NULL pointer.

Here is main.cpp:
#include <QPointer>
#include <QMap>
#include <QDebug>
#include <QString>
#include <QFile>
#include <QTextStream>

[Code] ...

My accompanying class declarations can be found here : [URL] ....

View 6 Replies View Related

C++ :: Bool Logic For Date Validation

Sep 17, 2013

My issue is regardless of which date I input its always defaulting to the values I have set in my constructor in my implementation file in the else statement. So the values always default to 3/15/2006 I think its something to do with the logic in my bool function but I may be incorrect.

header
//date.h header
#include <iostream>
#include <string>
using namespace std;

enum DateFormat {numeric, standard, alternative};
const int MIN_YEAR = 1900;
const int MAX_YEAR = 2015;

[Code] ....

View 4 Replies View Related

C/C++ :: Dictionary Logic - Searching For More Words?

Nov 18, 2014

I need to create code based upon the following pseudo code:

dictionary=vector
file containing words to search for=external file

While there more words to search, for search the dictionary if the entire dictionary is searched and the word is not found, return the word, search the dictionary for the next element (and so on)

I cannot for the life of me figure out the sequence of loops to do this. The following code returns all of the words instead of just the ones not found in the dictionary, but it's all I've got after countless changes:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
int main() {
string dictword;
ifstream dictionary;

[Code] ....

And it returns every word in the external file.

View 1 Replies View Related

C :: Logic To Find Least Common Number Combination

Nov 22, 2013

I have been struggling with this program. I am somewhat new to c and suck at logic. I have a personal program I want to make that I will try to get extra credit for in school. I have a printed set of winning lottery numbers form the last 10 years. I chose the easiest one do do logically which is just 5 numbers none repeating.

I am trying to find out how I can print the least common 10 sets. I think if there are any set which have not been picked I would have to print all of those because logically they would all be equal, then print sequentially the sets least picked up to 10.

I have pseudocode which I am sure is wrong but will post it just to show that I am trying. My first attempt was to add the numbers but quickly realized that that wouldn't work ...

5 Nums Pseudocode
Code:
Read Nums
Parse Into Ints
Make Array [185] //39+38+37+36+35 The highest the numbers added together can go

//LOGIC

[Code] ....

View 5 Replies View Related

C :: Cleaning Up Logic On Linked List Deletion

Jan 14, 2015

I have a doubly linked list from which I need to occasionally delete elements (any elements that have a type value different from 0). The function I have seems to work, but looking at it, I think I could probably make the logic cleaner.

The structs in questions are declared here, with irrelevent variabled omitted:

Code:

struct Event {
//...
int type;
//...
struct Event *next;
struct Event *prev;

[code]....

View 7 Replies View Related

C Sharp :: ForEach Loop Logic Using KeyValuePairs

Jun 3, 2013

I'm new to C#. I'm trying to create a program to audit some of our processors. As you will see below, I have two foreach loops that allow me access to errorOrders(returns <<UserName, #of errors>>) and totalOrders (returns <<UserName, #of totalOrders>>).

However, the problem i'm running into now is that it seems to constantly loop through these two ForEach loops. When i run it, the 'count' on both errorOrders & totalOrders is 38. The program loops through all 38 users just fine, but then it continues to loop through users again...re-doing the process that it just finished.

I'm looking to see if there is another way I could set this section up so that it only loops through users once. I was thinking about trying to create a 'Boolean flag' that would force the program out of the ForEach loop after it has run through all the users...but i'm sure there are other ways to handle this.

foreach (KeyValuePair<string, int> error in errorOrders)
{
foreach (KeyValuePair<string, int> total in totalOrders)
{  

[Code]....

I know i should probably seperate these two foreach loops instead of having them nested..however, the problem that arises once i do that is my errPercentage can not be calculated if i do.

View 1 Replies View Related

C++ :: Read In A Maze File To Move Smiley Face Around In - Stuck On A For Loop Entry

Mar 7, 2013

I am trying to get this code eventually to read in a maze file to move the smiley face around in. But right now my current snag is the yes or no to enter the for loop.

#include <iostream>
#include <windows.h>
#include <conio.h>
#include <time.h>
using namespace std;
int main() {
int name;
char ans;

[Code] .....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved