Showing posts with label Game Theory. Show all posts
Showing posts with label Game Theory. Show all posts
Friday, May 24, 2019
1199 - Partitioning Game
Problem Link
Concept:
Grundy’s game:
Sometimes a move in the game divides the game into sub-games that are independent
of each other. In this case, the Grundy number of the game is
mex({g1, g2,..., gn}),
where n is the number of possible moves and
gk = ak,1 xor ak,2 xor ... xor ak,m,
where move k generates sub-games with Grundy numbers ak,1,ak,2,...,ak,m.
An example of such a game is Grundy’s game. Initially, there is a single
heap that contains n sticks. On each turn, the player chooses a heap and divides
it into two nonempty heaps such that the heaps are of different size. The player
who makes the last move wins the game.
Let f (n) be the Grundy number of a heap that contains n sticks. The Grundy
number can be calculated by going through all ways to divide the heap into two
heaps. For example, when n = 8, the possibilities are 1+7, 2+6 and 3+5, so
f (8) = mex({ f (1) xor f (7), f (2) xor f (6), f (3) xor f (5)}).
In this game, the value of f (n) is based on the values of f (1),..., f (n-1). The
base cases are f (1) xor f (2) = 0, because it is not possible to divide the heaps of 1
and 2 sticks. The first Grundy numbers are:
f (1) = 0
f (2) = 0
f (3) = 1
f (4) = 0
f (5) = 2
f (6) = 1
f (7) = 0
f (8) = 2
The Grundy number for n = 8 is 2, so it is possible to win the game. The winning
move is to create heaps 1+7, because f (1) xor f (7) = 0.
Solution:
Concept:
Grundy’s game:
Sometimes a move in the game divides the game into sub-games that are independent
of each other. In this case, the Grundy number of the game is
mex({g1, g2,..., gn}),
where n is the number of possible moves and
gk = ak,1 xor ak,2 xor ... xor ak,m,
where move k generates sub-games with Grundy numbers ak,1,ak,2,...,ak,m.
An example of such a game is Grundy’s game. Initially, there is a single
heap that contains n sticks. On each turn, the player chooses a heap and divides
it into two nonempty heaps such that the heaps are of different size. The player
who makes the last move wins the game.
Let f (n) be the Grundy number of a heap that contains n sticks. The Grundy
number can be calculated by going through all ways to divide the heap into two
heaps. For example, when n = 8, the possibilities are 1+7, 2+6 and 3+5, so
f (8) = mex({ f (1) xor f (7), f (2) xor f (6), f (3) xor f (5)}).
In this game, the value of f (n) is based on the values of f (1),..., f (n-1). The
base cases are f (1) xor f (2) = 0, because it is not possible to divide the heaps of 1
and 2 sticks. The first Grundy numbers are:
f (1) = 0
f (2) = 0
f (3) = 1
f (4) = 0
f (5) = 2
f (6) = 1
f (7) = 0
f (8) = 2
The Grundy number for n = 8 is 2, so it is possible to win the game. The winning
move is to create heaps 1+7, because f (1) xor f (7) = 0.
Solution:
Tuesday, May 21, 2019
Game Theory (Nim)
Tutorial
1186 - Incredible Chess
বোর্ডের মাপকে স্তুপ সংখ্যা হিসেবে বিবেচনা করবো এবং কালো গুটি থেকে সাদা গুটির দূরত্বকে (কয়টি চাল দেওয়া সম্ভব তার সংখ্যা ) পাথর সংখ্যা বিবেচনা করবো। তারপর সমস্যাটি খুব সহজেই নিম অ্যালগোরিদম দিয়ে সমাধান করা যায়।
1192 - Left Right
সাদা এবং ধূসর বর্ণের ঘরের মধ্যবর্তী দূরত্বকে পাথরের সংখ্যা এবং প্রতিটি ধূসর-সাদা এর মধ্যের দূরত্বকে একটি করে স্তম্ভ বিবেচনা করবো।
1247 - Matrix Game
Tutorial এ hints দেওয়া আছে।
1253 - Misere Nim
Tutorial এ hints দেওয়া আছে।
1393 - Crazy Calendar
(1, 1) হতে (row, column) point এ যেতে যে কয়টা ঘর অতিক্রম করতে হয় সেটাই হচ্ছে পাথরের সংখ্যা ।
1186 - Incredible Chess
বোর্ডের মাপকে স্তুপ সংখ্যা হিসেবে বিবেচনা করবো এবং কালো গুটি থেকে সাদা গুটির দূরত্বকে (কয়টি চাল দেওয়া সম্ভব তার সংখ্যা ) পাথর সংখ্যা বিবেচনা করবো। তারপর সমস্যাটি খুব সহজেই নিম অ্যালগোরিদম দিয়ে সমাধান করা যায়।
1192 - Left Right
সাদা এবং ধূসর বর্ণের ঘরের মধ্যবর্তী দূরত্বকে পাথরের সংখ্যা এবং প্রতিটি ধূসর-সাদা এর মধ্যের দূরত্বকে একটি করে স্তম্ভ বিবেচনা করবো।
1247 - Matrix Game
Tutorial এ hints দেওয়া আছে।
1253 - Misere Nim
Tutorial এ hints দেওয়া আছে।
1393 - Crazy Calendar
(1, 1) হতে (row, column) point এ যেতে যে কয়টা ঘর অতিক্রম করতে হয় সেটাই হচ্ছে পাথরের সংখ্যা ।
Subscribe to:
Posts (Atom)