1 / 17

Pasture: Advanced Functional Programming for Game Design

Explore the design of a game board with elements like grass, fences, and animals with abilities to move, eat, and procreate. Learn about algorithms, AI integration, and handling conflicts for a dynamic gaming experience.

milos
Télécharger la présentation

Pasture: Advanced Functional Programming for Game Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PASTURE AdvancedFunctionalProgramming Daniel Strebel Eduardo Hernández Marquina

  2. TheProblem The board: A grid where the different elements are going to interact.

  3. TheProblem Cont. Elements • Fences: • Staticelements • Grass: • Procreate

  4. TheProblem Cont. ElementsCont: Abilities: - Move - Eat - Procreate

  5. Design Game Board

  6. Design cont. Game Board Todo Position-PID

  7. Design cont. Game Board Initialization NO YES Todo> 0 BuildnewTodo Waitfor Message

  8. Design cont. Game Board {start} {req_neighbors} time {neighbors, [{5,4, fox},.]} {move, 3,2 } {ok} Game Board

  9. Design cont. Game Board {start} {req_neighbors} time {neighbors, [{5,4, fox},.]} {move, 3,2 } Request not valid! {conflict, [{5,4, fox},.]} {eat, 4,4} {ok} Game Board

  10. Demo

  11. Limitations • Missing AI - Now action choices are random. • How to add simple AI? - Need to know the positions around. - Develop action priorities. 1.- Stay alive: scape from predators or eat. 2.- To find food: move away from borders.

  12. Algorithms Atoms forelementtypes Usedlibraries Code sharingbetweenanimals

  13. Algorithmscont {Eat_timer, Procreation_timer, Starvation_timer, Move_timer} animal_loop(Position, States, Default_States, Types) -> receive {die, _} -> urks; {start, Gameboard_PID} -> Gameboard_PID ! {request_neighbors, Position, self()}, receive {die, _} -> urks; {neighbors, Neighbor_List} -> decide_animal(Neighbor_List, Gameboard_PID, Position, States, Default_States, Types) end end. {Own_Type, Prey_Type}

  14. Algorithmscont decide_animal(Neighbor_List, Gameboard_PID, Position, States, Default_States, Types) -> {Own_Type, Prey_Type} = Types, {Eat_timer, Procreation_timer, Starvation_timer, Move_timer} = States, Prey_Cells = [{X_cell, Y_cell} || {_, Type, X_cell, Y_cell}<-Neighbor_List, Type==Prey_Type], Free_Cells = [{X_cell, Y_cell} || {_, Type, X_cell, Y_cell}<-Neighbor_List, Type==none], case {Free_Cells, Prey_Cells, Move_timer, Eat_timer, Procreation_timer} of {_, [_|_], _, 0, 0} -> % eat timer and procreation timer are zero and there is at least one neighboring prey cell [...] {[_|_], _, 0, _, _} -> % move timer is zero and there is at least one neighboring empty cell [...] {_, _, _, _, _} -> % no possible actions [...] end.

  15. Whythis produces correctresults Gameboard in charge-> consistent Elements canalwaysselect a possibleactions-> nodeadlocks, singleturns will terminate Order of executionis not guaranteed -> Non-deterministicbehaviour

  16. Difficult cases Find all possiblecases of inconsistency Whatshouldbedone in conflictsituations? Whythe heck isthere a dead lock???

  17. *?#~! ??!! http://code.google.com/p/pasture-uu-ht11/

More Related