Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to implement alpha-beta pruning (tic tac toe)

how to implement alpha-beta pruning (tic tac toe)

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialalgorithmsbeta-testing
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cristianpff
    wrote on last edited by
    #1

    hello everyone, i made a tic tac toe in C language, using the minimax algorithm but i have some problem when i try to play with larger matrix more than 3x3 for example 4x4 and my program go out of memory. So i search in the net and i discover the aplpha-beta pruning that reduce the computional coast and so i can play with 4x4 matrix whiteout problems but i have not idea to implement this algorithm to my minimax. if there is a person who want to help me i would be grateful. sorry for my bad english but i am italian :(( i can post my code if you want

    CPalliniC 1 Reply Last reply
    0
    • C cristianpff

      hello everyone, i made a tic tac toe in C language, using the minimax algorithm but i have some problem when i try to play with larger matrix more than 3x3 for example 4x4 and my program go out of memory. So i search in the net and i discover the aplpha-beta pruning that reduce the computional coast and so i can play with 4x4 matrix whiteout problems but i have not idea to implement this algorithm to my minimax. if there is a person who want to help me i would be grateful. sorry for my bad english but i am italian :(( i can post my code if you want

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      You could start (if you haven't already done) with the Wikipedia's article on the subject: Alpha–beta pruning[^].

      In testa che avete, signor di Ceprano?

      C 1 Reply Last reply
      0
      • CPalliniC CPallini

        You could start (if you haven't already done) with the Wikipedia's article on the subject: Alpha–beta pruning[^].

        C Offline
        C Offline
        cristianpff
        wrote on last edited by
        #3

        hi, i read the article on wikipedia and i understand it but the problem is that i don't know how to implement it to my minimax :(( here is my minimax if want to give me an idea .. ;)

        int miniMax(char wnr, int deep)//Minimax
        {
        if (controlloVincita(2))//control win
        return INT_MAX;
        if (endgame())
        return INT_MIN;
        int i, j, res, tmp;

        if (wnr == 1)//se giocatore massimizzante
        {
        	res = 1;
        	for (i = 0;ires || (tmp == INT\_MAX))
        					res = tmp;
        				BOARD\[i\]\[j\] = 0;
        			}
        		}
        }
        return res;
        

        }

        int get_next_move(unsigned int *i, unsigned int *j)
        {
        int max = INT_MIN, mi = 1, mj = 1, t;
        int alfa = INT_MIN, beta = INT_MAX;
        for (*i = 0;*imax)//
        {
        max = t;
        mi = *i;
        mj = *j;
        }
        BOARD[*i][*j] = 0;
        }

        BOARD\[mi\]\[mj\] = 2;//save the computer move
        \*i = mi;
        \*j = mj;
        return 1;
        

        }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups