You can use scalaz Memo :
val moveCache = Memo.mutableHashMapMemo{ip: (Input, Player) => Move(ip._1, ip._2)} .... val myMove = moveCache((myInput, myPlayer))
Honestly, I doubt very much that this will have a significant impact on performance. Before making your code less readable, make sure you have clear, profiling results that show that it actually makes the difference you think.
source share