Jump to content
  • Advertisement

JamesThiago

Member
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

105 Neutral

About JamesThiago

  • Rank
    Member
  1. JamesThiago

    HelpEvaluationFunctionConnect4

    yes, there's a alpha-beta search...If you have time i can show all the files for a better understanding....
  2. JamesThiago

    HelpEvaluationFunctionConnect4

    double test(Game_state *current_state, int player, int x, int y){ int rightmostHeight = 0; int width = current_state->width; int height = current_state->height; /* Loop until we reach the top of the board or an empty square */ while (rightmostHeight < height && (current_state->board[width - 4][rightmostHeight] != C4_NONE)) { rightmostHeight ++; } if((current_state->board[width - 4][rightmostHeight] == C4_NONE)){ while (rightmostHeight < height && (current_state->board[width - 5][rightmostHeight] != C4_NONE)) { rightmostHeight++; } }else if((current_state->board[width - 5][rightmostHeight] == C4_NONE)){ while (rightmostHeight < height && (current_state->board[width - 3][rightmostHeight] != C4_NONE)) { rightmostHeight++; } }else{ rightmostHeight += ((double) rand() / (RAND_MAX / 2) - 1); } return rightmostHeight; } double agent_s3450124(Game_state *current_state, int player, int x, int y){ double score = 0; int is_game_won = game_won(current_state); if (is_game_won == player) score = 1; else if (is_game_won == other(player)) score = -1; else{ score += 0.1 *test(current_state, player, x, y); } return score; } This is my evaluation function(agent_s345012()) at the moment...
  3. JamesThiago

    HelpEvaluationFunctionConnect4

    I have a lot of files...It's a bit hard to explain how all of them work...my work is just create a better agent than those....the other agents are working, but my cannot beat of of them....i need to create a stronger, that's my job...   that's the game, we choose the "players" and mine one is s3450124....so it's the function that needs to return a value between -1 and 1....so, I've posted my current code for my agent, sometimes it doesn't block the simple agent....for example, when i drop a piece in the center, and my opponent drop just above me and i drop in the left or right of my first drop....some strategies like that, I could put to work.  If you wanna see all the files, i can show you to a better understanding... thanks!
  4. JamesThiago

    HelpEvaluationFunctionConnect4

    I did function using alpha beta and my only problem now is my evaluation function....there are 3 agents(evaluation functions that return a double between -1 and 1): double agent_random(Game_state *current_state, int player, int x, int y) { return (double) rand() / (RAND_MAX / 2) - 1; } double agent_simple(Game_state *current_state, int player, int x, int y) { double score = 0; int is_game_won = game_won(current_state); if (is_game_won == player) score = 1; else if (is_game_won == other(player)) score = -1; else { score += 0.5 * agent_random(current_state, player, x, y); /* score += 0.3 * super_cool_heuristic_a(current_state, player, x, y) */ /* score += 0.8 * super_cool_heuristic_b(current_state, player, x, y) */ } return score; } but my main agent is not defeating neither of them...i put to play random against mine and is so so, i put simple against my main and is not good....I know some strategies to win but i cannot put in the code....i just did this: double agent_s3450124(Game_state *current_state, int player, int x, int y){ double score = 0; int is_game_won = game_won(current_state); if (is_game_won == player) score = 1; else if (is_game_won == other(player)) score = -1; else if(y==2)||(y==3)||(y==4) { score = 0.7; } else { score += 0.8 * ((double) rand() / (RAND_MAX / 2) - 1); } return score; }
  5. JamesThiago

    HelpEvaluationFunctionConnect4

    alright....ill change it
  6. JamesThiago

    HelpEvaluationFunctionConnect4

    I was trying to develop this and I got: double evaluate(int player, int level, double alpha, double beta) { int i; double goodness, best, maxab; if (poll_function && next_poll <= clock()) { next_poll += poll_interval; (*poll_function)(); } if (level == depth) return goodness_of(player); else { /* Assume it is the other player's turn. */ best = -(INT_MAX); maxab = alpha; for(i=0; i<size_x; i++) { if (current_state->board[drop_order[i]][size_y-1] != C4_NONE) continue; /* The column is full. */ push_state(); drop_piece(other(player), drop_order[i]); if (current_state->winner == other(player)) goodness = -(goodness_of(player)) + (level - depth) * 0.01; else goodness = evaluate(other(player), level, -beta, -maxab); if (goodness > best) { best = goodness; if (best > maxab) maxab = best; } pop_state(); } /* What's good for the other player is bad for this one. */ return -best; } } is something like that?
  7. JamesThiago

    HelpEvaluationFunctionConnect4

    Thanks Alvaro...I'm working on it right now.
  8. JamesThiago

    HelpEvaluationFunctionConnect4

    I know some tactics of that game, I played a lot, but I don't know how to implement that function to return a value between -1 and 1. Before I played i tried this: #include <stdlib.h> #include "c4.h" double agent_s3450124(Game_state *current_state, int player, int x, int y); double agent_s3450124(Game_state *current_state, int player, int x, int y){ double score = 0; int rightmostHeight = 0; int width = current_state->width; int height = current_state->height; int is_game_won = game_won(current_state); if (is_game_won == player) score = 1; else if (is_game_won == other(player)){ score = -1; }else{ while ((rightmostHeight < height) &&(( current_state->board[width - 1][rightmostHeight]) != C4_NONE)) { rightmostHeight++; } score = 0.2*rightmostHeight; } return score; }  
  9. JamesThiago

    HelpEvaluationFunctionConnect4

    Alvaro, what do u mean about odd/even threat? the columns? 
  10. JamesThiago

    HelpEvaluationFunctionConnect4

    I'm reading Alvaro and now i know the basic fundamentals of this game. But I have no idea about what I need to do, to return a good value in this function. like, if the current position is a good position(for example, there are 3 pieces and you just need to put one more to finish) and the function will return 1. if there is a little bit worse position, you return, for example, 0.9....but I don't know how to calculate this...  
  11. JamesThiago

    HelpEvaluationFunctionConnect4

    I just did the simple code above. I just know the this function will need some maths to return a good value because this function evaluates the current board state and returns a double value between -1 (worst) and 1 (best) indicating how good it is.
  12. JamesThiago

    HelpEvaluationFunctionConnect4

    I don't know how to play properly. I need a first step.
  13. Hi guys, I spent a some days researching a lot about that, but I didn't find anything that really helped me. So, I came to u guys to help me....I have no idea how to start. I just have a really simple evaluation function, i'm doing in C. double agent_random(Game_state *current_state, int player, int x, int y) { return (double) rand() / (RAND_MAX / 2) - 1; } double agent_simple(Game_state *current_state, int player, int x, int y) { double score = 0; int is_game_won = game_won(current_state); if (is_game_won == player) score = 1; else if (is_game_won == other(player)) score = -1; else { score += 0.5 * agent_random(current_state, player, x, y); } return score; } I need ideas to start it...please, help me guys!  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!