We were able to implement the win checking in Lua easier than C# mainly because of using a matrix to represent the board instead of a button array. The matrix allowed us to break the board down into sections where we needed to check for certain win scenarios. The seven different possibilities to win are shown in the image below:
After we implemented the basic win scenarios shown above, we determined that the code above does not account for the cases where the winning piece is placed in the middle of the four pieces, not an end piece. In order to account for these scenarios, we created the following for loop. This for loop checks the win for the current column and the two columns to the right of the piece. We also added a check to make sure the current column is inside the board.
The last two cases are for the diagonal wins are taken care of by the following for loop. This checks the diagonal wins for the 2 pieces up and down to the right of the current piece. We also added a check here to make sure our current row is inside the board.
Piecing it all together - we get our CheckWin function!
Team 3: Lua Connect Four - Mike and Blake
Monday, April 25, 2011
Sunday, April 24, 2011
We have artifical intelligence!!
Tuesday, April 12, 2011
Decision to go command line
Blake and I met on Sunday and decided to do a command line version which will print out a 7x6 game board. Brackets will divide the rows and each space will be assigned to an array location (1 through 42). Each space will store either a 0 1 or 2. This will denote if the space is empty, occupied by a Red Chip or occupied by a Black Chip.
I am going to start with the new stuff and Blake is going to work on converting our old C# code and game logic into Lua.
I am going to start with the new stuff and Blake is going to work on converting our old C# code and game logic into Lua.
Saturday, March 5, 2011
First Post
Hey everyone. For our project we will be converting a "Connect Four" game from C# to Lua. We have gotten a start by installing Lua 5.1 and playing around with some basics. So far some interesting things to note are that Lua is case sensitive, and in Lua a variable type does not need to be defined.
For now our plan is to take our exsiting code and convert the syntax from C# to Lua. From there we will compile it piece by piece to determine if we made any errors. After that we will implement in order to gain all the necessary functionality. This of course is our high level plan and is subject to change as we hit road blocks...stay tuned!
For now our plan is to take our exsiting code and convert the syntax from C# to Lua. From there we will compile it piece by piece to determine if we made any errors. After that we will implement in order to gain all the necessary functionality. This of course is our high level plan and is subject to change as we hit road blocks...stay tuned!
Subscribe to:
Posts (Atom)