Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Need a Strategy to work out

by msk_0984 (Friar)
on Jul 02, 2007 at 06:38 UTC ( #624391=perlquestion: print w/replies, xml ) Need Help??
msk_0984 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I need a strategy to biuld this please help mee out i hav this project to be complted but i am unable to find out a good strategy got soem ideas but they r really not applicable over here ...........

I need your help i need soem good solution strategies Here is wat i need a breif explaination


Nash equilibrium is defined as an outcome with the following property: each player's strategy is the best response against the other player's strategy. In other words, Nash equilibrium consists of two actions that are best responses against each other.

If players' actions are best responses against each other, then neither player will be willing to switch to another action given that his opponent sticks to the equilibrium action. In other words, a player cannot do better by changing his mind, given that his opponent doesn't change his mind. Why? Because if a player changes his mind and switches to another action, this action will be inferior (remember that the equilibrium action is the BEST response against the opponent's action). As a result, the player will be worse off! In a sense, every Nash equilibrium defines a saddle point from which nobody wants to deviate.


Do not confuse a strategy with an action. In most of your games, there are only two available actions. On the other hand, a strategy is a complete algorithm for playing the game that specifies which action the player must take at every step of the game (since the game is played 1000 times between two strategies, there are 1000 such steps). Therefore, you need to implement three different algorithms and play them against each other in a round-robin tournament.


It does not require that you choose perfect strategies. However, I will give you bonus points if your strategies are good, i.e., they can defeat most other strategies. An example of a weak strategy is a strategy that always plays the same move (1000 times) regardless of the opponent's behavior.


A good strategy must take into account the history of all previous moves played by the player and his opponent and define the player's next move. The main problem in defining the next move is that the strategy doesn't know how the opponent is going to play (please, keep in mind that the players make their moves simultaneously without knowing what the other player is going to do). A "smart" strategy would try to predict the opponent's next move based on the history of his previous moves. Since every game is played 1000 times in a row, the strategy can collect information about the opponent's past moves, opponent's reactions to specific moves (or to specific move sequences) and came up with a reasonable guess about the opponent's next move. As you can see, a good strategy would try to learn from the previous moves and adjust its behavior appropriately in order to defeat the opponent.

The bottom line is that a good strategy must be dynamic. It would take into account the opponent's previous moves and adjust its behavior appropriately. In other words, it will dynamically change its behavior as a response to the opponent's past behavior.


The simplest dynamic strategy is a random strategy. However, it is not a very smart choice because it does not learn from the opponent's past moves. After you come up with some good strategies, you could test them against a random strategy to see how good they are. In fact, playing against a random strategy is not as easy as it could seem (because one cannot come up with any rational expectations. If your opponent plays randomly, then everything is possible).

There is no problem if one of your strategies is purely random.


- Three different strategies, i.e., three methods that can play a round of 1000 games in a row against the same opponent. In every single game (there are 1000 such games in a round), the output of your method must be an action. Usually there are two available actions, and your method (strategy) must decide which action to play.

- A main program that can play a round-robin tournament between the three strategies (methods). When the main program plays two strategies against each other, it enters a loop (of 1000 repetitions) in every step of which it receives the outputs from the strategies, determines the outcome, and sends each strategy its score and the opponent's move (remember that when a strategy decides which action to play, it doesn't know how the opponent is going to play). After all three strategies are played against one another, the main program reports the final result from the tournament.

Please provide me a better strategy or any good idea for this and help me out monks....

Work Hard Party Harderrr!!
Sushil Kumar

Replies are listed 'Best First'.
Re: Need a Strategy to work out
by Polonius (Friar) on Jul 02, 2007 at 08:43 UTC

    This is fairly obviously homework (Hint: If you want to disguise homework, you need to spell-check the text you've added at least as carefully as what you've cut-and-pasted), so you ought to be particularly clear about where you need help. We can all get stuck with homework, and just need a nudge in the right direction to get going again. Monks will be happy to give you that nudge, provided you're honest about it, and give them enough information to help.

    You say you need a "strategy", but the assignment is about testing three different "strategies". I suspect you're using the word "strategy" to mean something different, a strategy for comparing strategies - perhaps you could call it a "meta-strategy"?

    If I'm wrong, and you really want us to help with game-playing strategies, then you need to tell us what the game is. Even if I'm right, I think telling us what the game is would help us understand the context (though I accept the argument that it could cloud our thinking).

      Well, yes, it's obviously homework. So obviously homework ("I will give you bonus points if...") that I don't think it was necessary for him to say "this is homework".

      I'd like to see some of the additional information you suggested he add, too, and would gladly nudge if I have any ideas after seeing the details of where he (or his friend) is at.

      Yaah that is true, it is my friends home work to say it truly and responsibly I said I am not gonna paste it here but he said I am desperate for this and I need some strategies so that I can get a solution here. I myself don't know wat it is all about in an intention to help him out i hav pasted this thing and in turn i got -ve points and bad remarks on meeee.

      I am really very sorry monks for voilating the ethics of the site and the main purpose for which the site has been built. Also i hav removed the exclaimation marks also .

      Work Hard Party Harderrr
      Sushil Kumar
        Yaah that is true, it is my friends home work to say it truly and responsibly

        Yaah, something along the lines of:

        my $dad=I::Have::Got->new('problem'); $dad->inform(who => 'a friend of mine', whom => 'his girlfriend', wtf => 'pregnant');

        In that case I suggest your friend join PerlMonks and ask his own questions.

        DWIM is Perl's answer to Gödel
        Desperates pay money for solution
Re: Need a Strategy to work out
by GrandFather (Sage) on Jul 02, 2007 at 08:08 UTC

    How about you tell us something about what you've done so far? We tend not to do people's homework for them, but we do help out with specific issues you may have.

    I note that there is no mention of the game play mechanism nor the framework that would drive your code.

    DWIM is Perl's answer to Gödel
Re: Need a Strategy to work out
by fenLisesi (Priest) on Jul 02, 2007 at 08:02 UTC
    I don't see how you can have only two exclamation marks after Party Harderrr. Surely, partying harderrr is important enough to deserve at least three exclamation marks.
Re: Need a Strategy to work out
by chanio (Priest) on Jul 05, 2007 at 01:10 UTC
    I am not sure to understand your interesting question. But, I will try to help...

    Could you give an example by comparing your idea with a chess game?

    When you only know how to play with one piece alone, you might reach to an 'even' situation with an enemy. Then, you should use another piece to help your main piece. That might be the incentive...

    The goal is always to win the game, but you should have stronger goals related with their inminence: reach the middle of the field, get free from your threats, increase your power, widen your alternatives, etc. When you are close to loosing the game, your goals are only the inminent ones. And very few: survive! You should always be able to sort those goals and re-evaluate their benefits. These should redefine your strategies...

    If every helping piece could move freely with its own goal, then your sorting might be also full of namespaces, and more complex... So, it is always better to cooperate with your enemy and leave him move freely without reaching to a 'static' or 'even' situation.

    Do these make any sense? If so, I am glad to have helped you.

    • Landlords production is only eaten by landlords...

      oh please, obviously it's your homework, I hope I can track your ass and give you an F
Re: Need a Strategy to work out
by jesuashok (Curate) on Jul 03, 2007 at 05:49 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://624391]
Front-paged by JSchmitz
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-06-17 22:20 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.