Tuesday, 20 December 2011

maintainability

added maintainability by making white spaces to easily read code, and green text to describe what each part does, printed offmade questionaires for testing, began gantt chart
got results from testing, done making psuadocode
completed gantt chart
redragheded origional project plan
wrote test report
wrote evaluation report
handed in finished project

Saturday, 17 December 2011

the code is done :D

added selection sort for veriety, added a 2-D array into the beggining to help with shuffeling. added 3 new forms, a menu, a instruction form and a highscore form. added in algorithm to end game and display winning (or second place) message upon losing last card. implemented a way to switch between forms (.show and . hide)
filled instruction form with text detailing how to play, made highscore form able to read from highscore file and create it if it is not availiable (H:/highscores). added part in which winning user is asked if they want their score saved, if they click yes it writes to and appends file to save their score and name which is asked for after.added more maintainabillity by adding in green text and spaces.. also sent away with questionaire for testing. created title page.

Tuesday, 15 November 2011

the end of the horizon

added messages to tell player that another player has run out of cards
working on way to end the game after 2 players have won as cheat becomes unrealistic when logical decisions occur when cheat boils down to 2 players

todo list
- end the game
- add selection sorts for veriety
- add file handling to create and read and edit highscores
- add initial form with instructions and access to highscores
- test among classmates

cards dont lie

has had trouble updating recently so brief updates
removed some buttons and replaced with subroutines (finish turn and claim cards) to make program more streamlined
added 52 buttons for all possible decks
made bubble sort mechanisms to make values look nicer, may add selection sort later for diversity
remade number to card translation subroutine called translate, gives a textual value to numbers in deck and also to last card in table pile
added ability for computer to shout cheat by randomly selecting a number, if 1 is chosen then cheat will be shouted by a random player or more and  depending on if a boolean value (cheattruefalse) is true or not the pile is moved into the p1 array or the accusers array deck
added subroutines to disable all 52 cmddeck buttons on command and also check if they are disabled, also added subroutine to make buttons enabled from 1 to number of cards player has left if there are no cards in pile or they decide to cheat
added subroutines to make players 2-4 play in order by searching to see if they can place a card of matching value, and if not select random cards from pile to cheat with
added code to ask the player if they want to cheat, cheattruefalse depends on this value. if player has no options and has to cheat because they're cards do not match then cheattruefalse is automatically true
added translation subroutines for each of the cpu players
made auto updating timer subroutine which updates on screen details every 5th of a second, may be removed later to reduce processor usage
added subroutine to let p1 play after turns of p2-p4 and detect whether any card can be played due to no cards in pile or if a matching value of card can be used or if only option is to cheat
added system of random numbers and if statements to determine if cpu will call cheat on itself, asks player beforehand if they think the cpu cheated, if they select yes and the cpu is not fast enough (number selected =/= resulting in cpu calling cheat) they will either claim or give the pile from/to the cpu player depending on if they cheated or not. cpu can still beat the player and call cheat first if the random number reflects this outcome, selecting "no" will result in nothing being called or a cpu player randomly calling cheat

Thursday, 6 October 2011

cheating computers

made basic cheat button algorithm to return cards into players deck 1 at a time, work needs to be done untill whole pile is transfered in one click. made winning message for when pile = 0
played around with timers and subroutines to start planning how the computer will use this data and play as 3 different players with time delays inbetween

Friday, 30 September 2011

documents

created and stored away proect plan, feasability and scope and boundarys in red folder

Wednesday, 28 September 2011

deleting arrays

found out how to remove array item by redimming and "sliding" each array item to left if they are larger than card selected.

changes

temporarily abandoned card idea untill basics of code is completed. tried using buttons to help user select card to place in pile, learned about and implemented redim and preserve statements to make the arrays of player1 and pile maleable to number of items in each array.

Tuesday, 20 September 2011

naming cards

put in extra if statements to give meaning to numbers in array
eg. if cards(i) = 1 then
cards(i) = "ace"
end if

also amde to display all cards for player

Monday, 12 September 2011

everyday im shuffelin'

wrote pseudocode and algorithm to generate 52 random numbers in an array and display them neatly (nessesary for main project)

pseudo code: dim global variables, array items and counter
1. when command gets clicked
1.1 set counter to 0
1.2 make a collection
1.3 declare array
1.4 dimention x as integer to store random numbers
1.5 randomize
1.6 make collection a new one to start fresh
1.7 add all possible cards to collection when array item is i
1.7.1 next i
1.8 for all numbers in collection
1.8.1 make x item in collection
1.8.2 add it to array
1.8.3 display number
1.8.4 add 1 to counter
1.8.5 check counter private function
1.8.6 remove number x from collection so next is unique
1.8.7 next x
1.9. end sub
2. random generator code function
2.1 upper - lower
2.2 end function
3. check counter
3.1. when counter gets to 52
3.1.1 take new line for neater text
3.2 end if
3.3 end sub




"Option Explicit 'Force variable declaration

     Dim i As Integer 'Counter for loops
     Dim COUNTER As Integer
      Private Sub cmdstart_click()
   COUNTER = 0
          Dim Collection As Collection 'The collection we will use to store the numbers
 
          Dim cards(1 To 52) As Integer 'The array to store the values from the collection
 
      
 
          Dim X As Integer 'Variable to store the random generated number
 
        
          Randomize 'Just once to ensure that we get random values
        
          Set Collection = New Collection 'Get the collection ready to use
 
        

          For i = 1 To 52 'The possible numbers that we can have as a result is all the numbers from 1 to 52 so
              Collection.Add i 'add all the possible numbers to the collection
          Next
        

          For i = 1 To 52 'Now to get the 52 numbers we added in the previous loop
              X = RandomInteger(1, Collection.Count) 'Get a random item from the collection (that exists for sure)
              cards(i) = Collection.Item(X) 'Add it to the array
TB.Text = TB.Text & " " & cards(i) ' make space for and display each number
COUNTER = COUNTER + 1 ' add 1 to counter
checkcounter ' private sub to make results neater
              Collection.Remove X 'Remove it so we don't add it again
          Next
        

End Sub
Private Function RandomInteger(Lowerbound As Integer, Upperbound As Integer) As Integer 'The random number generator code
 
          RandomInteger = Int((Upperbound - Lowerbound + 1) * Rnd + Lowerbound)

      End Function
 
Private Sub checkcounter()
If COUNTER = 52 Then ' when all numbers picked and put in array
TB.Text = TB.Text & vbCrLf ' take new line for next set
End If

End Sub"

Friday, 9 September 2011

progress and new updated detailed project proposal

updated project proposal so it is more detailed

"
Callum green project proposal

Cheat is a fun game where a group of players are dealt a equal amount of cards and then play in order where a number of cards are placed, if a card is above, the same, or bellow the placed card in a numerical sense then said card(s) may be placed on top of the pile. However the player may add any card, if this card is not above, below or the same as the card previously played then it is called a cheat. If another player calls cheat the player must take the entire pile into their deck. Similarly if a player calls cheat when the play was not a cheat, the accuser must take the pile. This process continues until 2 players are left. By a process of elimination it would be too easy to declare if an opponent is cheating and must be stopped when number of players reaches this number. These are the losers. The first person to have no cards is the winner

In visual basic, the game would begin by creating a 52 part array with a unique card in each place
These are then “shuffeled” into 4 separate arrays and a 5th is created for the middle pile
One array is the players and they may choose which card to place on the pile from their array displayed in a text box. There is a random chance someone will shout cheat and the player can also yell cheat by pressing a button. The arrays will change to accommodate more or less cards respectively. When the first person gives their last card they are deemed the winner and they will be announced at the end of the game. The game ends with the last 2 players and the winner will be announced, number of turns will be recorded on a high score list. Details stored can be sorted using various sorts to find the person who cheated the most, search can be used to find out high score (array = 0 places)
I believe this Is a good enough project for AH due to complexity of the code, the use of saving files (high score) various sorting (finding who cheated the most) and searching (finding details of winning turn etc turns used and wether cheat)"

Wednesday, 7 September 2011

algorithim thinking

considered how to make a unique random number generator from 1 to 52, consulted the website http://www.vbforums.com/showthread.php?t=281172

Thursday, 30 June 2011

started blog to type evidence for the AH project :)
wrote project proposal, wants to create VB version of cheat
considered use of sorting, searches and saving. game could be saved, cards sorted by quantity held and CPU players sorted by quantity of cards, number of cheats and largest cheat could be counted and displayed, whether a CPU player calls cheat is determined by a random number generator. hopes to write algorithim over summer holidays

hope you enjoyed my first post :D