rookie0Ken's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
14 (0.02 per day)
Joined:
06-August 12
Profile Views:
2,097
Last Active:
User is offline Mar 28 2013 05:22 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Subaru
Dream Kudos:
0
Icon   rookie0Ken has not set their status

Posts I've Made

  1. In Topic: thrown exception in a recursive method

    Posted 22 Oct 2012

    thanks
  2. In Topic: Tic Tac Toe

    Posted 19 Sep 2012

    ooh silly me i see how you use the IsWin method to check for a winning move and using a dummy move.Thats pretty good, very little code, very efficient.

    Thanks alot guys, if i had guys like you to mentor and tutor me, i cant see any reason why i cant be the best.

    Thanks alot again.
  3. In Topic: Tic Tac Toe

    Posted 19 Sep 2012

    in my edited code i changed the methods that are taking row and col as arguments to take just a number (from 1 to 9) being the cell location one being the top right most cell.
    sorry for the visual noise, still very new at this.

    private void ComputerAI(CellType player) {// takes player type to determine comp move
                Random move =new Random();
                int cell=move.Next(9);
                
                 //can act as both a defensive and offensive move
                if ((board[0] == player && board[0] == board[1]) ||
                    (board[6] == player && board[6] == board[4]) || 
                    (board[8] == player && board[8] == board[5]))
                    board[2] = CellType.PlayerO;
    
    


    i was thinking if the AI can pass player as a method then if any player has one move to win the AI can either play to win or play to prevent win
  4. In Topic: Tic Tac Toe

    Posted 19 Sep 2012

    here is the AI code i have so far. Ideally the AI should prevent a player from winning in one player mode, but what i have just plays random moves till its in a position to win. Any suggestions?
     private void ComputerAI(CellType player) {
                Random move =new Random();
                int cell=move.Next(9);
                
                if ((board[0] == player && board[0] == board[1]) || (board[6] == player && board[6] == board[4]) || (board[8] == player && board[8] == board[5]))
                    board[2] = CellType.PlayerO;
    
                else if ((board[0] == player && board[0] == board[2]) || (board[7] == player && board[7] == board[4]))
                    board[1] = CellType.PlayerO;
    
                else if ((board[1] == player && board[1] == board[2]) || (board[4] == player && board[4] == board[8]) || (board[3] == player && board[3] == board[6]))
                    board[0] = CellType.PlayerO;
    
                else if ((board[0] == player && board[0] == board[6]) || (board[6] == player && board[4] == board[5]))
                    board[3] = CellType.PlayerO;
    
                else if ((board[0] == player && board[0] == board[8]) || (board[6] == player && board[6] == board[2]) || (board[1] == player && board[1] == board[7]) || (board[3] == player && board[3] == board[5]))
                    board[4] = CellType.PlayerO;
    
                else if ((board[2] == player && board[2] == board[8]) || (board[3] == player && board[3] == board[4]))
                    board[5] = CellType.PlayerO;
    
                else if ((board[0] == player && board[0] == board[3]) || (board[2] == player && board[2] == board[4]) || (board[7] == player && board[7] == board[8]))
                    board[6] = CellType.PlayerO;
    
                else if ((board[6] == player && board[6] == board[8]) || (board[1] == player && board[1] == board[4]))
                    board[7] = CellType.PlayerO;
    
                else if ((board[0] == player && board[0] == board[4]) || (board[2] == player && board[2] == board[5]) || (board[6] == player && board[6] == board[7]))
                    board[8] = CellType.PlayerO;
                else
                        board[cell] = CellType.PlayerO;
               
            }
    
    

    thanks again for the brief tutorial on enums. Now i know when to use enums.
  5. In Topic: Tic Tac Toe

    Posted 19 Sep 2012

    Thanks baavgai, using ur guideline i have coded the game successfully. I think am starting to get the concept of using enums, but not completely, i'll keep practicing. I want to code a computer AI to compete with the player.Will code it and post it in this thread and maybe if you dont mind you will give me guidance and tips to make the code more efficient.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

rookie0Ken has no profile comments yet. Why not say hello?