Comp 1011 Assignment 2 (1 Viewer)

Constip8edSkunk

Joga Bonito
Joined
Apr 15, 2003
Messages
2,397
Location
Maroubra
Gender
Male
HSC
2003
i cant dl cygwin... cuz sites down...

but i can get make to work just cant compile... due to incompatbleinterface versions... despite having installed 6.0.1(somehow due to having 6.2 installed earlier)

what i did was downloaded this , extracted it 2 some directory, added its path environment ( basically "[whatever directory u installed in]/bin")
then i changed all the cp commands in the make file included in the assign2-stub.zip with xcopy and then ran make in the directory of the stub files.


edit: whoa rage u legend... looks pretty informative..... *starts reading it*

edit2 <deleted edit)
 
Last edited:

redslert

yes, my actual brain
Joined
Nov 25, 2002
Messages
2,373
Location
Behind You!!
Gender
Male
HSC
2003
kewl Ragerunner! you got a nice tutor! actually bothered to write so much
although i don't understand half of what is said!
 

Constip8edSkunk

Joga Bonito
Joined
Apr 15, 2003
Messages
2,397
Location
Maroubra
Gender
Male
HSC
2003
i think the definition for cluedogame and newgame will change depending on how we make our step function so its best to work on step first

its step that determines whats done each turn and how the gamestate will be affected.right now, it will always return no player disproving suggestions, and theres nothing stopping the game ie eliminating players... thats what we need to add first. to do so we must add more info to the cluedogame ADT, like what happened previous turn. then we need to devellop step further to accomadate for whisper inform etc and hence change the data CluedoGAme = ??? even more ....

thats what im think right now anyway
 

McLake

The Perfect Nerd
Joined
Aug 14, 2002
Messages
4,187
Location
The Shire
Gender
Male
HSC
2002
I'll interpret that for you later today, I have to go to uni now ...
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
You can get Cygwin from many places......like the CSE mirror...
 

McLake

The Perfect Nerd
Joined
Aug 14, 2002
Messages
4,187
Location
The Shire
Gender
Male
HSC
2002
DISCLAIMER: I havn't read the spec very thourougly, I am merley interpretting David's words, and adding what I know from what he has told me

> Let's say for the newGame function...you've got:
>
> newGame pls ans = CdG pls ans
>
> What am I meant to put to finish the function off? As in, what am I meant
> to be doing exactly?

First of all, you will need to set up your 'CludeoGame' data type.
Somewhere in your code, you will have something like:

data CludeoGame = CdG (???)

First of all, notice the name "CdG". It is useless. Replace it with
something more usefull. ("CludeoGameADT", perhaps?)

After the name of your data-type, you must specify what information you
need to store between turns. By default, you have:

data CluedoGame = CdG [(Player,[Card])] Triple

This means you are specifying that your CludeGame data-type will store a
list of players and the cards the are holding, as well as the solution.

You may wish to store other information as well, such as whose turn it
currently is and/or perhaps what happened in the last turn.

For debugging purposes, you will also certainly want to add the line:

data CluedoGame = CdG [(Player,[Card])] Triple
deriving (Show, Eq, Read)


'newGame' basically just sets up your CludeoGame data type, and returns
it to 'Cludeo.hs'. Cludeo.hs will then repeatably call 'step', giving
'step' your data-type, and getting a new one.


newGame :: [(Player,[Card])] -> Triple -> CluedoGame
newGame pls ans = CdG pls ans

All 'newGame' in its current format does is get the list of players and
cards, get the solution, and shove them into the default (insufficient)
CludeoGame data type.

So the code is basically saying:

newGame pls ans = CdG pls ans
^ ^ ^
| | |
| | +-- Create a new data-type 'CdG' (which is a
| | CludeoGame) and set its values to 'pls' and
| | 'ans'.
| |
| +---- Save the answer in the variable 'ans'
|
|
+-------- Save the players in the variable 'pls'
An ADt is like a C struct. It holds info that you want in one place. So your ADT will hold all the variable you need to keep track of, and it will be the input or output to most functions. Ask me to explain this more if it is unclear.

> What am I meant to put to finish the function off? As in, what am I meant
> to be doing exactly?

So, to answer your question, you must:

1. Define your own CludeoGame data-type. (Or just modify the current
one)

2. Change 'newGame' so it sets up and returns your CludeoGame data-type
in a state ready to given to 'step'.
Does this need any more exlanation?

> So basically what I need to do for newGame is to store all the details for
> all the players? e.g. Roland has cards K17,David,Mouse,Matthews,BFG
> and Kheng has cards Sara,Keyboard,Clancy etc... ?

Correct. As well as any other information you need to keep the game
running. (For example, you might want to remember that player "Bob" made
an accusation and was wrong, so he is out of the game, and that it is
Alice's turn next.)
Does this need any more exlanation?

> newGame :: [(Player,[Card])] -> Triple -> CluedoGame

This is the function signature. It is written in the spec. You can not
change it.

> newGame pls ans = CluedoGameADT pls ans

This is the line of code you need to rewrite.

Perhaps an example is in order.

Lets say I have a data-type 'Car':

type NumberPlate = String
type KilometersTravelled = Int
type CarAccidents = Int
type PedestriansHit = Int

data Car = CarADT NumberPlate KilometersTravelled CarAccidents PedestriansHit

I could then write a function, 'newCar':

newCar :: NumberPlate -> Car
newCar plateNumber
= CarADT plateNumber 0 0 0

I could then write some functions to do things to my car:

getNumberPlate :: Car -> NumberPlate
getNumberPlayer (CarADT plateNumber _ _ _)
= plateNumber

hitPedestrian :: Car -> Car
hitPedestrian (CarADT plateNumber kmTravelled accidents pedestriansHit)
= (CarADT plateNumber kmTravelled accidents (pedestriansHit + 1))

(And so on)

Basically, all 'newCar' does is creates a Car data-type which can then
be used in my other functions.

All 'newGame' does is creates a 'CludeoGame' data-type which can then
be used in Cludeo's other functions, such as 'step'.
This is a setup function to set values. David has given a fairly good explantion here. Do you wan't me to explain it further?
 

Ragerunner

Your friendly HSC guide
Joined
Apr 12, 2003
Messages
5,472
Location
UNSW
Gender
Male
HSC
2003
I understand his explanation reasonably well, but implementing it is another thing...
 

McLake

The Perfect Nerd
Joined
Aug 14, 2002
Messages
4,187
Location
The Shire
Gender
Male
HSC
2002
Originally posted by Ragerunner
I understand his explanation reasonably well, but implementing it is another thing...
Too true ...
 

cyrax83

discrete is killing me :(
Joined
Nov 18, 2002
Messages
376
Gender
Male
HSC
2003
i say we all pitch in $10-$15 each. get some smartass to make us 1 copy of his code. Then we all change it around and put in a million other variable names/make the code a 100 times more unefficient and totally screw it around.
 

enak

Limbo
Joined
Oct 18, 2002
Messages
1,046
Location
Sydney
Gender
Undisclosed
HSC
N/A
Originally posted by cyrax83
i say we all pitch in $10-$15 each. get some smartass to make us 1 copy of his code. Then we all change it around and put in a million other variable names/make the code a 100 times more unefficient and totally screw it around.
lol, the lecturer today talked about copying other ppl's code today :p
 

redslert

yes, my actual brain
Joined
Nov 25, 2002
Messages
2,373
Location
Behind You!!
Gender
Male
HSC
2003
lol his just trying to scare us

i doubt anyone copied for assign1 because you have to be extremely stupid to not even be able to do pronounce.....his just threaten us
 

Constip8edSkunk

Joga Bonito
Joined
Apr 15, 2003
Messages
2,397
Location
Maroubra
Gender
Male
HSC
2003
apparently there was this one time some1 got expelled for breaking into his lecturers office to get assignment/exam solutions for some comp course lol
 

redslert

yes, my actual brain
Joined
Nov 25, 2002
Messages
2,373
Location
Behind You!!
Gender
Male
HSC
2003
with the amount of stress i'm under for this one assignment, i don't blame who ever it was!
 

Ragerunner

Your friendly HSC guide
Joined
Apr 12, 2003
Messages
5,472
Location
UNSW
Gender
Male
HSC
2003
He isn't lying. My friend got BUSTED for plagarism for assign1.

He went from 19.5/20 to 0...

Lucky he didn't receive negative marks..

And at this stage, I'm still CLUELESS for stage 1.....

argh...
 

redslert

yes, my actual brain
Joined
Nov 25, 2002
Messages
2,373
Location
Behind You!!
Gender
Male
HSC
2003
wow that's pretty nasty
i guess who ever he copied off got 0 also

arrrrrrrgh your not the only one still lost!
so many people finished already and in under 150 lines!!

i'm still on ZERO....
 

cyrax83

discrete is killing me :(
Joined
Nov 18, 2002
Messages
376
Gender
Male
HSC
2003
rage get ur ass to cse labs and help me :(
 

Constip8edSkunk

Joga Bonito
Joined
Apr 15, 2003
Messages
2,397
Location
Maroubra
Gender
Male
HSC
2003
i know some one who went from 20 to -15 .... harsh.....

start by writing a function that checks what happens when "pl play"(Action) is a suggestion(use isAccuse)(ie checks wether the suggestion is correct ...remember that the Action here is Suggest Triple) you can do this in many ways, using recursion - checking each card or usiing higherorder functions and elem. you want to make it so that the function returns the player ID (getID) of the 'disprover' and the Disproving Card.... this can then be subbed into the second value ..(where it is NOthing right now)

on the other hand an accusation ...ie it should return Nothing for the 2nd part of the triple... then the 3rd value(the new gamestate) will be either Just [NewGame State] (if accusation is wrong) or Nothing (if accusation is right).

The New GameState must be of type CluedoGame... and it must also update any information that is needed for a new turn... eg give players new information by using inform and whisper(just use type signature as a guide)... also consider how you might deal with the elimination of players. To do this you need to modify data CluedoGame (add more information). its best to write another function(s) to update the gamestate so u dun have guards everywhere in step to account for coorect accusation wrong accusation correct sugestion wrong suggestion ....

Finally, account for the scenario where there are no players left (ie. Maybe Action of the 1st vaklue of the triple given by step is Nothing)
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top