forked from ryukinix/lisp-insights
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This game was written in most part using functional style. What I've learned: * Functional programming techniques allows you to write a game program with a "rule engine" that is separate from the rest of the code. You can accomplish this by using function pipelining and building a game tree that is independently traversed by other parts of your game code as the game progresses. * You can create an AI player for a two-player game using the minimax algorithm. This algorithm is based on the truism "What is good for my enemy is bad for me.". It allows you to efficiently rate positions in a two-player board game * Lexical variables (which we've been calling local variables) can live on past the form in which they were created if they are referenced by a lambda expression. Capturing variables in this way is called creating a closure. * Functional programs can be optimized using memoization, which requires you to cache previous results calculated by a function * You can also improve functional programs by using tail call optimizations, which allow you to make sure the call stack isn't abused. You do this by controlling which function appears in the tail call (final) position of your list-eater functions.
- Loading branch information
Showing
2 changed files
with
121 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters