RebelnRevolt's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
4 (0.01 per day)
Joined:
08-December 12
Profile Views:
130
Last Active:
User is offline Dec 10 2012 09:26 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   RebelnRevolt has not set their status

Posts I've Made

  1. In Topic: mind reviewing my pseudocode?

    Posted 9 Dec 2012

    here's what I ended up with after the changes. I'm feeling a lot better with where I'm at now. thanks again Martyr2!

    		
    Module Main()
    	//initialize the game board
    	Constant integer ROWS = 3
    	Constant integer COLS = 3
    	Declare string board[ROWS][COLS] = {" *"," *"," *"}
    					                   {" *"," *"," *"}
    					                   {" *"," *"," *"}
    	declare boolean gameOver
    	set gameOver = false
    
    	Display board[][]
    	
    	While gameOver = false
    		
    		//represent player 1 choice	
    		Call playerOne()
    	
    		Display board[][]
    
    		Call checkWin()
    
    		//represent player 2 choice
    		Call PlayerTwo()
    		
    		Call checkWin()
    
    		display board[][]
    	End while		
    	
    End Module
    
    Module checkWin()
    	declare integer index
    	declare integer indexA
    	declare integer indexB
    
    	//Check if player 1 won
    	set index = 0
    	//check horizontals
    	If board[index][] = " X, X, X" Then
    		Display "Player one wins!"
    		set gameOver = True
    	else
    		If index <=2 then
    			set index = index+1
    		end If
    	end If
    
    	set index = 0
    	//check verticals
    	If board[][index] = " X, X, X" Then
    		Display "Player one wins!"
    		set gameOver = True
    	else
    		If index <=2 then
    			set index = index+1
    		end If
    	end If
    	
    	//Check diagonals
    	If board[0][0]=board[1][1]=board[2][2] = X OR
    	   board[0][2]=board[1][1]=board[2][0] = X Then
    		Display "Player one wins!"
    		set gameOver = true
    	End If
    	
    	//Check if player 2 won
    	set index = 0
    	//check horizontals
    	If board[index][] = " O, O, O" Then
    		Display "Player two wins!"
    		set gameOver = true
    	else
    		If index <=2 then
    			set index = index+1
    		end If
    	end If
    
    	set index = 0
    	//check verticals
    	If board[][index] = " O, O, O" Then
    		Display "Player two wins!"
    		set gameOver = true
    	else
    		If index <=2 then
    			set index = index+1
    		end If
    	end If
    	
    	//Check diagonals
    	If board[0][0]=board[1][1]=board[2][2] = O OR
    	   board[0][2]=board[1][1]=board[2][0] = O Then
    		Display "Player two wins!"
    		set gameOver = true
    	End If
    	
    	Set indexA = 0
    	Set indexB = 0
    	//Check if astrierisks are on the board to determine tie.
    	
    	If board[indexA][indexB] = " *" Then
    		end if	
    	Else
    		While indexA<= ROWS-1 AND indexB<=COLS-1
    			If IndexA <=2 
    				Set indexA = indexA+1
    			Else
    				Set IndexA = 0
    				Set indexB = indexB+1
    			end if
    		End while
    		
    		Display "The game is a tie."
    		Set gameOver = True
    	End If
    		
    End module
    
    
    Module playerOne()
    	declare integer rowLine
    	declare integer colLine
    	declare boolean nextTurn
    	
    	
    	set nexTurn = false
    
    	While nextTurn = false
    		// get player 1 input
    		Display "Player 1 [X]:"
              	Display "Enter row [1-3]:"
              	Input rowLine
    		while rowLine<1 OR rowLine>3
    		Display "invalid input, reenter choice."
    		input rowLine
    		Display "Player 1 [X]:"
    		Display "Enter column [1-3]:"
    		Input colLine
    		while colLine<1 OR colLine>3
    			Display "invalid input, reenter choice."
    			input colLine
    		end while
    
    		//reflect input on board
    		If board[rowLine-1][colLine-1] != " *"
    			Display "invalid move"
    		else
    			set board[rowLine-1][colLine-1] = " X"
    			set nextTurn = true
    	End If
    End module
    
    Module playerTwo()
    	declare integer rowLine
    	declare integer colLine
    	declare boolean nextTurn
    	
    	
    	set nexTurn = false
    
    	While nextTurn = false
    		// get player 2 input
    		Display "Player 2 [O]:"
              	Display "Enter row [1-3]:"
              	Input rowLine
    		while rowLine<1 OR rowLine>3
    		Display "invalid input, reenter choice."
    		input rowLine
    		Display "Player 2 [O]:"
    		Display "Enter column [1-3]:"
    		Input colLine
    		while colLine<1 OR colLine>3
    			Display "invalid input, reenter choice."
    			input colLine
    		end while
    
    		//reflect input on board
    		If board[rowLine-1][colLine-1] != " *"
    			Display "invalid move"
    		else
    			set board[rowLine-1][colLine-1] = " O"
    			set nextTurn = true
    	End If
    End module
    
    


    the only thing I'm really unsure about is if I did the checking for the 3 in a row for vertical and horizontals correct. So if anyone can put me at ease for that or let me know of anything else they see in this I'd greatly appreciate it and I'll uh...I dunno draw you a picture or something!
  2. In Topic: mind reviewing my pseudocode?

    Posted 8 Dec 2012

    awesome thank you so much!!! :D

My Information

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

Contact Information

E-mail:
Private

Friends

RebelnRevolt hasn't added any friends yet.

Comments

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