![]() |
|
[Python] Putting a strategy into a python agent - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Putting a strategy into a python agent (/showthread.php?tid=5472518) |
Putting a strategy into a python agent - S M I T H Y - Nov 23, 2016 So im working on some agents to play the Axelrods python game, the agent i currently have is below, what i would like to know is how would i implement a new strategy into this agent? A strategy such as one that always defects? The agent always needs to return either a 'C' for cooperate or D for defect. Code class PlayerFlipper:* - Goodies - Nov 23, 2016 Well, if you want to always defect, just return 'D' every time. * - S M I T H Y - Nov 23, 2016 (Nov 23, 2016 09:40 AM)Goodies Wrote: Well, if you want to always defect, just return 'D' every time. Thanks for your reply, okay so how could i turn it into a strategy thats random, so the agent cooperates or defects on a completely random basis? Another strategy that i want to implement is a Mimic strategy so it mimics other players moves based on previous rounds. * - Goodies - Nov 23, 2016 (Nov 23, 2016 10:36 AM)S M I T H Y Wrote: Thanks for your reply, okay so how could i turn it into a strategy thats random, so the agent cooperates or defects on a completely random basis? how about: PHP Code * - God - Nov 23, 2016 (Nov 23, 2016 10:36 AM)S M I T H Y Wrote: Thanks for your reply, okay so how could i turn it into a strategy thats random, so the agent cooperates or defects on a completely random basis? You can use the random library. PHP Code Is this what you mean by a 'random' strategy? |