achiabodo / compintelligence Goto Github PK
View Code? Open in Web Editor NEWGeneric repo for the 23/24 course of Computational Intelligence @ Polito
License: MIT License
Generic repo for the 23/24 course of Computational Intelligence @ Polito
License: MIT License
The code is well written and the creation of a class for each single player make the code well organized.
Hi Alessandro,
here is a review of your code by me. I hope that you will find it helpful:
Best regards,
Andrea
The code is well-structured, and the evolutionary algorithm for Nim players appears solid. Well done!
Ensure K is considered consistently. Check:
Your number_wins
method involves creating deep copies of the game state and repeatedly playing random moves until the game ends. The repeated simulation of matches can be very computationally expensive, particularly when it's used in the evolutionary process for fitness evaluation.
Lab 9 Peer Review:
PatternBasedAgent
, the idea of diving the 1000-loci genome in smaller repeating subsequence is , in my opinion, simply brilliant.# W: Set of vectors, p: Crossover probability
def uniform_crossover_multiple_ind(W, p):
k = len(W)
l = len(W[0])
v = [0] * l
# Crossover Operation
for i in range(l):
# Check probability
if p >= randint(0,1):
# Load v with ith elements from each vector in W
v = [W[j][i] for j in range(k)]
# Randomly Shuffle v
shuffle(v)
#Put back the values in W
for j in range(k):
W[j][i] = v[j]
#Return modified set of vectors W
return W
Aside from that, this is a very well executed work that shows a complete mastery of the topic and of the python language.
My suggestions and advice:
In the SimulativePlayer play() method, in order to evaluate if a certain state will be a good one, a better choice could be to use two players that knows exactly the best move to perform (for example those who use a Nim sum rule). That is because, in that case, the role of the starting state will be crucial to determine the final result. Moreover, by comparing the results with “best_sum > tmp_sum” you’re getting the worst state and not the best one.
During the training phase you’re choosing parents randomly, which works for Evolution Strategies. But since you're doing crossover, we're not following ES anymore. Instead, consider using a tournament or roulette wheel selection based on fitness, like in GA and GP. Otherwise, to stick to the ES just use tweaking (mutation), although some modern ES methods also mix things up a bit by using also recombinations.
Appreciations:
The code is well written and well organized.
I appreciate the approach in which you associated each possible state of the game to a specific action and how you performed the mutation or the crossover inside the agents.
I think this code is good. It makes a Tic-Tac-Toe game and has different kinds of players, like random ones and a smart one that learns by playing. The game training part looks cool, where the smart player learns and gets better over time. However, in some places, simpler words or comments could make it easier to understand. For example, in the ReinforcedPlayer class, explaining a bit more about why it's updating the Q-values could be helpful. Also, in the training loop, using more clear names for variables could make it easier to follow. Overall, it's a nice code for a game and learning player.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.