Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#201 Re: Maths Is Fun - Suggestions and Comments » Chess » 2008-04-01 02:47:26

By the way, this topic made me make my own chess engine in C++. Its even weaker than this one though. The move generating and implementing the alpha-beta searching took quite a while for me so my evaluation function is as simple as you can get. Its basically what mathyperson suggested of the values of the pieces.

int Eval_function()
{
    int value_piece[6] = {VALUE_PAWN, VALUE_KNIGHT, VALUE_BISHOP, VALUE_ROOK, VALUE_QUEEN, VALUE_KING};
    int score = 0;
    for (int i=0;i<64;i++) {
        if (color[i] == WHITE)
            score += value_piece[piece[i]];
        else if (color[i] == BLACK)
            score -= value_piece[piece[i]];
    }
    if (side == WHITE)
        return score;
    return -score;
}

This is as simple as you can get. If you want it to improve a little then you need to start implementing other deductions and bonus in scores. For example, as you can see in this code, the score consists ONLY of the pieces in the board. It doesnt take into account any positional knowledge etc.

A suggestion for you MathIsFun, which is something im going to implement in mine in the summer (since im almost in finals right now and getting to where i am basically took me all day yesterday and I had to study for Discrete sad ) Start tweaking your evaluation function such as this:

give bonus score if a side has a rook on an open file.
give bonus score if 3 pawns are covering the king.
give bonus score if theres a knight near the king.
deduct score if the king has an open file.
give bonus score if the bishop's diagonal are longer = more mobility.
give bonus score if your pawns control the center of the board.

Etc. I read this a site once about how to tweak your evaluation fucntion. It looks very simple but it actually serves of help in the strength of play.

Also, MathIsFun you asked about relative value of the pieces. I assume you have your knights valued as 3 (or 300, as I do so all my work is in integer). In a simple evaluation function where you only take into account the value of the piece, your basically saying that a Knight in its original position is worth the same as a knight placed on a key spot such as e4 and d4 controlling the center of the board. Same can be said about having control of the center. If any of you took chess classes when you were little, I can still remember my trainer "control the center of the board..." etc. Having control of the center is a key element.  So as I said, a knight placed and protected in d4 is worth more than 3 but also a backwards knight in b1 which offers no help is worth less than 3. Its all relative to the position. Every piece has similar stuff, if you add this to every piece etc. The engine will increase its playing strength dramatically even if it sounds that your doing simple stuff.

Hope I helped.

#202 Re: Maths Is Fun - Suggestions and Comments » Chess » 2008-04-01 02:22:34

Look at this game playing medium style:

1: e4  Nf6
2: Nc3  Nc6
3: f4  d6
4: Nf3  Bd7
5: Bb5  Nxe4
6: Nxe4  d5
7: Nc5  b6
8: Nxd7  a6
9: Bxc6  Rc8
10: Nf6

Why did it give me a free piece at move 5 with Nxe4?

Also when I checkmated it with a double check it didnt record the final move as Nf6++ or even Nf6+ indicating im checking him with knight and bishop.

#203 Re: Dark Discussions at Cafe Infinity » how old » 2008-03-31 10:16:33

Im 18. I will be 19 in June.

Time goes by fast....and I want it to go faster till I hit 21 (drinking) and then I want it to stop. smile

#204 Re: Help Me ! » finding the missing side of a triangle » 2008-03-31 10:14:44

Why didnt it help you? Its perfectly clear. I think the problem lies on the other side of the screen.

#205 Re: Help Me ! » How to do this integral? » 2008-03-30 13:38:28

And now for the new integral?

#206 Re: Help Me ! » How to do this integral? » 2008-03-29 15:01:51

I do not follow that approach since I havent been introduced to double integrals yet.

#207 Re: Maths Is Fun - Suggestions and Comments » Chess » 2008-03-29 04:38:26

Also. I was just playing this game:

1: f4  Nf6
2: Nc3  Nc6
3: e4  Nd4
4: Nf3  Nxf3+
5: Qxf3  c5
6: Bc4  d6

and I was trying to castle for the 7th move and it didnt let me. I think its because when the knight ate on f3 it was checking me. But since I ate with the queen and my king never moved I could still castle under chess rules. Might want to check on that.

#208 Re: Maths Is Fun - Suggestions and Comments » Chess » 2008-03-29 04:30:43

Could you please add different levels of difficulty?

Look at this game in pgn-viewer:

1: e4  Nc6
2: f4  Nf6
3: Nc3  d6
4: Nf3  Be6
5: d4  h5
6: d5  Nxd5
7: exd5  Bxd5
8: Qxd5  Nb4
9: Qb5+  c6
10: Qxb4  c5
11: Bb5+  Qd7
12: Bxd7+  Kxd7
13: Qxb7+  Ke8
14: Nb5  Rd8
15: Qc6+  Rd7
16: Qc8+  Rd8
17: Nc7++

in move 5-6 it let me fork one of his pieces but instead of losing just that one, it ate with the knight which ended up losing 2 pieces. It went and gave me another piece later on.

Also, when a move gives checkmate, such as in my example "17: Nc7+" it is written with 2 plus signs. like "17: Nc7++"

#209 Re: Help Me ! » How to prove Bernoulli's inequality using Induction? » 2008-03-29 04:14:56

Thanks a lot luca. I understand it now. I didnt reply sooner because I had to run to take my test but as I mention in another topic, it was canceled.

Thanks a lot.

#210 Help Me ! » Combinatorics and Permutations. » 2008-03-28 12:30:43

LuisRodg
Replies: 1

I had a test today on Logic, Mathematical Induction, Strong Induction, Structural Induction, Combinatorics and Permutations.

The test was canceled because there was a misunderstanding with the time and the proctor etc so it was postponed to next Friday.

I felt really comfortable in all the areas except Combinatorics and Permutations and now that I have an extra week to study, I'd like to improve in those areas.

I have read the Combinatorics/Permutations chapter twice and I have understood everything perfectly however, when given a problem somehow I just cant come up with the solution. It doesnt come to me. As in the past, this is solved with practice so right now as I type im doing every problem in the back of the chapter but im having trouble with all of them and I find myself having to look at the solutions manual.

Could anyone that is good at Combinatorics/Permutations offer some tips? Like, how to approach certain type of questions etc. My book seems to explain the general theory but doesnt go much further than that.

It'd really be helpful.

#211 Re: Dark Discussions at Cafe Infinity » Spring Break anyone??? » 2008-03-28 12:16:00

Spring Break for me was last week.

I live in Miami so I stayed local and went to Miami Beach with a couple of my friends etc. Nothing great but its better than staying at home. I did some catching up with homework as well.

#212 Help Me ! » How to prove Bernoulli's inequality using Induction? » 2008-03-28 03:43:03

LuisRodg
Replies: 2

Prove that if h>-1 then 1+nh <= (1+h)^n

So I did the basis step:

Inductive step:

So:

But I got stuck and dont know how to continue...I dont know how to keep filling the blanks so the induction is finished. Could anyone help me?

#213 Re: Help Me ! » Largest number in subset » 2008-03-28 02:38:28

What do you mean largest subset?

How do you define largest? By the amount of elements contained? In that case, that is called the cardinality of a set, denoted:

|A| = the amount of elements inside a set.

So given a set, the largest subset will be the same set itself. But I dont think this is the approach you want to get since it serves no purpose.

Could you tell us what are you using this on? What do you need to accomplish? If you need to find the largest element (given its a number) inside a set then just use the programming approach given above.

Please explain yourself.

#214 Re: Help Me ! » Largest number in subset » 2008-03-28 02:27:10

Didnt we already help you with that?

#215 Re: Help Me ! » Largest number in subset » 2008-03-28 02:09:23

A set is a group or collection of elements. It can be numbers, persons, objects. Anything. It doesnt imply addition like you did. Sure, you could add the elements if its possible but that has nothing to do with the set itself.

A = {1,2,3,4,5}

B = {1,2,3} is a subset of the set above. We say its a subset because every single element in B is in A also. We dont care what those elements add up to.

To put an example that doesnt have to do with numbers so you dont think addition:

Let A = the set of all people living in the world.

Let B = the set of all people living in the US.

B is a subset of A because all the people living in the US also are part of the world. In other words, set B is contained inside set A, therefore B is a subset of A.

#216 Re: Help Me ! » Largest number in subset » 2008-03-27 23:49:22

Thanks Franklin for fixing my code. It would have given an out of bound error.

Let A = {1,2,3,4,5} and let B = {1,2,3} and let C = {1,2}

the numbers inside the { } denote the elements contained in the set separated by commas.

Here B is a subset of A and C is a subset of B but since B is a subset of A then any subsets of B will logically be a subset of A as well.

this is called Set Theory and its not hard to understand. If you want to understand it better you might want to read on it. Post if you have any questions.

I think its really funny how we all ignored Jane's explosion on what I thought was a plausible mistake by mathsy...

#217 Re: Help Me ! » \sqrt{5.44444444}=2.3333333 why? » 2008-03-27 15:31:33

I dont understand your first question. What do you mean why?

#218 Re: Help Me ! » Largest number in subset » 2008-03-27 12:30:36

Also for your original question.

Lets say you have an array of size n which contains integers and you want to see which element inside the array is the largest number.

------------------------------------------------------------

int max_num(int []array) {
int largest_n = array[0];

for (int i=0; i<array.length(), i++) {
     if (array[i+1] > array[i])
         largest_n = array[i+1];
}

return largest_n;
}

------------------------------------------------------------

Im rusty on my java/C++ so dont focus on the syntax.

This code assumes the first element in the array is the largest number and then loops through all the elements checking to see if the next one is larger than the previous, if it is then we assume it is the largest one and continue. When the iteration throughout all the elements in the array is done then largest_n will contain the largest number in the array.

#219 Re: Help Me ! » Largest number in subset » 2008-03-27 12:24:36

Let A = {1,2,3,4,5} and let B = {1,2,3}

B is a subset of A.

When you say subset, you can think of it as "B is contained inside of A".

All the elements of B are also elements of A because B is a subset of A.

#220 Re: Coder's Corner » Converting from one form to another » 2008-03-27 07:44:16

145 + ((72 + 5/2) / 100) is not equal to 145725.

Are you talking about concatenation or regular mathematical addition?

#223 Help Me ! » Total distance travelled by a ball. » 2008-03-24 10:12:31

LuisRodg
Replies: 2

"A ball is dropped from 10 height. Each time it strikes the ground it bounces vertically to a height equal to 3/4 of the preceding height. What is the total distance traveled by the ball?

So I tried to set this up such that when the ball is dropped, thats 10 meters traveled, it bounces up 3/4 of the way so thats (3/4)10 meters travelled etc etc etc. So it looks like an infinite series such as

x = 10 + 10(3/4) + 10(3/4)^2 + 10(3/4)^3 + ...

in which a = 10 and r = 3/4 so by using the Sn formula I get = 40 meters...but the solutions manual says otherwise. What did I do wrong?

#225 Re: Help Me ! » Another Logarithmic Equation problem » 2008-03-24 05:40:00

I was trying to solve the one you put before and you edit it out? Why do you do that? I dont feel like wasting my own time to help you and then you edit it out.

Good luck.

Board footer

Powered by FluxBB