Click here to Skip to main content
15,886,815 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i was trying to run my code but error come out
class Board:public State(){

private:
    vector<int>blocks;

public:
    void generateIntlState() {
        int bIndex = 0;
        intializeBlocks();

    for(int r = 0; r < BOARDSIZE; r++){
        for(int c = 0; c < BOARDSIZE; c++){
            setVal(r,c blocks[bIndex]);
            bIndex ++;
        }
    }
    pushBlockDown();
    }



    void intializeBlocks(){
    int zeroCount = 1;

    for (int i = 1; i < 9; i ++){
        blocks.push_back(i);
        if(zeroCount<=3){
            blocks.push_back(0);
            }
            zeroCount++;
        }
    for( int i = 8; i > 0; i--){
        int num=rand()% i;
        int temp = blocks[i];
        blocks[i] = blocks[num];
        blocks[num] = temp;
        }
}

    void findActHeuristic(priority_queue<Action>&actions, Goal g){
    Action a;
    vector<Action>actions_vec;
    vector<State> states;
    int h = 0;

    for(int r = 0; r < BOARDSIZE; r++){
        for(int c = 0; c < BOARDSIZE; c++){
          if((r != c)&&(isFull(r))&&(isEmptu(c))){
            a.setAction(r,c);
            actions_vec.push_back(a);
            }
        }
    }
    for(int i = 0; i <actions_vec.size(); i++){
        State newState = nextState(actions_vec[i]);
        states.push_back(newState);
        if(newState.getVal(g.getRow(),g.getColumn()) == g.getVal()){
            h = 100;
        }else if(newState.isOnTop(g.getVal())&&(newState.isColumnEmpty(g.getColumn()))){
            h = 95;
        }else if(newState.isOnTop(g.getVal())&&(newState.isBlockEmpty(g.getColumn()))){
            h = 85;
        }else if(newState.isBlockEmpty(g.getRow(),g.getColumn())){
            h = 65;
        }else if(newState.isColumnEmpty(g.getColumn()))&&(getRowPos(g.getVal()) > g.getRow()){
            h = 55;
        }else if(newState.isColumnEmpty(g.getColumn())){
            h = 50;
        }else if(newState.isOnTop(ggetVal())){
            h = 40;
        }else if(newState.isColumnFull(g.getColumn())){
            h = 1;
        }else{
            h = 5;
        }
        actions_vec[i].setHeuristic(h);
        actions.push(actions_vec[i]);
    }


    template<typename T>void priority_queueQ(priority_queue<T>q){
    while(!q.empty()){
        q.top().printGoal();
        q.pop();
        }
        cout << endl;
        }
    }
};

And if i delete () and more error come out

What I have tried:

This it's the error:
error: expected class-name before '(' token|
error: expected '{' before '(' token|
error: expected unqualified-id before ')' token|
Posted
Updated 16-Apr-20 4:10am
Comments
Richard Deeming 16-Apr-20 10:09am    
Four almost-identical questions in two days. I think you need to go back and re-read your class notes.
CHill60 16-Apr-20 10:28am    
And just for the record, you are nowhere near being able to "run" your program, it won't even compile.

Ok let me see where do I start.

C++
class Board:public State(){


should be

C++
class Board:public State{


For loop

C++
setVal(r, c blocks[bIndex]);


should be either

C++
setVal(r, c, blocks[bIndex]);


or remove "c" token.

I assume that the majority of functions declared in the State class? Because if they're not, this is yet another problem.

And I am assuming that you have following line visible to your code:

C++
#include <vector>
#include <queue>

using namespace std;
 
Share this answer
 
v3
Comments
Effendy Hendra 16-Apr-20 10:10am    
Yeah if i delete it's gonna be more error
steveb 17-Apr-20 12:38pm    
Spend a few weeks reading beginners c++ book to get an idea about strict syntax rules. At current junction you are obviously in over your head
How many times are you going to ask the same question until you learn to fix this yourself?
Why my code not working ?[^]
Why my code not working ?[^]
Can you help me to fix my code ?[^]
If you had done what you were told to the first time you posted this (and the second, and the third), you could have solved this yesterday.

You are not going to learn to fix compiler errors by desperately hoping others will fix them for you ... and you are going to have many, many more of them in future - we all do - so learnign to fix them yourself is kinda important if you want to advance beyond one line of correctly-compiling code per week.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900