last day (15 days later) » 

3:29 PM
hello
 
hello
 
are you familiar with java?
 
yes
 
do you mind helping me? :S
 
yes :)
 
3:31 PM
i have a couple of questions
:3
umm
ok
first of all
this is a project so like i just want u to know ur helping me with homework
if you're ok with that
 
no problem as long as you don't just copy paste I'm ok with that :D
 
well
im basically done
just a few errors and optimization required
do you want me to send u the link of the project so u know what im talking about first?
 
Ok which step are you doing now ?
 
umm
im gonna send u
my whole project
so u can see
what ive done so far
i've finished the decision tree
nvm idk how to send a zip file
how do i do this.
 
dekajoo@gmail.com
:D
 
3:37 PM
kk
sent
so basically "GuessWhoGame" and Color was provided to me already
 
ps: I have a call at 18h so we might not finish but i can take you after the call (30min ~)
 
I have to do Guesser and GuesserTest
when is 18h
 
in 20 min
in france:D
 
ok we can do this until
then oh je parle francais aussi
;)
 
You should do guesser like that
What are the parameter on the people you got ?
(like hair, shirtcolor ...)
en francais peut etre
En fait moi je commencerais par faire une matrice 2d (un tableau de tableau quoi) de booléens
de couleur spardon
en ordonné les noms des personnes et en abscisse les characteristiques (hair, shirt...)
ensuite tu parcours ce tableau et tu trouve la question la plus équilibré possible en fonction des personnes restantes (il te faut une liste de personnes restantes)
 
3:45 PM
ok im not that good at french :p english plz
 
lool
 
i didnt understand a thing u said hahaa
look at guesswhogame
it has all the parameters
it goes name hair shirt eye glasses smiling hat
 
Ok basically the better question is
given the people that have not been eliminated already
what question should I ask that have the most balanced probability
if it's a yes/no question that must be 50/50
 
ohh ok
 
the closest to 50/50
 
3:47 PM
what i did was just go shirt colors
if u can help me fix first the problem
i have a problem with isabelle and dave
1 test failed:
GuesserTest
testConstructor
testMain
testGuesser
File: C:\Users\Rohan Vidyarthi\Desktop\Project 1\GuesserTest.java [line: 33]
Failure: org.junit.ComparisonFailure: expected:<[Dav]e> but was:<[Isabell]e>
 
if it's a color question that must be 100/number_of_possible_color for each people
ohhh
 
i cant find the error
 
ok I thought you want to solve the problem in the minimum of time
but you just want to solve the problem right ?
 
i mean i would like to do that but first i just want to solve it and make it work properly
before i try to optimize it
 
ok
I'm looking
your method is quite dirty
 
3:50 PM
:(
 
you can't just do if () {if () {}}
 
sorry i am new to programming
 
that's not the good way :)
np
 
how should I do it?
 
you have a list of people ok ?
 
3:51 PM
yes 26 ppl
 
you should do a fonction that ask a single question and given the answer get rid of the people that do not fit in the list
 
I did that
First I took all people with brown hair
it had like 13 people
then I made 3 sub groups with 3 different shirt colors
 
yes but you are asking ALL the question in one function
 
hmm
 
and you do not elminate people from a list
you just choose the winner at the end
 
3:53 PM
can u show me how
small example
 
Yes I'll send you an example in 30 min but I need to go get that call now
 
ok
 
(business interview and such :p)
 
i will try another way to do this until then :)
 
see you in 30min
 
3:54 PM
in this chat or gmail?
 
try to create a list of people possible copying the basic list
and then ask 1 question
(only one) and get rid of the people not fitting
 
i swear mine does that.. but ok
talk to u in 30 mins! <3
 
4:05 PM
    if (g.hairIsColor(Color.BROWN)) {
        if (g.shirtIsColor(Color.GREEN)) {
            if (g.isWearingGlasses()) {
                if (g.isSmiling()) {
                    if (g.isWearingHat())
                        return "Emily";
                    if (g.eyeIsColor(Color.BLUE))
                        return "Alice";
                    if (g.eyeIsColor(Color.GREEN))
                        return "Frank";
                    else
                        return "Isabelle";
                }
like this?
 
4:16 PM
dont read that ^ its stupid and i am stuck :'(
 
4:41 PM
re
ok :D
let me code something to show you
 
i finished it
:p
 
nice
you found your mistake or tried another way ?
 
yea i just hard coded
that one person
but i would like to know 2 things
 
ok :D let see if we can do better
yes ?
 
how to make this program without being messy since u said its messy
and also how to optimize to make it smaller
right now its asking about 9-19 questinos
 
4:43 PM
yes we can do much better I think,
 
how did the interview go btw?
 
I'll try to show you how to make a clean and that will reduce the size of the code
I NAILED it :D
 
kk
 
(mean very good)
ok let me 10min so I can write a bit of code
 
kk
 
4:48 PM
One think I see first :
System.out.println(y.play(x));
System.out.println(x.guess(y.play(x)));
this is very bad do you see why ?
 
no
o.O
 
Be cause you are calling play 2 times
when it's the function that is suppose to take time :D
 
oops
 
(very bad was a bit exessif)
 
but i need to run plat
play
anyways and can nly do it with guess
 
4:49 PM
ofc but you can do :
string result = y.play(x);
System.out.println(result);
System.out.println(x.guess(result));
 
o :P
kk merci beaucoup
 
every time you call a thing 2 times in a raw try to wonder "is it worth it to do a variable"
ok i get back to it
are you alawed to modify GuessWhoGame.java ?
 
nope
 
hmm can you access the "characters" table
?
 
possibly
yes
g.isSmiling()
g.shirtIsColor(Color.RED)
 
4:53 PM
no I mean
 
etc
 
When you play guess who you have the person in front of you
and you can see the list of starting characters
with their hair color etc..
Do I have to hardcode a copy of the characters table or can i get it from somewhere ?
 
oh idk...
im not sure what you mean
 
I mean I'm suppose to know that karen has black hair
I'm not suppose to ask it
you "hard coded" it
with your imbricated "if (...) {}"
 
yea thats the only way
 
4:56 PM
nested
 
boolean hairIsColor(Color c)
return true if the character's hair is the specified color, false otherwise
boolean eyeIsColor(Color c)
return true if the character's eyes are the specified color, false otherwise
boolean shirtIsColor(Color c)
return true if the character's shirt is the specified color, false otherwise
boolean isWearingGlasses()
return true if the character is wearing glasses, false otherwise
boolean isSmiling()
return true if the character is smiling, false otherwise
boolean isWearingHat()
those r the methods in guess who game to retrieve the characteristics of the characters
 
but does it count as a Question if it's not about the secret character ?
 
ohh
 
do you see the issue ?
 
guessing the person's name counts a question, and if you don't get it right you have a penalty of 11 questions . Optimal trees will have to ask 4 or 5 questions before guessing, making the final score from 5 to 6 per game.
so yes every question that is askde and is not about the person is still counted
 
5:00 PM
you will get it when i finished
 
o.o ok
 
by the way have you seen inheritance ?
 
not yet
 
5:17 PM
oh
ok so If i give you my answer they will now I helped you
hmmm let me try something more simple
ok so If you havn't seen inheritance, coding the way you do is ok, I think your teacher is expecting something like it.
BUT
Their is some things you might do to enhance your code
 
iyd ok
its ok
im not going to turn in
your answer
im already done
i just learning now
:p
 
**First** : When you have more than 2 possibility you shouldn't do :
if (g.shirtIsColor(Color.GREEN)) { ... }
if (g.shirtIsColor(Color.RED)) { ... }
...

You shoudl do a switch instead
switch (particularity) {
case Particularity.BLUE:
...
break;
case ...

default...
 
O.O ok
 
have you seen the switches ?
switch/case ?
 
yes i use switch for my test
 
5:22 PM
it's cleaner to use switch when you have more than 3 possibility
2*
and the good thing is that since you have a default case that should never been accessed
you can raise an exception in it (if you have seen exceptions)
 
nope
 
that basicly says : "the program shouldn't be here that's a bug" that helps a lot when debugging and clean programmers raise exceptions.
never mind
:)
ok so Secondly :
if you want to optimise the number of question
since your array of people is static
the only thing to optimise is what question do you ask in above all IN WHICH ORDER ?
 
hmm ok
 
since your array of characters won't change the order you ask question don't need to change.
The way to choose what question you should ask is simple
for each attribute possible of a character (color of the hair, eyes, presence of hat,...) write somewhere the % of people with each type of attribut
that's not clear let me give you an example
 
kk
 
5:29 PM
first attribut is hair in this table :
private static final Character[] characters = new Character[] {
new Character("Alice", Color.BROWN, Color.BLUE, Color.GREEN, true, true, false),
new Character("Bob", Color.BROWN, Color.BROWN, Color.GREEN, true, false, true),
new Character("Carol", Color.BLACK, Color.BLUE, Color.BLUE, true, false, false),
new Character("Dave", Color.BROWN, Color.BROWN, Color.GREEN, false, true, true),
new Character("Emily", Color.BROWN, Color.HAZEL, Color.RED, true, true, true),
(you just have to look at the code
 
yea
 
the constructor of Character is public Character(String name, Color hair, Color eyes, Color shirt, boolean glasses, boolean smiling, boolean hat))
ok
so for the question "what is your hair color"
sorry for the question isYourHair( color ) ...
their is 11 people to answer yes to BROWN
4 people to answer yes to black
2 blond
2 red
so that give you 11/20 % to guess rigth on brown
4/20 for black
etc ...
because there is 20 people
do you follow me ?
anyway your goal for each attribute (hair, eyes...) is to find the question the closest to 50% people answering yes
and take note of that percentage
(for the banary question you have only 1 choice so you just have to take note of how many people will answer yes)
when it's done you have to order question from the question the closest to 50% answering yes to the question with % of people answering yes the farest from 50%
(that can be close to 0% or 100%)
if you harde code the possibility like you have done with the questions ordered in this order you will have the most efficient way to ask questions possible
but this will be long since you have to do it again after each answer who will shrink the number of possible characters.
good luck I have to go : )
(ps: I stared 5 answers from you so you'll have the bronze medal from SO, keep farming !)
 

last day (15 days later) »